Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply new factory registration mechanism + refresh #162

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/******************************************************************************
/******************************************************************************
* BeamAdapter plugin *
* (c) 2006 Inria, University of Lille, CNRS *
* *
Expand Down Expand Up @@ -26,6 +26,8 @@

TEST(AdaptiveBeamController, target)
{
sofa::simpleapi::importPlugin("BeamAdapter");

const auto node = sofa::simpleapi::createNode("node");
const auto controller = sofa::simpleapi::createObject(node, "AdaptiveBeamController");

Expand Down
28 changes: 10 additions & 18 deletions src/BeamAdapter/component/BeamInterpolation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,17 @@
namespace sofa::component::fem::_beaminterpolation_
{

using namespace sofa::defaulttype;
template class SOFA_BEAMADAPTER_API BeamInterpolation<sofa::defaulttype::Rigid3Types>;

/////////////////////////////////////////// FACTORY ////////////////////////////////////////////////
///
/// Register the component into the sofa factory.
/// For more details:
/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/
///
////////////////////////////////////////////////////////////////////////////////////////////////////

//TODO(damien): Il faut remplacer les descriptions dans RegisterObject par un vrai description
static int BeamInterpolationClass = core::RegisterObject("Adaptive Beam Interpolation")
.add< BeamInterpolation<Rigid3Types> >(true)
;
} // namespace sofa::component::fem::_beaminterpolation_

namespace beamadapter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @fredroy
Could you explain why

  • the template class SOFA_BEAMADAPTER_API BeamInterpolation<sofa::defaulttype::Rigid3Types>; should be in one namespace
  • while the registerBeamInterpolation() is in another namespace ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because:

  • this line (template blabla) must in the same namespace as the declaration in the header
  • I put the registerBeamInterpolation in an other namespace because as I said in the description, namespaces in this plugin is really a mess. This PR could introduce a pathway to normalization. Moreover, I think we said (somewhere 🤔) that namespace should reflect the module/plugin's name.

{

////////////////////////////////////////////////////////////////////////////////////////////////////
/// Explicit template instanciation of extern template.
////////////////////////////////////////////////////////////////////////////////////////////////////
template class SOFA_BEAMADAPTER_API BeamInterpolation<Rigid3Types>;
void registerBeamInterpolation(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("Adaptive Beam Interpolation")
.add< sofa::component::fem::_beaminterpolation_::BeamInterpolation<sofa::defaulttype::Rigid3Types> >());
}

} // namespace sofa::component::fem::_beaminterpolation_
} // namespace beamadapter
24 changes: 10 additions & 14 deletions src/BeamAdapter/component/WireBeamInterpolation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,18 @@

namespace sofa::component::fem::_wirebeaminterpolation_
{
using namespace sofa::defaulttype;

/////////////////////////////////////////// FACTORY ////////////////////////////////////////////////
///
/// Register the component into the sofa factory.
/// For more details:
/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/
///
////////////////////////////////////////////////////////////////////////////////////////////////////

//TODO(damien): Il faut remplacer les descriptions dans RegisterObject par un vrai description
static int WireBeamInterpolationClass = core::RegisterObject("Adaptive Beam Interpolation on Wire rest Shape")
.add< WireBeamInterpolation<Rigid3Types> >();

template class SOFA_BEAMADAPTER_API WireBeamInterpolation<Rigid3Types>;
template class SOFA_BEAMADAPTER_API WireBeamInterpolation<sofa::defaulttype::Rigid3Types>;

} // namespace sofa::component::fem::_wirebeaminterpolation_

namespace beamadapter
{

void registerWireBeamInterpolation(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("Adaptive Beam Interpolation on Wire rest Shape")
.add< sofa::component::fem::_wirebeaminterpolation_::WireBeamInterpolation<sofa::defaulttype::Rigid3Types> >());
}

} // namespace beamadapter
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,17 @@ void AdaptiveBeamLengthConstraintResolution::store(int line, SReal* force, bool
*m_active = (force[line] != 0);
}

template class AdaptiveBeamLengthConstraint<sofa::defaulttype::Rigid3Types>;

using namespace sofa::defaulttype;
using namespace sofa::helper;
using core::RegisterObject;

/////////////////////////////////////////// FACTORY ////////////////////////////////////////////////
///
/// Register the component into the sofa factory.
/// For more details:
/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/
///
////////////////////////////////////////////////////////////////////////////////////////////////////
static int AdaptiveBeamLengthConstraintClass = RegisterObject("Constrain the length of a beam.")
.add< AdaptiveBeamLengthConstraint<Rigid3Types> >(true) // default template

;

template class AdaptiveBeamLengthConstraint<Rigid3Types>;
} // namespace sofa::component::constraintset::_adaptivebeamlengthconstraint_

namespace beamadapter
{

} // namespace sofa::component::constraintset::_adaptivebeamlengthconstraint_
void registerAdaptiveBeamLengthConstraint(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("Constrain the length of a beam.")
.add< sofa::component::constraintset::_adaptivebeamlengthconstraint_::AdaptiveBeamLengthConstraint<sofa::defaulttype::Rigid3Types> >());
}

} // namespace beamadapter
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ using sofa::core::objectmodel::BaseObjectDescription ;
using sofa::component::DeprecatedComponent;
using sofa::defaulttype::Rigid3Types;
using sofa::defaulttype::Rigid3Types;
using sofa::core::RegisterObject;


namespace sofa::component::constraintset::_adaptiveBeamSlidingConstraint_
Expand Down Expand Up @@ -78,25 +77,20 @@ void AdaptiveBeamSlidingConstraintResolution::store(int line, double* force, boo
*m_slidingDisp = force[line+2] * m_slidingW;
}


/////////////////////////////////////////// FACTORY ////////////////////////////////////////////////
///
/// Register the component into the sofa factory.
/// For more details:
/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/
///
////////////////////////////////////////////////////////////////////////////////////////////////////

SOFA_DECL_CLASS(AdaptiveBeamSlidingConstraint)

int AdaptiveBeamSlidingConstraintClass = RegisterObject("Constrain a rigid to be attached to a beam (only in position, not the orientation)")
.add< AdaptiveBeamSlidingConstraint<Rigid3Types> >()

;

template class SOFA_BEAMADAPTER_API AdaptiveBeamSlidingConstraint<Rigid3Types>;


///////////////////////////////////////////////////////////////////////////////////////////////////

} // namespace sofa::component::constraintset::_adaptiveBeamSlidingConstraint_

namespace beamadapter
{

void registerAdaptiveBeamSlidingConstraint(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("Constrain a rigid to be attached to a beam (only in position, not the orientation).")
.add< sofa::component::constraintset::_adaptiveBeamSlidingConstraint_::AdaptiveBeamSlidingConstraint<Rigid3Types> >());
}

} // namespace beamadapter
26 changes: 10 additions & 16 deletions src/BeamAdapter/component/controller/AdaptiveBeamController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,19 @@
namespace sofa::component::controller::_adaptivebeamcontroller_
{

using sofa::defaulttype::Rigid3Types;
using core::RegisterObject;
template class SOFA_BEAMADAPTER_API AdaptiveBeamController<sofa::defaulttype::Rigid3Types>;

/////////////////////////////////////////// FACTORY ////////////////////////////////////////////////
///
/// Register the component into the sofa factory.
/// For more details:
/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/
///
////////////////////////////////////////////////////////////////////////////////////////////////////

//TODO(dmarchal 2017-06-01): Il faut remplacer les descriptions dans RegisterObject par un vrai description
int AdaptiveBeamControllerClass = RegisterObject("Adaptive beam controller")
.add< AdaptiveBeamController<Rigid3Types> >()
;
} // namespace sofa::component::controller::_adaptivebeamcontroller_

template class SOFA_BEAMADAPTER_API AdaptiveBeamController<Rigid3Types>;
namespace beamadapter
{

void registerAdaptiveBeamController(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("Adaptive beam controller.")
.add< sofa::component::controller::_adaptivebeamcontroller_::AdaptiveBeamController<sofa::defaulttype::Rigid3Types> >());
}

} // namespace sofa::component::controller::_adaptivebeamcontroller_
} // namespace beamadapter


Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,17 @@
namespace sofa::component::controller
{

const static int BeamAdapterActionControllerClass = core::RegisterObject("BeamAdapterActionController")
.add< BeamAdapterActionController<sofa::defaulttype::Rigid3Types> >()
;

template class SOFA_BEAMADAPTER_API BeamAdapterActionController<sofa::defaulttype::Rigid3Types>;

} // namespace sofa::component::controller
} // namespace

namespace beamadapter
{

void registerBeamAdapterActionController(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("BeamAdapterActionController")
.add< sofa::component::controller::BeamAdapterActionController<sofa::defaulttype::Rigid3Types> >());
}

} // namespace beamadapter
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,17 @@
namespace sofa::component::controller::_interventionalradiologycontroller_
{

using namespace sofa::defaulttype;


/////////////////////////////////////////// FACTORY ////////////////////////////////////////////////
///
/// Register the component into the sofa factory.
/// For more details:
/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/
///
////////////////////////////////////////////////////////////////////////////////////////////////////

static int InterventionalRadiologyControllerClass = core::RegisterObject("Provides a Mouse & Keyboard user control on an EdgeSet Topology.")
.add< InterventionalRadiologyController<Rigid3Types> >(true)
;

template class SOFA_BEAMADAPTER_API InterventionalRadiologyController<Rigid3Types>;
template class SOFA_BEAMADAPTER_API InterventionalRadiologyController<sofa::defaulttype::Rigid3Types>;

} // namespace sofa::component::controller::_interventionalradiologycontroller_

namespace beamadapter
{

void registerInterventionalRadiologyController(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("Provides a Mouse & Keyboard user control on an EdgeSet Topology.")
.add< sofa::component::controller::_interventionalradiologycontroller_::InterventionalRadiologyController<sofa::defaulttype::Rigid3Types> >());
}

} // namespace beamadapter
24 changes: 10 additions & 14 deletions src/BeamAdapter/component/controller/SutureController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,17 @@
namespace sofa::component::controller::_suturecontroller_
{

using namespace sofa::defaulttype;
template class SOFA_BEAMADAPTER_API SutureController<sofa::defaulttype::Rigid3Types>;

/////////////////////////////////////////// FACTORY ////////////////////////////////////////////////
///
/// Register the component into the sofa factory.
/// For more details:
/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/
///
////////////////////////////////////////////////////////////////////////////////////////////////////
} // namespace

static int SutureControllerClass = core::RegisterObject("Provides a Mouse & Keyboard user control on an EdgeSet Topology.")
.add< SutureController<Rigid3Types> >(true)

;
namespace beamadapter
{

template class SOFA_BEAMADAPTER_API SutureController<Rigid3Types>;
void registerSutureController(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("Provides a Mouse & Keyboard user control on an EdgeSet Topology.")
.add< sofa::component::controller::_suturecontroller_::SutureController<sofa::defaulttype::Rigid3Types> >());
}

} // namespace sofa::component::controller::_suturecontroller_
} // namespace beamadapter
25 changes: 10 additions & 15 deletions src/BeamAdapter/component/engine/SteerableCatheter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,17 @@
namespace sofa::component::engine
{

using namespace sofa::defaulttype;
template class SOFA_BEAMADAPTER_API SteerableCatheter<sofa::defaulttype::Rigid3Types>;

/////////////////////////////////////////// FACTORY ////////////////////////////////////////////////
///
/// Register the component into the sofa factory.
/// For more details:
/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/
///
////////////////////////////////////////////////////////////////////////////////////////////////////

//TODO(damien): Il faut remplacer les descriptions dans RegisterObject par un vrai description
static int SteerableCatheterClass = core::RegisterObject("")
.add< SteerableCatheter<Rigid3Types> >()
}// namespace sofa::component::engine

;
namespace beamadapter
{

template class SOFA_BEAMADAPTER_API SteerableCatheter<Rigid3Types>;
void registerSteerableCatheter(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("Catheter object with a flexible tip based on WireRestShape")
.add< sofa::component::engine::SteerableCatheter<sofa::defaulttype::Rigid3Types> >());
}

}// namespace sofa::component::engine
} // namespace beamadapter
26 changes: 10 additions & 16 deletions src/BeamAdapter/component/engine/WireRestShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,18 @@

namespace sofa::component::engine::_wirerestshape_
{
using namespace sofa::defaulttype;

/////////////////////////////////////////// FACTORY ////////////////////////////////////////////////
///
/// Register the component into the sofa factory.
/// For more details:
/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/
///
////////////////////////////////////////////////////////////////////////////////////////////////////

const int WireRestShapeClass = core::RegisterObject("Describe the shape functions on multiple segments using curvilinear abscissa")
.add< WireRestShape<Rigid3Types> >(true)

;

template class SOFA_BEAMADAPTER_API WireRestShape<Rigid3Types>;

template class SOFA_BEAMADAPTER_API WireRestShape<sofa::defaulttype::Rigid3Types>;

} // namespace sofa::component::engine::_wirerestshape_

namespace beamadapter
{

void registerWireRestShape(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("Describe the shape functions on multiple segments using curvilinear abscissa")
.add< sofa::component::engine::_wirerestshape_::WireRestShape<sofa::defaulttype::Rigid3Types> >());
}

} // namespace beamadapter
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
//
#define SOFA_PLUGIN_BEAMADAPTER_ADAPTIVEBEAMFORCEFIELD_CPP

//////////////////////// Inclusion of headers...from wider to narrower/closer //////////////////////
#include <sofa/defaulttype/RigidTypes.h>
#include <BeamAdapter/config.h>
#include <sofa/core/ObjectFactory.h>
Expand All @@ -43,21 +42,17 @@
namespace sofa::component::forcefield::_adaptivebeamforcefieldandmass_
{

/////////////////////////////////////////// FACTORY ////////////////////////////////////////////////
///
/// Register the component into the sofa factory.
/// For more details:
/// https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/the-objectfactory/
///
////////////////////////////////////////////////////////////////////////////////////////////////////
template class SOFA_BEAMADAPTER_API AdaptiveBeamForceFieldAndMass<sofa::defaulttype::Rigid3Types>;

//TODO(damien): Il faut remplacer les descriptions dans RegisterObject par un vrai description
const static int AdaptiveBeamForceFieldAndMassClass = sofa::core::RegisterObject("Adaptive Beam finite elements")
.add< AdaptiveBeamForceFieldAndMass<sofa::defaulttype::Rigid3Types> >()
;
} // namespace

template class SOFA_BEAMADAPTER_API AdaptiveBeamForceFieldAndMass<sofa::defaulttype::Rigid3Types>;
namespace beamadapter
{

////////////////////////////////////////////////////////////////////////////////////////////////////
void registerAdaptiveBeamForceFieldAndMass(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("Adaptive Beam finite elements")
.add< sofa::component::forcefield::_adaptivebeamforcefieldandmass_::AdaptiveBeamForceFieldAndMass<sofa::defaulttype::Rigid3Types> >());
}

} // namespace sofa::component::forcefield::_adaptivebeamforcefieldandmass_
} // namespace beamadapter
Loading
Loading