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

[Playback] Apply new factory registration mechanism #4933

Merged
merged 4 commits into from
Sep 5, 2024
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
Expand Up @@ -98,10 +98,11 @@ std::string lookForValidCompareStateFile( const std::string& sceneName,

}



int CompareStateClass = core::RegisterObject("Compare State vectors from a reference frame to the associated Mechanical State")
.add< CompareState >();
void registerCompareState(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Compare State vectors from a reference frame to the associated Mechanical State.")
.add< CompareState >());
}

CompareState::CompareState(): ReadState()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@
namespace sofa::component::playback
{



int CompareTopologyClass = core::RegisterObject("Compare Topology containers from a reference frame to the associated Topology")
.add< CompareTopology >();
void registerCompareTopology(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Compare Topology containers from a reference frame to the associated Topology.")
.add< CompareTopology >());
}

CompareTopology::CompareTopology(): ReadTopology()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@
namespace sofa::component::playback
{

// Register in the Factory
int InputEventReaderClass = core::RegisterObject("Read events from file")
.add< InputEventReader >();
void registerInputEventReader(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Read events from file.")
.add< InputEventReader >());
}

InputEventReader::InputEventReader()
: d_filename(initData(&d_filename, std::string("/dev/input/mouse2"), "filename", "input events file name"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ namespace sofa::component::playback

using namespace defaulttype;

int ReadStateClass = core::RegisterObject("Read State vectors from file at each timestep")
.add< ReadState >();
void registerReadState(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Read State vectors from file at each timestep.")
.add< ReadState >());
}

ReadStateCreator::ReadStateCreator(const core::ExecParams* params)
: Visitor(params)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ namespace sofa::component::playback

using namespace defaulttype;

int ReadTopologyClass = core::RegisterObject("Read topology containers informations from file at each timestep")
.add< ReadTopology >();
void registerReadTopology(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Read topology containers informations from file at each timestep.")
.add< ReadTopology >());
}

ReadTopologyCreator::ReadTopologyCreator(const core::ExecParams* params)
:Visitor(params)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ namespace sofa::component::playback

using namespace defaulttype;


int WriteStateClass = core::RegisterObject("Write State vectors to file at each timestep")
.add< WriteState >();
void registerWriteState(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Write State vectors to file at each timestep.")
.add< WriteState >());
}

WriteStateCreator::WriteStateCreator(const core::ExecParams* params)
:simulation::Visitor(params)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ namespace sofa::component::playback

using namespace defaulttype;



int WriteTopologyClass = core::RegisterObject("Write topology containers informations to file at each timestep")
.add< WriteTopology >();


void registerWriteTopology(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Write topology containers informations to file at each timestep.")
.add< WriteTopology >());
}

WriteTopologyCreator::WriteTopologyCreator(const core::ExecParams* params)
:Visitor(params)
Expand Down
27 changes: 26 additions & 1 deletion Sofa/Component/Playback/src/sofa/component/playback/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,24 @@
******************************************************************************/
#include <sofa/component/playback/init.h>
#include <sofa/core/ObjectFactory.h>
#include <sofa/helper/system/PluginManager.h>

namespace sofa::component::playback
{


extern void registerCompareState(sofa::core::ObjectFactory* factory);
extern void registerCompareTopology(sofa::core::ObjectFactory* factory);
extern void registerInputEventReader(sofa::core::ObjectFactory* factory);
extern void registerReadState(sofa::core::ObjectFactory* factory);
extern void registerReadTopology(sofa::core::ObjectFactory* factory);
extern void registerWriteState(sofa::core::ObjectFactory* factory);
extern void registerWriteTopology(sofa::core::ObjectFactory* factory);

extern "C" {
SOFA_EXPORT_DYNAMIC_LIBRARY void initExternalModule();
SOFA_EXPORT_DYNAMIC_LIBRARY const char* getModuleName();
SOFA_EXPORT_DYNAMIC_LIBRARY const char* getModuleVersion();
SOFA_EXPORT_DYNAMIC_LIBRARY void registerObjects(sofa::core::ObjectFactory* factory);
}

void initExternalModule()
Expand All @@ -45,11 +56,25 @@ const char* getModuleVersion()
return MODULE_VERSION;
}

void registerObjects(sofa::core::ObjectFactory* factory)
{
registerCompareState(factory);
registerCompareTopology(factory);
registerInputEventReader(factory);
registerReadState(factory);
registerReadTopology(factory);
registerWriteState(factory);
registerWriteTopology(factory);
}

void init()
{
static bool first = true;
if (first)
{
// make sure that this plugin is registered into the PluginManager
sofa::helper::system::PluginManager::getInstance().registerPlugin(MODULE_NAME);

first = false;
}
}
Expand Down
1 change: 1 addition & 0 deletions Sofa/Component/src/sofa/component/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ void registerObjects(sofa::core::ObjectFactory* factory)
factory->registerObjectsFromPlugin("Sofa.Component.StateContainer");
factory->registerObjectsFromPlugin("Sofa.Component.Setting");
factory->registerObjectsFromPlugin("Sofa.Component.Visual");
factory->registerObjectsFromPlugin("Sofa.Component.Playback");
factory->registerObjectsFromPlugin("Sofa.Component.SceneUtility");
}

Expand Down
Loading