Skip to content

Commit 34ecb59

Browse files
committed
apply new register mechanism to the "essential" components
1 parent 539b6be commit 34ecb59

File tree

5 files changed

+36
-20
lines changed

5 files changed

+36
-20
lines changed

Sofa/framework/Simulation/Core/src/sofa/simulation/DefaultAnimationLoop.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,18 @@
5656
namespace sofa::simulation
5757
{
5858

59-
int DefaultAnimationLoopClass = core::RegisterObject("Simulation loop to use in scene without constraints nor contact.")
60-
.add<DefaultAnimationLoop>()
61-
.addDocumentationURL(std::string(sofa::SOFA_DOCUMENTATION_URL) + std::string("components/animationloops/defaultanimationloop/"))
62-
.addDescription(R"(
59+
void registerDefaultAnimationLoop(sofa::core::ObjectFactory* factory)
60+
{
61+
factory->registerObjects(core::ObjectRegistrationData("Simulation loop to use in scene without constraints nor contact.")
62+
.add<DefaultAnimationLoop>()
63+
.addDocumentationURL(std::string(sofa::SOFA_DOCUMENTATION_URL) + std::string("components/animationloops/defaultanimationloop/"))
64+
.addDescription(R"(
6365
This loop triggers the following steps:
6466
- build and solve all linear systems in the scene : collision and time integration to compute the new values of the dofs
6567
- update the context (dt++)
6668
- update the mappings
67-
- update the bounding box (volume covering all objects of the scene))");
69+
- update the bounding box (volume covering all objects of the scene))"));
70+
}
6871

6972
DefaultAnimationLoop::DefaultAnimationLoop(simulation::Node* _m_node)
7073
: Inherit()

Sofa/framework/Simulation/Core/src/sofa/simulation/DefaultVisualManagerLoop.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ namespace sofa::core::objectmodel {
3535
namespace sofa::simulation
3636
{
3737

38-
int DefaultVisualManagerLoopClass = core::RegisterObject("The simplest Visual Loop Manager, created by default when user do not put on scene")
39-
.add< DefaultVisualManagerLoop >()
40-
;
38+
void registerDefaultVisualManagerLoop(sofa::core::ObjectFactory* factory)
39+
{
40+
factory->registerObjects(core::ObjectRegistrationData("The simplest Visual Loop Manager, created by default when user does not put one in the scene.")
41+
.add< DefaultVisualManagerLoop >());
42+
}
4143

4244
DefaultVisualManagerLoop::DefaultVisualManagerLoop() :
4345
l_node(initLink("targetNode","Link to the scene's node where the rendering will take place"))

Sofa/framework/Simulation/Core/src/sofa/simulation/RequiredPlugin.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ using sofa::helper::system::PluginManager;
3333
namespace sofa::simulation
3434
{
3535

36-
int RequiredPluginClass = core::RegisterObject("Load the required plugins")
37-
.add< RequiredPlugin >();
36+
void registerRequiredPlugin(sofa::core::ObjectFactory* factory)
37+
{
38+
factory->registerObjects(core::ObjectRegistrationData("Load the required plugins.")
39+
.add< RequiredPlugin >());
40+
}
3841

3942
RequiredPlugin::RequiredPlugin()
4043
: d_pluginName( initData(&d_pluginName, "pluginName", "plugin name (or several names if you need to load different plugins or a plugin with several alternate names)"))

Sofa/framework/Simulation/Core/src/sofa/simulation/init.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,33 @@
2626

2727
#include <sofa/simulation/MainTaskSchedulerRegistry.h>
2828

29+
#include <sofa/core/ObjectFactory.h>
2930

30-
namespace sofa::simulation::core
31+
namespace sofa::simulation
32+
{
33+
34+
extern void registerRequiredPlugin(sofa::core::ObjectFactory* factory);
35+
extern void registerDefaultVisualManagerLoop(sofa::core::ObjectFactory* factory);
36+
extern void registerDefaultAnimationLoop(sofa::core::ObjectFactory* factory);
37+
38+
namespace core
3139
{
3240

3341
static bool s_initialized = false;
3442
static bool s_cleanedUp = false;
3543

44+
3645
SOFA_SIMULATION_CORE_API void init()
3746
{
3847
if (!s_initialized)
3948
{
4049
sofa::core::init();
4150
s_initialized = true;
51+
52+
auto* factory = sofa::core::ObjectFactory::getInstance();
53+
registerRequiredPlugin(factory);
54+
registerDefaultVisualManagerLoop(factory);
55+
registerDefaultAnimationLoop(factory);
4256
}
4357
}
4458

@@ -73,7 +87,9 @@ static const struct CleanupCheck
7387
}
7488
} check;
7589

76-
} // namespace sofa::simulation::core
90+
} // namespace core
91+
92+
} // namespace sofa::simulation
7793

7894

7995

Sofa/framework/Simulation/Graph/src/sofa/simulation/graph/DAGSimulation.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,4 @@ Node::SPtr DAGSimulation::createNewNode(const std::string& name)
5757
return sofa::core::objectmodel::New<DAGNode>(name);
5858
}
5959

60-
61-
62-
// Register in the Factory
63-
//int DAGSimulationClass = core::RegisterObject ( "Main simulation algorithm, based on tree graph" )
64-
//.add< DAGSimulation >()
65-
//;
66-
67-
6860
} // namespace sofa::simulation::graph

0 commit comments

Comments
 (0)