Skip to content

Commit 6a2554e

Browse files
committed
Apply new factory registration mechanism
1 parent cdde44d commit 6a2554e

8 files changed

Lines changed: 40 additions & 31 deletions

src/ShapeMatchingPlugin/ShapeMatchingForceField.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,17 @@
2525
#include <sofa/defaulttype/VecTypes.h>
2626
#include <sofa/core/ObjectFactory.h>
2727

28-
namespace sofa::component::forcefield
28+
namespace shapematchingplugin
2929
{
3030

3131
using namespace sofa::defaulttype;
3232

33-
int ShapeMatchingForceFieldClass = core::RegisterObject("Meshless deformations based on shape matching")
34-
.add< ShapeMatchingForceField<Vec3Types> >()
35-
;
33+
void registerShapeMatchingForceField(sofa::core::ObjectFactory* factory)
34+
{
35+
factory->registerObjects(sofa::core::ObjectRegistrationData("Meshless deformations based on shape matching")
36+
.add< ShapeMatchingForceField<Vec3Types> >());
37+
}
3638

3739
template class SOFA_SHAPEMATCHINGPLUGIN_API ShapeMatchingForceField<Vec3Types>;
3840

39-
} // namespace sofa::component::forcefield
41+
} // namespace shapematchingplugin

src/ShapeMatchingPlugin/ShapeMatchingForceField.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
#include <ShapeMatchingPlugin/ShapeMatchingRotationFinder.h>
3232

33-
namespace sofa::component::forcefield
33+
namespace shapematchingplugin
3434
{
3535

3636
/// Meshless deformations based on shape matching
@@ -74,4 +74,4 @@ class ShapeMatchingForceField : public core::behavior::ForceField<DataTypes>
7474
extern template class SOFA_SHAPEMATCHINGPLUGIN_API ShapeMatchingForceField<defaulttype::Vec3Types>;
7575
#endif // !defined(SOFA_COMPONENT_FORCEFIELD_SHAPEMATCHINGFORCEFIELD_CPP)
7676

77-
} // namespace sofa::component::forcefield
77+
} // namespace shapematchingplugin

src/ShapeMatchingPlugin/ShapeMatchingForceField.inl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <assert.h>
2929
#include <iostream>
3030

31-
namespace sofa::component::forcefield
31+
namespace shapematchingplugin
3232
{
3333

3434
template<class DataTypes>
@@ -148,4 +148,4 @@ void ShapeMatchingForceField<DataTypes>::draw(const core::visual::VisualParams*
148148
}
149149

150150

151-
} // namespace sofa::component::forcefield
151+
} // namespace shapematchingplugin

src/ShapeMatchingPlugin/ShapeMatchingRotationFinder.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,19 @@
3232
#include <ShapeMatchingPlugin/ShapeMatchingRotationFinder.inl>
3333
#include <sofa/core/ObjectFactory.h>
3434

35-
namespace sofa::component::container
35+
namespace shapematchingplugin
3636
{
3737

3838
using namespace sofa::defaulttype;
3939

4040
// Register in the Factory
41-
int ShapeMatchingRotationFinderClass = core::RegisterObject("ShapeMatchingRotationFinder")
42-
.add< ShapeMatchingRotationFinder< Vec3Types > >()
43-
.addAlias("RotationFinder")
44-
;
41+
void registerShapeMatchingRotationFinder(sofa::core::ObjectFactory* factory)
42+
{
43+
factory->registerObjects(sofa::core::ObjectRegistrationData("ShapeMatchingRotationFinder")
44+
.add< ShapeMatchingRotationFinder< Vec3Types > >()
45+
.addAlias("RotationFinder"));
46+
}
4547

4648
template class SOFA_SHAPEMATCHINGPLUGIN_API ShapeMatchingRotationFinder< defaulttype::Vec3Types >;
4749

48-
} // namespace sofa::component::container
50+
} // namespace shapematchingplugin

src/ShapeMatchingPlugin/ShapeMatchingRotationFinder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* "Meshless Deformations Based on Shape Matching" (Muller, Heidelberger, Teschner and Gross)
3737
*
3838
*/
39-
namespace sofa::component::container
39+
namespace shapematchingplugin
4040
{
4141

4242
template <class DataTypes>
@@ -120,4 +120,4 @@ class ShapeMatchingRotationFinder : public sofa::core::behavior::RotationFinder<
120120
extern template class SOFA_SHAPEMATCHINGPLUGIN_API ShapeMatchingRotationFinder< defaulttype::Vec3Types >;
121121
#endif
122122

123-
} // namespace sofa::component::container
123+
} // namespace shapematchingplugin

src/ShapeMatchingPlugin/ShapeMatchingRotationFinder.inl

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

3333

34-
namespace sofa::component::container
34+
namespace shapematchingplugin
3535
{
3636

3737
using namespace sofa::core::topology;
@@ -619,4 +619,4 @@ void ShapeMatchingRotationFinder<DataTypes>::draw(const core::visual::VisualPara
619619
vparams->drawTool()->restoreLastState();
620620
}
621621

622-
} // namespace sofa::component::container
622+
} // namespace shapematchingplugin

src/ShapeMatchingPlugin/initShapeMatchingPlugin.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,21 @@
2424
******************************************************************************/
2525
#include <ShapeMatchingPlugin/initShapeMatchingPlugin.h>
2626
#include <sofa/core/ObjectFactory.h>
27+
#include <sofa/helper/system/PluginManager.h>
2728

28-
namespace sofa::component
29+
namespace shapematchingplugin
2930
{
3031

32+
extern void registerShapeMatchingForceField(sofa::core::ObjectFactory* factory);
33+
extern void registerShapeMatchingRotationFinder(sofa::core::ObjectFactory* factory);
34+
3135
extern "C" {
3236
SOFA_SHAPEMATCHINGPLUGIN_API void initExternalModule();
3337
SOFA_SHAPEMATCHINGPLUGIN_API const char* getModuleName();
3438
SOFA_SHAPEMATCHINGPLUGIN_API const char* getModuleVersion();
3539
SOFA_SHAPEMATCHINGPLUGIN_API const char* getModuleLicense();
3640
SOFA_SHAPEMATCHINGPLUGIN_API const char* getModuleDescription();
37-
SOFA_SHAPEMATCHINGPLUGIN_API const char* getModuleComponentList();
41+
SOFA_SHAPEMATCHINGPLUGIN_API void registerObjects(sofa::core::ObjectFactory* factory);
3842
}
3943

4044
void initShapeMatchingPlugin()
@@ -44,6 +48,9 @@ namespace sofa::component
4448

4549
void initExternalModule()
4650
{
51+
// make sure that this plugin is registered into the PluginManager
52+
sofa::helper::system::PluginManager::getInstance().registerPlugin(MODULE_NAME);
53+
4754
static bool first = true;
4855
if (first)
4956
{
@@ -53,12 +60,12 @@ namespace sofa::component
5360

5461
const char* getModuleName()
5562
{
56-
return shapematching::MODULE_NAME;
63+
return MODULE_NAME;
5764
}
5865

5966
const char* getModuleVersion()
6067
{
61-
return shapematching::MODULE_VERSION;
68+
return MODULE_VERSION;
6269
}
6370

6471
const char* getModuleLicense()
@@ -71,11 +78,10 @@ namespace sofa::component
7178
return "Plugin with ShapeMatchingPlugin";
7279
}
7380

74-
const char* getModuleComponentList()
81+
void registerObjects(sofa::core::ObjectFactory* factory)
7582
{
76-
/// string containing the names of the classes provided by the plugin
77-
static std::string classes = sofa::core::ObjectFactory::getInstance()->listClassesFromTarget(sofa_tostring(SOFA_TARGET));
78-
return classes.c_str();
83+
void registerShapeMatchingForceField(factory);
84+
void registerShapeMatchingRotationFinder(factory);
7985
}
8086

81-
} // namespace sofa::component
87+
} // namespace shapematchingplugin

src/ShapeMatchingPlugin/initShapeMatchingPlugin.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@
2424
******************************************************************************/
2525
#include <ShapeMatchingPlugin/config.h>
2626

27-
namespace sofa::component
28-
{
27+
namespace shapematchingplugin
2928

3029
void SOFA_SHAPEMATCHINGPLUGIN_API initShapeMatchingPlugin();
3130

32-
} // namespace sofa::component
31+
} // namespace shapematchingplugin

0 commit comments

Comments
 (0)