25 #ifndef _OD_RXDYNAMICMODULE_H_
26 #define _OD_RXDYNAMICMODULE_H_
44 template<
class T,
class TInterface = T>
47 ODRX_HEAP_OPERATORS();
65 long numRefs()
const {
return m_nLockCount; }
99 #define ODRX_STATIC_MODULE_ENTRY_POINT(_UserModuleClass) odrxCreateModuleObject_For_##_UserModuleClass
105 #define ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(_UserModuleClass) \
106 OdRxModule* ODRX_STATIC_MODULE_ENTRY_POINT(_UserModuleClass)(const OdString& szModuleName)
121 #define ODRX_BEGIN_STATIC_MODULE_MAP() \
122 STATIC_MODULE_DESC g_ODRX_STATIC_MODULE_MAP[] = {
133 #define ODRX_DEFINE_STATIC_APPLICATION(AppName, ModuleClassName) \
134 { AppName, ODRX_STATIC_MODULE_ENTRY_POINT(ModuleClassName) },
138 #define ODRX_DEFINE_STATIC_APPMODULE(moduleName, ModuleClassName) \
139 ODRX_DEFINE_STATIC_APPLICATION(moduleName, ModuleClassName)
145 #define ODRX_END_STATIC_MODULE_MAP() \
150 #define ODRX_INIT_STATIC_MODULE_MAP() odrxInitStaticModuleMap(g_ODRX_STATIC_MODULE_MAP)
152 #define ODRX_DEFINE_STATIC_MODULE(_UserModuleClass)\
154 static OdRxModule* g_pSingletonModule##_UserModuleClass = 0;\
156 ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(_UserModuleClass)\
158 return OdRxStaticModule<_UserModuleClass >::createModule(szModuleName);\
172 template<
class T,
class TInterface = T>
175 ODRX_HEAP_OPERATORS();
192 if (m_nLockCount == 0){
196 long numRefs()
const {
return m_nLockCount; }
229 #define ODRX_DEFINE_PSEUDO_STATIC_MODULE(_UserModuleClass)\
230 ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(_UserModuleClass)\
232 return OdRxPseudoStaticModule<_UserModuleClass >::createModule(szModuleName);\
235 #if defined(_TOOLKIT_IN_DLL_) && !defined(__MWERKS__)
238 #if defined(__GNUC__) && defined(__APPLE__) // GNU compiler MacOS X
240 #define ODRX_STATIC_MODULE_PATH "{5CEAD1EF-4D33-48fe-99E4-E09176BCF088}/"
242 #define ODRX_STATIC_APP_MODULE_NAME(AppName) (OdString(ODRX_STATIC_MODULE_PATH) + AppName + DEFAULT_MODULE_EXTENSION_DOT_W)
244 void deleteModuleObject();
254 template<
class T,
class TInterface = T>
255 class OdRxMacModule :
public T
275 long numRefs()
const {
return m_nLockCount; }
281 void* sysData() {
return m_hModule; }
290 static OdRxMacModule* createModule(
void *hModule,
const OdString name)
292 return new OdRxMacModule(hModule,
name);
300 deleteModuleObject();
316 #define ODRX_DEFINE_DYNAMIC_MODULE(_UserModuleClass)\
317 ODRX_ALLOC_OPERATORS()\
318 static OdRxModule* g_pSingletonModule = 0;\
320 __attribute__ ((visibility("default"))) \
321 OdRxModule* odrxCreateModuleObject(void *hModule, OdChar *name)\
323 if(!g_pSingletonModule)\
325 g_pSingletonModule = OdRxMacModule<_UserModuleClass >::createModule(hModule, name);\
328 return g_pSingletonModule;\
330 void odrxGetAPIVersion(int& nMajorVersion, int& nMinorVersion,\
331 int& nMajorBuildVersion, int& nMinorBuildVersion)\
333 nMajorVersion = TD_MAJOR_VERSION;\
334 nMinorVersion = TD_MINOR_VERSION;\
335 nMajorBuildVersion = TD_MAJOR_BUILD;\
336 nMinorBuildVersion = TD_MINOR_BUILD;\
339 void deleteModuleObject()\
341 g_pSingletonModule = NULL;\
344 #elif defined(__GNUC__) && !defined(_WIN32)
346 #define ODRX_STATIC_MODULE_PATH "{5CEAD1EF-4D33-48fe-99E4-E09176BCF088}/"
348 #define ODRX_STATIC_APP_MODULE_NAME(AppName) (OdString(ODRX_STATIC_MODULE_PATH) + AppName + DEFAULT_MODULE_EXTENSION_DOT_W)
350 void deleteModuleObject();
360 template<
class T,
class TInterface = T>
361 class OdRxUnixModule :
public T
382 long numRefs()
const {
return m_nLockCount; }
388 void* sysData() {
return m_hModule; }
397 static OdRxUnixModule* createModule(
void *hModule,
const OdString name)
399 return new OdRxUnixModule(hModule,
name);
407 deleteModuleObject();
424 #define ODRX_DEFINE_DYNAMIC_MODULE(_UserModuleClass)\
425 ODRX_ALLOC_OPERATORS()\
426 static OdRxModule* g_pSingletonModule = 0;\
428 class OdRxUnixModule##_UserModuleClass : public OdRxUnixModule<_UserModuleClass>\
430 ODRX_HEAP_OPERATORS();\
431 OdRxUnixModule##_UserModuleClass(void *hModule, const OdString name)\
432 : OdRxUnixModule<_UserModuleClass>(hModule, name)\
436 static _UserModuleClass* createModule(void *hModule, const OdString name) \
438 return new OdRxUnixModule##_UserModuleClass(hModule, name);\
441 virtual void deleteModule()\
443 g_pSingletonModule = 0;\
449 __attribute__ ((visibility("default"))) \
450 OdRxModule* odrxCreateModuleObject(void *hModule, OdChar *name)\
452 if(!g_pSingletonModule)\
454 g_pSingletonModule = OdRxUnixModule##_UserModuleClass::createModule(hModule, name);\
457 return g_pSingletonModule;\
459 __attribute__ ((visibility("default"))) \
460 void odrxGetAPIVersion(int& nMajorVersion, int& nMinorVersion,\
461 int& nMajorBuildVersion, int& nMinorBuildVersion)\
463 nMajorVersion = TD_MAJOR_VERSION;\
464 nMinorVersion = TD_MINOR_VERSION;\
465 nMajorBuildVersion = TD_MAJOR_BUILD;\
466 nMinorBuildVersion = TD_MINOR_BUILD;\
469 void deleteModuleObject()\
471 g_pSingletonModule = NULL;\
474 #else //defined(__GNUC__)
476 #define ODRX_STATIC_MODULE_PATH "{5CEAD1EF-4D33-48fe-99E4-E09176BCF088}/"
478 #define ODRX_STATIC_APP_MODULE_NAME(AppName) (OdString(ODRX_STATIC_MODULE_PATH) + AppName + DEFAULT_MODULE_EXTENSION_DOT_W)
491 template<
class T,
class TInterface = T>
492 class OdRxWin32Module :
public T
497 OdRxWin32Module() : m_nLockCount(0) { }
507 long numRefs()
const {
return m_nLockCount; }
511 , m_sModuleName(
name)
518 void* sysData() {
return reinterpret_cast<void*
>(m_hModule); }
527 static OdRxWin32Module* createModule(HMODULE hModule,
const OdString name ) {
return new OdRxWin32Module(hModule,
name); }
534 g_pSingletonModule = 0;
543 return m_sModuleName;
550 #define ODRX_DEFINE_DYNAMIC_MODULE(_UserModuleClass)\
551 ODRX_ALLOC_OPERATORS()\
552 static OdRxModule* g_pSingletonModule = 0;\
554 __declspec(dllexport) OdRxModule* odrxCreateModuleObject(HMODULE& hModule, const OdChar *name)\
556 if(!g_pSingletonModule)\
558 g_pSingletonModule = OdRxWin32Module<_UserModuleClass >::createModule(hModule, name);\
561 return g_pSingletonModule;\
563 __declspec(dllexport) void odrxGetAPIVersion(int& nMajorVersion, int& nMinorVersion,\
564 int& nMajorBuildVersion, int& nMinorBuildVersion)\
566 nMajorVersion = TD_MAJOR_VERSION;\
567 nMinorVersion = TD_MINOR_VERSION;\
568 nMajorBuildVersion = TD_MAJOR_BUILD;\
569 nMinorBuildVersion = TD_MINOR_BUILD;\
575 void deleteModuleObject();
585 template<
class T,
class TInterface = T>
586 class OdRxWin32Module :
public T
590 OdRxWin32Module() : m_nLockCount(0) { }
600 long numRefs()
const {
return m_nLockCount; }
601 OdRxWin32Module(HMODULE hModule )
610 void* sysData() {
return reinterpret_cast<void*
>(m_hModule); }
619 static OdRxWin32Module* createModule(HMODULE hModule) {
return new OdRxWin32Module(hModule); }
626 deleteModuleObject();
635 wchar_t buffer[_MAX_PATH];
636 ::GetModuleFileNameW(m_hModule,
buffer, _MAX_PATH );
645 #define ODRX_DEFINE_DYNAMIC_MODULE(_UserModuleClass)\
646 ODRX_ALLOC_OPERATORS()\
647 static OdRxModule* g_pSingletonModule = 0;\
649 __declspec(dllexport) OdRxModule* odrxCreateModuleObject(HMODULE& hModule)\
651 if(!g_pSingletonModule)\
653 g_pSingletonModule = OdRxWin32Module<_UserModuleClass >::createModule(hModule);\
656 return g_pSingletonModule;\
658 __declspec(dllexport) void odrxGetAPIVersion(int& nMajorVersion, int& nMinorVersion,\
659 int& nMajorBuildVersion, int& nMinorBuildVersion)\
661 nMajorVersion = TD_MAJOR_VERSION;\
662 nMinorVersion = TD_MINOR_VERSION;\
663 nMajorBuildVersion = TD_MAJOR_BUILD;\
664 nMinorBuildVersion = TD_MINOR_BUILD;\
667 void deleteModuleObject()\
669 g_pSingletonModule = NULL;\
672 #endif //__BORLANDC__
676 #endif //defined(__GNUC__) && defined(__APPLE__)
678 # define ODRX_GET_MODULE_OBJECT(_UserModuleClass) g_pSingletonModule
680 #else //#ifdef _TOOLKIT_IN_DLL_
682 #define ODRX_STATIC_MODULE_PATH ""
684 #define ODRX_STATIC_APP_MODULE_NAME(AppName) AppName
686 #define ODRX_DEFINE_DYNAMIC_MODULE(_UserModuleClass) ODRX_DEFINE_STATIC_MODULE(_UserModuleClass)
688 # define ODRX_GET_MODULE_OBJECT(_UserModuleClass) g_pSingletonModule##_UserModuleClass
691 #endif //#ifdef _TOOLKIT_IN_DLL_
695 #if defined(_TOOLKIT_IN_DLL_) && (defined(_MSC_VER) || (defined(_WIN32) && defined(__GNUC__)))
700 #define DISABLE_THREAD_LIBRARY_CALLS()\
701 extern "C" int APIENTRY DllMain(HINSTANCE h, DWORD reason, LPVOID ) {\
702 if(reason==DLL_PROCESS_ATTACH)\
703 DisableThreadLibraryCalls((HMODULE)h);\
709 #define DISABLE_THREAD_LIBRARY_CALLS()
711 #endif //#if defined(_TOOLKIT_IN_DLL_) && defined(_MSC_VER)
716 #endif // _OD_RXDYNAMICMODULE_H_