|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
9 #ifndef YARP_OS_SHAREDLIBRARYCLASSAPI_H
10 #define YARP_OS_SHAREDLIBRARYCLASSAPI_H
22 #define YARP_SHAREDLIBRARYCLASSAPI_PADDING (30 - 2 * (YARP_POINTER_SIZE / 4))
61 #define YARP_SHARED_CLASS_FN extern "C" YARP_EXPORT
79 #define YARP_DEFINE_SHARED_SUBCLASS(factoryname, classname, basename) \
80 YARP_SHARED_CLASS_FN void* factoryname##_create() \
82 classname* cn = new classname; \
83 basename* bn = dynamic_cast<basename*>(cn); \
86 return static_cast<void*>(bn); \
88 YARP_SHARED_CLASS_FN void factoryname##_destroy(void* obj) \
90 classname* cn = dynamic_cast<classname*>(static_cast<basename*>(obj)); \
94 YARP_SHARED_CLASS_FN int factoryname##_getVersion(char* ver, int len) \
98 YARP_SHARED_CLASS_FN int factoryname##_getAbi(char* abi, int len) \
102 YARP_SHARED_CLASS_FN int factoryname##_getClassName(char* name, int len) \
104 char cname[] = #classname; \
105 strncpy(name, cname, len); \
106 return strlen(cname) + 1; \
108 YARP_SHARED_CLASS_FN int factoryname##_getBaseClassName(char* name, int len) \
110 char cname[] = #basename; \
111 strncpy(name, cname, len); \
112 return strlen(cname) + 1; \
114 YARP_SHARED_CLASS_FN int factoryname(void* api, int len) \
116 struct yarp::os::SharedLibraryClassApi* sapi = (struct yarp::os::SharedLibraryClassApi*)api; \
117 if (len < (int)sizeof(yarp::os::SharedLibraryClassApi)) \
119 sapi->startCheck = yarp::os::createVocab('Y', 'A', 'R', 'P'); \
120 sapi->structureSize = sizeof(yarp::os::SharedLibraryClassApi); \
121 sapi->systemVersion = 5; \
122 sapi->create = factoryname##_create; \
123 sapi->destroy = factoryname##_destroy; \
124 sapi->getVersion = factoryname##_getVersion; \
125 sapi->getAbi = factoryname##_getAbi; \
126 sapi->getClassName = factoryname##_getClassName; \
127 sapi->getBaseClassName = factoryname##_getBaseClassName; \
128 for (int i = 0; i < YARP_SHAREDLIBRARYCLASSAPI_PADDING; i++) { \
129 sapi->roomToGrow[i] = 0; \
131 sapi->endCheck = yarp::os::createVocab('P', 'L', 'U', 'G'); \
132 return sapi->startCheck; \
145 #define YARP_DEFAULT_FACTORY_NAME "yarp_default_factory"
146 #define YARP_DEFINE_DEFAULT_SHARED_CLASS(classname) YARP_DEFINE_SHARED_SUBCLASS(yarp_default_factory, classname, classname)
147 #define YARP_DEFINE_SHARED_CLASS(factoryname, classname) YARP_DEFINE_SHARED_SUBCLASS(factoryname, classname, classname)
149 #endif // YARP_OS_SHAREDLIBRARYCLASS_H
int(* getVersion)(char *ver, int len)
NetInt32 roomToGrow[(30 - 2 *(8/4))]
#define YARP_END_PACK
Ends 1 byte packing for structs/classes.
#define YARP_BEGIN_PACK
Starts 1 byte packing for structs/classes.
int(* getAbi)(char *abi, int len)
void(* destroy)(void *obj)
Collection of hooks for creating/destroying a plugin.
int(* getClassName)(char *name, int len)
#define YARP_SHAREDLIBRARYCLASSAPI_PADDING
The main, catch-all namespace for YARP.
int(* getBaseClassName)(char *name, int len)
std::int32_t NetInt32
Definition of the NetInt32 type.