22 #ifndef ROBOTTESTINGFRAMEWORK_SHAREDLIBRARYCLASSAPI_H 23 #define ROBOTTESTINGFRAMEWORK_SHAREDLIBRARYCLASSAPI_H 29 struct SharedLibraryClassApi;
66 #define SHLIBPP_SHARED_CLASS_FN extern "C" SHLIBPP_EXPORT 84 #define SHLIBPP_DEFINE_SHARED_SUBCLASS(factoryname, classname, basename) \ 85 SHLIBPP_SHARED_CLASS_FN void* factoryname##_create() \ 87 classname* cn = new classname; \ 88 auto* bn = dynamic_cast<basename*>(cn); \ 91 return static_cast<void*>(bn); \ 93 SHLIBPP_SHARED_CLASS_FN void factoryname##_destroy(void* obj) \ 95 classname* cn = dynamic_cast<classname*>(static_cast<basename*>(obj)); \ 99 SHLIBPP_SHARED_CLASS_FN int factoryname##_getVersion(char* ver, int len) \ 103 SHLIBPP_SHARED_CLASS_FN int factoryname##_getAbi(char* abi, int len) \ 107 SHLIBPP_SHARED_CLASS_FN int factoryname##_getClassName(char* name, int len) \ 109 char cname[] = #classname; \ 110 strncpy(name, cname, len); \ 111 return strlen(cname) + 1; \ 113 SHLIBPP_SHARED_CLASS_FN int factoryname##_getBaseClassName(char* name, int len) \ 115 char cname[] = #basename; \ 116 strncpy(name, cname, len); \ 117 return strlen(cname) + 1; \ 119 SHLIBPP_SHARED_CLASS_FN int factoryname(void* api, int len) \ 121 struct shlibpp::SharedLibraryClassApi* sapi = (struct shlibpp::SharedLibraryClassApi*)api; \ 122 if (len < (int)sizeof(shlibpp::SharedLibraryClassApi)) \ 124 sapi->startCheck = shlibpp::VOCAB('S', 'H', 'P', 'P'); \ 125 sapi->structureSize = sizeof(shlibpp::SharedLibraryClassApi); \ 126 sapi->systemVersion = 5; \ 127 sapi->create = factoryname##_create; \ 128 sapi->destroy = factoryname##_destroy; \ 129 sapi->getVersion = factoryname##_getVersion; \ 130 sapi->getAbi = factoryname##_getAbi; \ 131 sapi->getClassName = factoryname##_getClassName; \ 132 sapi->getBaseClassName = factoryname##_getBaseClassName; \ 133 for (int i = 0; i < SHLIBPP_SHAREDLIBRARYCLASSAPI_PADDING; i++) { \ 134 sapi->roomToGrow[i] = 0; \ 136 sapi->endCheck = shlibpp::VOCAB('P', 'L', 'U', 'G'); \ 137 return sapi->startCheck; \ 150 #define SHLIBPP_DEFAULT_FACTORY_NAME "shlibpp_default_factory" 151 #define SHLIBPP_DEFINE_DEFAULT_SHARED_CLASS(classname) SHLIBPP_DEFINE_SHARED_SUBCLASS(shlibpp_default_factory, classname, classname) 152 #define SHLIBPP_DEFINE_SHARED_CLASS(factoryname, classname) SHLIBPP_DEFINE_SHARED_SUBCLASS(factoryname, classname, classname) 154 #endif // ROBOTTESTINGFRAMEWORK_SHAREDLIBRARYCLASSAPI_H Collection of hooks for creating/destroying a plugin.
int(* getVersion)(char *ver, int len)
#define SHLIBPP_SHAREDLIBRARYCLASSAPI_PADDING
int roomToGrow[SHLIBPP_SHAREDLIBRARYCLASSAPI_PADDING]
int(* getClassName)(char *name, int len)
int(* getAbi)(char *abi, int len)
int(* getBaseClassName)(char *name, int len)
void(* destroy)(void *obj)