Skip to content

Commit cb6acf8

Browse files
authored
Apply new factory registration mechanism (#14)
* [all] Update plugin registration mechanism * remove getModuleComponentList * update namespaces to keep only ::pluginexample * add comment in config.h.in and use MODULE_NAME/VERSION
1 parent bed3da1 commit cb6acf8

15 files changed

+105
-75
lines changed

PluginExample_test/MyBehaviorModel_test.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,17 @@ using std::vector;
2626

2727
#include <sofa/testing/BaseTest.h>
2828
using sofa::testing::BaseTest;
29-
3029
using ::testing::Types;
3130

31+
using namespace pluginexample;
32+
3233
namespace {
3334

3435
class MyBehaviorModel_test : public BaseTest,
3536
public ::testing::WithParamInterface<unsigned>
3637
{
3738
public:
38-
using MyBehaviorModel = sofa::component::behaviormodel::MyBehaviorModel;
39+
using MyBehaviorModel = pluginexample::MyBehaviorModel;
3940

4041
void doTearDown() override
4142
{

src/PluginExample/MyBehaviorModel.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <sofa/core/ObjectFactory.h>
2525

2626

27-
namespace sofa::component::behaviormodel
27+
namespace pluginexample
2828
{
2929

3030
MyBehaviorModel::MyBehaviorModel()
@@ -52,8 +52,11 @@ void MyBehaviorModel::updatePosition(double dt)
5252
SOFA_UNUSED(dt);
5353
}
5454

55-
int MyBehaviorModelClass = core::RegisterObject("Dummy component with a custom widget.").add< MyBehaviorModel >();
56-
55+
void registerMyBehaviorModel(sofa::core::ObjectFactory* factory)
56+
{
57+
factory->registerObjects(core::ObjectRegistrationData("Dummy component with a custom widget.")
58+
.add< MyBehaviorModel >());
59+
}
5760

58-
} // namespace sofa::component::behaviormodel
61+
} // namespace pluginexample
5962

src/PluginExample/MyBehaviorModel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <sofa/core/BehaviorModel.h>
2727

2828

29-
namespace sofa::component::behaviormodel
29+
namespace pluginexample
3030
{
3131

3232
/**
@@ -52,5 +52,5 @@ class SOFA_PLUGINEXAMPLE_API MyBehaviorModel : public sofa::core::BehaviorModel
5252
};
5353

5454

55-
} // sofa::component::behaviormodel
55+
} // namespace pluginexample
5656

src/PluginExample/MyDataWidgetUnsigned.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <sofa/helper/Factory.h>
2525

2626

27-
namespace sofa::gui::qt
27+
namespace pluginexample
2828
{
2929

3030
/*
@@ -112,4 +112,4 @@ void MyDataWidgetUnsigned::change()
112112
}
113113

114114

115-
} // namespace sofa::gui::qt
115+
} // namespace pluginexample

src/PluginExample/MyDataWidgetUnsigned.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include <QString>
3232

3333

34-
namespace sofa::gui::qt
34+
namespace pluginexample
3535
{
3636

3737
/**
@@ -65,4 +65,4 @@ protected slots:
6565
};
6666

6767

68-
} // namespace sofa::gui::qt
68+
} // namespace pluginexample

src/PluginExample/MyMappingPendulumInPlane.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@
2727
#include <sofa/defaulttype/VecTypes.h>
2828

2929

30-
namespace sofa::component::mapping
30+
namespace pluginexample
3131
{
3232

3333
using namespace sofa::defaulttype;
3434

35-
36-
int MyMappingPendulumInPlaneClass = core::RegisterObject("Mapping from an angle to a point in 2D")
35+
void registerMyMappingPendulumInPlane(sofa::core::ObjectFactory* factory)
36+
{
37+
factory->registerObjects(core::ObjectRegistrationData("Mapping from an angle to a point in 2D.")
3738
.add< MyMappingPendulumInPlane<Vec1Types, Vec3Types> >()
38-
.add< MyMappingPendulumInPlane<Vec1Types, Vec2Types> >()
39-
;
39+
.add< MyMappingPendulumInPlane<Vec1Types, Vec2Types> >());
40+
}
4041

4142
template class SOFA_PLUGINEXAMPLE_API MyMappingPendulumInPlane<Vec1Types, Vec3Types>;
4243
template class SOFA_PLUGINEXAMPLE_API MyMappingPendulumInPlane<Vec1Types, Vec2Types>;
4344

4445

4546

46-
} // namespace sofa::component::mapping
47-
47+
} // namespace pluginexample

src/PluginExample/MyMappingPendulumInPlane.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <sofa/helper/OptionsGroup.h>
2929

3030

31-
namespace sofa::component::mapping
31+
namespace pluginexample
3232
{
3333

3434
using type::vector;
@@ -84,5 +84,5 @@ class MyMappingPendulumInPlane: public core::Mapping<TIn, TOut>
8484
vector<Vec2> gap;
8585
};
8686

87-
} // namespace sofa::component::mapping
87+
} // namespace pluginexample
8888

src/PluginExample/MyMappingPendulumInPlane.inl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ using std::cerr;
3232
using std::endl;
3333

3434

35-
namespace sofa::component::mapping
35+
namespace pluginexample
3636
{
3737

3838
using helper::ReadAccessor;
@@ -206,4 +206,4 @@ void MyMappingPendulumInPlane<In, Out>::applyDJT(const core::MechanicalParams* m
206206
}
207207

208208

209-
} // namespace sofa::component::mapping
209+
} // namespace pluginexample

src/PluginExample/MyProjectiveConstraintSet.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,22 @@
2424
#include <sofa/core/ObjectFactory.h>
2525

2626

27-
namespace sofa::component::projectiveconstraintset
27+
namespace pluginexample
2828
{
29-
29+
3030
using namespace sofa::defaulttype;
3131

32-
33-
int MyProjectiveConstraintSetClass = core::RegisterObject("just an example of templated component")
32+
void registerMyProjectiveConstraintSet(sofa::core::ObjectFactory* factory)
33+
{
34+
factory->registerObjects(core::ObjectRegistrationData("Just an example of templated component.")
3435
.add< MyProjectiveConstraintSet<Vec3Types> >()
3536
.add< MyProjectiveConstraintSet<Vec1Types> >()
36-
.add< MyProjectiveConstraintSet<Rigid3Types> >()
37-
;
37+
.add< MyProjectiveConstraintSet<Rigid3Types> >());
38+
}
3839

3940
template class SOFA_PLUGINEXAMPLE_API MyProjectiveConstraintSet<Rigid3Types>;
4041
template class SOFA_PLUGINEXAMPLE_API MyProjectiveConstraintSet<Vec3Types>;
4142

4243

4344

44-
} // namespace sofa::component::projectiveconstraintset
45+
} // namespace pluginexample

src/PluginExample/MyProjectiveConstraintSet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <sofa/defaulttype/VecTypes.h>
2929

3030

31-
namespace sofa::component::projectiveconstraintset
31+
namespace pluginexample
3232
{
3333

3434
template <class DataTypes>

0 commit comments

Comments
 (0)