Skip to content

Commit 8778de5

Browse files
committed
Apply new factory registration mechanism
1 parent e7786f0 commit 8778de5

10 files changed

+97
-49
lines changed

src/SofaSphFluid/OglFluidModel.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ namespace sofa::component::visualmodel
88

99
SOFA_DECL_CLASS(OglFluidModel)
1010

11-
int OglFluidModelClass = sofa::core::RegisterObject("Particle model for OpenGL display, using glsl")
12-
.add< OglFluidModel<sofa::defaulttype::Vec3Types> >();
11+
void registerOglFluidModel(sofa::core::ObjectFactory* factory)
12+
{
13+
factory->registerObjects(sofa::core::ObjectRegistrationData("Particle model for OpenGL display, using glsl.")
14+
.add< OglFluidModel<sofa::defaulttype::Vec3Types> >());
15+
}
1316

1417
template class SOFA_SPH_FLUID_API OglFluidModel<sofa::defaulttype::Vec3Types>;
1518

src/SofaSphFluid/ParticleSink.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@
2828
namespace sofa::component::misc
2929
{
3030

31-
int ParticleSinkClass = core::RegisterObject("Parametrable particle generator")
32-
.add< ParticleSink<defaulttype::Vec3Types> >()
33-
.add< ParticleSink<defaulttype::Vec2Types> >()
34-
;
31+
void registerParticleSink(sofa::core::ObjectFactory* factory)
32+
{
33+
factory->registerObjects(sofa::core::ObjectRegistrationData("Parametrable particle generator.")
34+
.add< ParticleSink<defaulttype::Vec3Types> >()
35+
.add< ParticleSink<defaulttype::Vec2Types> >());
36+
}
3537

3638
template class SOFA_SPH_FLUID_API ParticleSink<defaulttype::Vec3Types>;
3739
template class SOFA_SPH_FLUID_API ParticleSink<defaulttype::Vec2Types>;

src/SofaSphFluid/ParticleSource.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,17 @@
2828
namespace sofa::component::misc
2929
{
3030

31-
int ParticleSourceClass = core::RegisterObject("Parametrable particle generator")
32-
.add< ParticleSource<defaulttype::Vec3Types> >()
33-
.add< ParticleSource<defaulttype::Vec2Types> >()
31+
void registerParticleSource(sofa::core::ObjectFactory* factory)
32+
{
33+
factory->registerObjects(sofa::core::ObjectRegistrationData("Parametrable particle generator.")
34+
.add< ParticleSource<defaulttype::Vec3Types> >()
35+
.add< ParticleSource<defaulttype::Vec2Types> >());
36+
}
3437

35-
;
3638

3739
template class SOFA_SPH_FLUID_API ParticleSource<defaulttype::Vec3Types>;
3840
template class SOFA_SPH_FLUID_API ParticleSource<defaulttype::Vec2Types>;
3941

40-
4142
}
4243

4344

src/SofaSphFluid/ParticlesRepulsionForceField.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,16 @@ namespace sofa::component::forcefield
3232
using namespace sofa::defaulttype;
3333
using namespace core::behavior;
3434

35-
36-
int ParticlesRepulsionForceFieldClass = core::RegisterObject("ForceField using SpatialGridContainer to compute repulsion forces in a set of spheres")
37-
.add< ParticlesRepulsionForceField<Vec3Types> >()
38-
.add< ParticlesRepulsionForceField<Vec2Types> >()
39-
40-
;
35+
void registerParticlesRepulsionForceField(sofa::core::ObjectFactory* factory)
36+
{
37+
factory->registerObjects(sofa::core::ObjectRegistrationData("ForceField using SpatialGridContainer to compute repulsion forces in a set of spheres.")
38+
.add< ParticlesRepulsionForceField<Vec3Types> >()
39+
.add< ParticlesRepulsionForceField<Vec2Types> >());
40+
}
4141

4242
template class SOFA_SPH_FLUID_API ParticlesRepulsionForceField<Vec3Types>;
4343
template class SOFA_SPH_FLUID_API ParticlesRepulsionForceField<Vec2Types>;
4444

45-
4645
} // namespace sofa::component::forcefield
4746

4847

src/SofaSphFluid/SPHFluidForceField.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,15 @@ namespace sofa::component::forcefield
3232
using namespace sofa::defaulttype;
3333
using namespace core::behavior;
3434

35-
36-
int SPHFluidForceFieldClass = core::RegisterObject("Smooth Particle Hydrodynamics")
37-
.add< SPHFluidForceField<Vec3Types> >()
38-
//.add< SPHFluidForceField<Vec2Types> >()
39-
40-
;
35+
void registerSPHFluidForceField(sofa::core::ObjectFactory* factory)
36+
{
37+
factory->registerObjects(sofa::core::ObjectRegistrationData("Smooth Particle Hydrodynamics.")
38+
.add< SPHFluidForceField<Vec3Types> >());
39+
}
4140

4241
template class SOFA_SPH_FLUID_API SPHFluidForceField<Vec3Types>;
4342
template class SOFA_SPH_FLUID_API SPHFluidForceField<Vec2Types>;
4443

45-
4644
} // namespace sofa::component::forcefield
4745

4846

src/SofaSphFluid/SPHFluidSurfaceMapping.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ namespace sofa::component::mapping
3131
using namespace sofa::defaulttype;
3232

3333
// Register in the Factory
34-
int SPHFluidSurfaceMappingClass = core::RegisterObject("SPHFluidSurfaceMappingClass")
35-
.addAlias("MarchingCubeMapping")
36-
.add< SPHFluidSurfaceMapping< Vec3Types, Vec3Types > >()
37-
;
34+
void registerSPHFluidSurfaceMapping(sofa::core::ObjectFactory* factory)
35+
{
36+
factory->registerObjects(sofa::core::ObjectRegistrationData("Mapping the surface of a Smooth Particle Hydrodynamics model.")
37+
.add< SPHFluidSurfaceMapping< Vec3Types, Vec3Types > >());
38+
}
3839

3940
template class SOFA_SPH_FLUID_API SPHFluidSurfaceMapping< Vec3Types, Vec3Types >;
4041

src/SofaSphFluid/SpatialGridContainer.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ namespace sofa::component::container
3030
using namespace sofa::defaulttype;
3131
using namespace core::behavior;
3232

33-
34-
int SpatialGridContainerClass = core::RegisterObject("Hashing spatial grid container, used for SPH fluids for instance.")
35-
.add< SpatialGridContainer<Vec3Types> >()
36-
;
33+
void registerSpatialGridContainer(sofa::core::ObjectFactory* factory)
34+
{
35+
factory->registerObjects(sofa::core::ObjectRegistrationData("Hashing spatial grid container, used for SPH fluids for instance.")
36+
.add< SpatialGridContainer<Vec3Types> >());
37+
}
3738

3839
template class SOFA_SPH_FLUID_API SpatialGridContainer< Vec3Types >;
3940
template class SOFA_SPH_FLUID_API SpatialGrid< SpatialGridTypes< Vec3Types > >;
4041

41-
4242
} // namespace sofa::component::container
4343

4444

src/SofaSphFluid/SpatialGridPointModel.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ namespace sofa::component::collision
3131

3232
using namespace sofa::component::collision::geometry;
3333

34-
int SpatialGridPointModelClass = core::RegisterObject("Collision model which represents a set of points, spatially grouped using a SpatialGridContainer")
35-
.add< SpatialGridPointModel >()
36-
;
34+
void registerSpatialGridPointModel(sofa::core::ObjectFactory* factory)
35+
{
36+
factory->registerObjects(sofa::core::ObjectRegistrationData("Collision model which represents a set of points, spatially grouped using a SpatialGridContainer.")
37+
.add< SpatialGridPointModel >());
38+
}
3739

3840
SpatialGridPointModel::SpatialGridPointModel()
3941
: d_leafScale(initData(&d_leafScale,0,"leafScale","at which level should the first cube layer be constructed.\nNote that this must not be greater than GRIDDIM_LOG2"))

src/SofaSphFluid/config.h.in

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
* *
2020
* Contact information: contact@sofa-framework.org *
2121
******************************************************************************/
22-
#ifndef SOFASPHFLUID_CONFIG_H
23-
#define SOFASPHFLUID_CONFIG_H
22+
#pragma once
2423

2524
#include <sofa/config.h>
2625

@@ -33,4 +32,8 @@
3332
# define SOFA_SPH_FLUID_API SOFA_IMPORT_DYNAMIC_LIBRARY
3433
#endif
3534

36-
#endif
35+
namespace sofasphfluid
36+
{
37+
constexpr const char* MODULE_NAME = "@PROJECT_NAME@";
38+
constexpr const char* MODULE_VERSION = "@PROJECT_VERSION@";
39+
} // namespace sofasphfluid

src/SofaSphFluid/initSPHFluid.cpp

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,39 @@
2121
******************************************************************************/
2222
#include <SofaSphFluid/config.h>
2323

24+
#include <sofa/core/ObjectFactory.h>
25+
#include <sofa/helper/system/PluginManager.h>
2426

25-
namespace sofa::component
27+
28+
namespace sofa::component::misc
29+
{
30+
extern void registerParticleSink(sofa::core::ObjectFactory* factory);
31+
extern void registerParticleSource(sofa::core::ObjectFactory* factory);
32+
}
33+
namespace sofa::component::collision
34+
{
35+
extern void registerSpatialGridPointModel(sofa::core::ObjectFactory* factory);
36+
}
37+
namespace sofa::component::container
38+
{
39+
extern void registerSpatialGridContainer(sofa::core::ObjectFactory* factory);
40+
}
41+
namespace sofa::component::forcefield
42+
{
43+
extern void registerParticlesRepulsionForceField(sofa::core::ObjectFactory* factory);
44+
extern void registerSPHFluidForceField(sofa::core::ObjectFactory* factory);
45+
}
46+
namespace sofa::component::mapping
47+
{
48+
extern void registerSPHFluidSurfaceMapping(sofa::core::ObjectFactory* factory);
49+
}
50+
namespace sofa::component::visualmodel
51+
{
52+
extern void registerOglFluidModel(sofa::core::ObjectFactory* factory);
53+
}
54+
55+
56+
namespace sofasphfluid
2657
{
2758

2859
extern "C" {
@@ -31,26 +62,29 @@ SOFA_SPH_FLUID_API const char* getModuleName();
3162
SOFA_SPH_FLUID_API const char* getModuleVersion();
3263
SOFA_SPH_FLUID_API const char* getModuleLicense();
3364
SOFA_SPH_FLUID_API const char* getModuleDescription();
34-
SOFA_SPH_FLUID_API const char* getModuleComponentList();
65+
SOFA_SPH_FLUID_API void registerObjects(sofa::core::ObjectFactory* factory);
3566
}
3667

3768
void initExternalModule()
3869
{
3970
static bool first = true;
4071
if (first)
4172
{
73+
// make sure that this plugin is registered into the PluginManager
74+
sofa::helper::system::PluginManager::getInstance().registerPlugin(MODULE_NAME);
75+
4276
first = false;
4377
}
4478
}
4579

4680
const char* getModuleName()
4781
{
48-
return "SofaSphFluid";
82+
return MODULE_NAME;
4983
}
5084

5185
const char* getModuleVersion()
5286
{
53-
return "1.0";
87+
return MODULE_VERSION;
5488
}
5589

5690
const char* getModuleLicense()
@@ -63,13 +97,18 @@ const char* getModuleDescription()
6397
return "This plugin contains fluids simulation based on the SPH method.";
6498
}
6599

66-
const char* getModuleComponentList()
100+
void registerObjects(sofa::core::ObjectFactory* factory)
67101
{
68-
return "SpatialGridContainer SPHFluidForceField SPHFluidSurfaceMapping"
69-
" ParticleSink ParticuleSource ParticlesRepulsionForceField";
102+
sofa::component::misc::registerParticleSink(factory);
103+
sofa::component::misc::registerParticleSource( factory);
104+
sofa::component::collision::registerSpatialGridPointModel(factory);
105+
sofa::component::container::registerSpatialGridContainer(factory);
106+
sofa::component::forcefield::registerParticlesRepulsionForceField(factory);
107+
sofa::component::forcefield::registerSPHFluidForceField(factory);
108+
sofa::component::mapping::registerSPHFluidSurfaceMapping(factory);
109+
sofa::component::visualmodel::registerOglFluidModel(factory);
70110
}
71111

72-
73-
} // namespace sofa::component
112+
} // namespace sofasphfluid
74113

75114

0 commit comments

Comments
 (0)