Skip to content

Commit c1b7a1b

Browse files
committed
[src] Wrap up new factory registration mechanism in initPlugin.cpp
1 parent b44def5 commit c1b7a1b

File tree

1 file changed

+91
-51
lines changed

1 file changed

+91
-51
lines changed
Lines changed: 91 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,110 @@
1-
#include <string>
2-
#include <stdio.h>
1+
#include <sofa/core/ObjectFactory.h>
32
#include <sofa/helper/system/FileRepository.h>
3+
#include <sofa/helper/system/PluginManager.h>
44
#include <sofa/helper/system/SetDirectory.h>
5-
#include <sofa/core/ObjectFactory.h>
65
#include <stdio.h>
76
#include <string.h>
87

8+
#include <string>
9+
910
#define Q(x) #x
1011
#define QUOTE(x) Q(x)
1112

12-
namespace sofa {
13-
14-
namespace collisionAlgorithm {
15-
16-
//Here are just several convenient functions to help user to know what contains the plugin
17-
18-
extern "C" {
19-
void initExternalModule();
20-
const char* getModuleName();
21-
const char* getModuleVersion();
22-
const char* getModuleLicense();
23-
const char* getModuleDescription();
24-
const char* getModuleComponentList();
25-
}
26-
27-
void initExternalModule()
28-
{
29-
static bool first = true;
30-
if (first)
31-
{
32-
first = false;
13+
namespace sofa::collisionAlgorithm
14+
{
15+
16+
// CollisionPipeline
17+
extern void registerCollisionLoop(sofa::core::ObjectFactory* factory);
18+
19+
// Algorithms
20+
extern void registerFind2DClosestProximityAlgorithm(sofa::core::ObjectFactory* factory);
21+
extern void registerFindClosestProximityAlgorithm(sofa::core::ObjectFactory* factory);
22+
extern void registerInsertionAlgorithm(sofa::core::ObjectFactory* factory);
23+
24+
// BroadPhase
25+
extern void registerAABBBroadPhase(sofa::core::ObjectFactory* factory);
26+
extern void registerFullAABBBroadPhase(sofa::core::ObjectFactory* factory);
27+
28+
// Distance Filters
29+
extern void registerDistanceFilter(sofa::core::ObjectFactory* factory);
30+
31+
// Geometry
32+
extern void registerSubsetGeometry(sofa::core::ObjectFactory* factory);
33+
extern void registerPointGeometry(sofa::core::ObjectFactory* factory);
34+
extern void registerEdgeGeometry(sofa::core::ObjectFactory* factory);
35+
extern void registerTriangleGeometry(sofa::core::ObjectFactory* factory);
36+
extern void registerTetrahedronGeometry(sofa::core::ObjectFactory* factory);
37+
} // namespace sofa::collisionAlgorithm
38+
39+
namespace sofa::component
40+
{
41+
42+
// Here are just several convenient functions to help user to know what contains the plugin
43+
44+
extern "C"
45+
{
46+
void initExternalModule();
47+
const char* getModuleName();
48+
const char* getModuleVersion();
49+
const char* getModuleLicense();
50+
const char* getModuleDescription();
51+
void registerObjects(sofa::core::ObjectFactory* factory);
52+
}
53+
54+
void initCollisionAlgorithm()
55+
{
56+
static bool first = true;
57+
if (first)
58+
{
59+
first = false;
3360
#ifdef PLUGIN_DATA_DIR
34-
sofa::helper::system::DataRepository.addLastPath(std::string(QUOTE(PLUGIN_DATA_DIR)));
61+
sofa::helper::system::DataRepository.addLastPath(std::string(QUOTE(PLUGIN_DATA_DIR)));
3562
#endif
36-
sofa::helper::system::DataRepository.addLastPath(sofa::helper::system::SetDirectory::GetCurrentDir());
37-
}
38-
}
63+
sofa::helper::system::DataRepository.addLastPath(
64+
sofa::helper::system::SetDirectory::GetCurrentDir());
65+
}
66+
}
67+
68+
void initExternalModule()
69+
{
70+
initCollisionAlgorithm();
71+
}
3972

40-
const char* getModuleName()
41-
{
42-
return "CollisionAlgorithm";
43-
}
73+
const char* getModuleName() { return "CollisionAlgorithm"; }
4474

45-
const char* getModuleVersion()
46-
{
75+
const char* getModuleVersion()
76+
{
4777
#ifdef PLUGIN_GIT_INFO
48-
return QUOTE(PLUGIN_GIT_INFO);
78+
return QUOTE(PLUGIN_GIT_INFO);
4979
#else
50-
return "??? to get the last git hash you must active the setupGit macro in CMakeLists";
80+
return "??? to get the last git hash you must active the setupGit macro in CMakeLists";
5181
#endif
52-
}
82+
}
5383

54-
const char* getModuleLicense()
55-
{
56-
return "LGPL";
57-
}
58-
59-
const char* getModuleDescription() {
60-
return "Plugin for collision detection";
61-
}
84+
const char* getModuleLicense() { return "LGPL"; }
6285

63-
const char* getModuleComponentList()
64-
{
65-
return "";
66-
}
86+
const char* getModuleDescription() { return "Plugin for collision detection"; }
6787

68-
}
88+
void registerObjects(sofa::core::ObjectFactory* factory)
89+
{
90+
using namespace sofa::collisionAlgorithm;
91+
// Register CollisionPipeline
92+
registerCollisionLoop(factory);
93+
// Register Algorithms
94+
registerFind2DClosestProximityAlgorithm(factory);
95+
registerFindClosestProximityAlgorithm(factory);
96+
registerInsertionAlgorithm(factory);
97+
// Register BroadPhase
98+
registerAABBBroadPhase(factory);
99+
registerFullAABBBroadPhase(factory);
100+
// Register Distance Filters
101+
registerDistanceFilter(factory);
102+
// Register Geometry
103+
registerSubsetGeometry(factory);
104+
registerPointGeometry(factory);
105+
registerEdgeGeometry(factory);
106+
registerTriangleGeometry(factory);
107+
registerTetrahedronGeometry(factory);
108+
}
69109

70-
}
110+
} // namespace sofa::component

0 commit comments

Comments
 (0)