25#ifndef _OD_RXDYNAMICMODULE_H_
26#define _OD_RXDYNAMICMODULE_H_
44template<
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) \
106OdRxModule* ODRX_STATIC_MODULE_ENTRY_POINT(_UserModuleClass)(const OdString& szModuleName)
121#define ODRX_BEGIN_STATIC_MODULE_MAP() \
122STATIC_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) \
139ODRX_DEFINE_STATIC_APPLICATION(moduleName, ModuleClassName)
145#define ODRX_END_STATIC_MODULE_MAP() \
151#define ODRX_DECLARE_EXTERN_STATIC_MODULE_MAP extern STATIC_MODULE_DESC g_ODRX_STATIC_MODULE_MAP[];
155#define ODRX_INIT_STATIC_MODULE_MAP() odrxInitStaticModuleMap(g_ODRX_STATIC_MODULE_MAP)
157#define ODRX_DEFINE_STATIC_MODULE(_UserModuleClass)\
159 static OdRxModule* g_pSingletonModule##_UserModuleClass = 0;\
161ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(_UserModuleClass)\
163 return OdRxStaticModule<_UserModuleClass >::createModule(szModuleName);\
177template<
class T,
class TInterface = T>
180 ODRX_HEAP_OPERATORS();
197 if (m_nLockCount == 0){
201 long numRefs()
const {
return m_nLockCount; }
234#define ODRX_DEFINE_PSEUDO_STATIC_MODULE(_UserModuleClass)\
235 ODRX_DECLARE_STATIC_MODULE_ENTRY_POINT(_UserModuleClass)\
237 return OdRxPseudoStaticModule<_UserModuleClass >::createModule(szModuleName);\
240#if defined(_TOOLKIT_IN_DLL_)
243#if defined(__GNUC__) && defined(__APPLE__)
245#define ODRX_STATIC_MODULE_PATH "{5CEAD1EF-4D33-48fe-99E4-E09176BCF088}/"
247#define ODRX_STATIC_APP_MODULE_NAME(AppName) (OdString(ODRX_STATIC_MODULE_PATH) + AppName + DEFAULT_MODULE_EXTENSION_DOT_W)
249void deleteModuleObject();
259template<
class T,
class TInterface = T>
260class OdRxMacModule :
public T
280 long numRefs()
const {
return m_nLockCount; }
286 void* sysData() {
return m_hModule; }
295 static OdRxMacModule* createModule(
void *hModule,
const OdString name)
297 return new OdRxMacModule(hModule,
name);
305 deleteModuleObject();
321#define ODRX_DEFINE_DYNAMIC_MODULE(_UserModuleClass)\
322ODRX_ALLOC_OPERATORS()\
323 static OdRxModule* g_pSingletonModule = 0;\
325 __attribute__ ((visibility("default"))) \
326 OdRxModule* odrxCreateModuleObject(void *hModule, OdChar *name)\
328 if(!g_pSingletonModule)\
330 g_pSingletonModule = OdRxMacModule<_UserModuleClass >::createModule(hModule, name);\
333 return g_pSingletonModule;\
335 void odrxGetAPIVersion(int& nMajorVersion, int& nMinorVersion,\
336 int& nMajorBuildVersion, int& nMinorBuildVersion)\
338 nMajorVersion = TD_MAJOR_VERSION;\
339 nMinorVersion = TD_MINOR_VERSION;\
340 nMajorBuildVersion = TD_MAJOR_BUILD;\
341 nMinorBuildVersion = TD_MINOR_BUILD;\
344 void deleteModuleObject()\
346 g_pSingletonModule = NULL;\
349#elif defined(__GNUC__) && !defined(_WIN32)
351#define ODRX_STATIC_MODULE_PATH "{5CEAD1EF-4D33-48fe-99E4-E09176BCF088}/"
353#define ODRX_STATIC_APP_MODULE_NAME(AppName) (OdString(ODRX_STATIC_MODULE_PATH) + AppName + DEFAULT_MODULE_EXTENSION_DOT_W)
355void deleteModuleObject();
365template<
class T,
class TInterface = T>
366class OdRxUnixModule :
public T
387 long numRefs()
const {
return m_nLockCount; }
393 void* sysData() {
return m_hModule; }
402 static OdRxUnixModule* createModule(
void *hModule,
const OdString name)
404 return new OdRxUnixModule(hModule,
name);
412 deleteModuleObject();
429#define ODRX_DEFINE_DYNAMIC_MODULE(_UserModuleClass)\
430ODRX_ALLOC_OPERATORS()\
431 static OdRxModule* g_pSingletonModule = 0;\
433class OdRxUnixModule##_UserModuleClass : public OdRxUnixModule<_UserModuleClass>\
435 ODRX_HEAP_OPERATORS();\
436 OdRxUnixModule##_UserModuleClass(void *hModule, const OdString name)\
437 : OdRxUnixModule<_UserModuleClass>(hModule, name)\
441 static _UserModuleClass* createModule(void *hModule, const OdString name) \
443 return new OdRxUnixModule##_UserModuleClass(hModule, name);\
446 virtual void deleteModule()\
448 g_pSingletonModule = 0;\
454 __attribute__ ((visibility("default"))) \
455 OdRxModule* odrxCreateModuleObject(void *hModule, OdChar *name)\
457 if(!g_pSingletonModule)\
459 g_pSingletonModule = OdRxUnixModule##_UserModuleClass::createModule(hModule, name);\
462 return g_pSingletonModule;\
464 __attribute__ ((visibility("default"))) \
465 void odrxGetAPIVersion(int& nMajorVersion, int& nMinorVersion,\
466 int& nMajorBuildVersion, int& nMinorBuildVersion)\
468 nMajorVersion = TD_MAJOR_VERSION;\
469 nMinorVersion = TD_MINOR_VERSION;\
470 nMajorBuildVersion = TD_MAJOR_BUILD;\
471 nMinorBuildVersion = TD_MINOR_BUILD;\
474 void deleteModuleObject()\
476 g_pSingletonModule = NULL;\
481#define ODRX_STATIC_MODULE_PATH "{5CEAD1EF-4D33-48fe-99E4-E09176BCF088}/"
483#define ODRX_STATIC_APP_MODULE_NAME(AppName) (OdString(ODRX_STATIC_MODULE_PATH) + AppName + DEFAULT_MODULE_EXTENSION_DOT_W)
496template<
class T,
class TInterface = T>
497class OdRxWin32Module :
public T
502 OdRxWin32Module() : m_nLockCount(0) { }
512 long numRefs()
const {
return m_nLockCount; }
516 , m_sModuleName(
name)
523 void* sysData() {
return reinterpret_cast<void*
>(m_hModule); }
532 static OdRxWin32Module* createModule(HMODULE hModule,
const OdString name ) {
return new OdRxWin32Module(hModule,
name); }
539 g_pSingletonModule = 0;
548 return m_sModuleName;
555#define ODRX_DEFINE_DYNAMIC_MODULE(_UserModuleClass)\
556ODRX_ALLOC_OPERATORS()\
557static OdRxModule* g_pSingletonModule = 0;\
559__declspec(dllexport) OdRxModule* odrxCreateModuleObject(HMODULE& hModule, const OdChar *name)\
561 if(!g_pSingletonModule)\
563 g_pSingletonModule = OdRxWin32Module<_UserModuleClass >::createModule(hModule, name);\
566 return g_pSingletonModule;\
568__declspec(dllexport) void odrxGetAPIVersion(int& nMajorVersion, int& nMinorVersion,\
569 int& nMajorBuildVersion, int& nMinorBuildVersion)\
571 nMajorVersion = TD_MAJOR_VERSION;\
572 nMinorVersion = TD_MINOR_VERSION;\
573 nMajorBuildVersion = TD_MAJOR_BUILD;\
574 nMinorBuildVersion = TD_MINOR_BUILD;\
580void deleteModuleObject();
590template<
class T,
class TInterface = T>
591class OdRxWin32Module :
public T
595 OdRxWin32Module() : m_nLockCount(0) { }
605 long numRefs()
const {
return m_nLockCount; }
606 OdRxWin32Module(HMODULE hModule )
615 void* sysData() {
return reinterpret_cast<void*
>(m_hModule); }
624 static OdRxWin32Module* createModule(HMODULE hModule) {
return new OdRxWin32Module(hModule); }
631 deleteModuleObject();
640 wchar_t buffer[_MAX_PATH];
641 ::GetModuleFileNameW(m_hModule,
buffer, _MAX_PATH );
650#define ODRX_DEFINE_DYNAMIC_MODULE(_UserModuleClass)\
651ODRX_ALLOC_OPERATORS()\
652static OdRxModule* g_pSingletonModule = 0;\
654__declspec(dllexport) OdRxModule* odrxCreateModuleObject(HMODULE& hModule)\
656 if(!g_pSingletonModule)\
658 g_pSingletonModule = OdRxWin32Module<_UserModuleClass >::createModule(hModule);\
661 return g_pSingletonModule;\
663__declspec(dllexport) void odrxGetAPIVersion(int& nMajorVersion, int& nMinorVersion,\
664 int& nMajorBuildVersion, int& nMinorBuildVersion)\
666 nMajorVersion = TD_MAJOR_VERSION;\
667 nMinorVersion = TD_MINOR_VERSION;\
668 nMajorBuildVersion = TD_MAJOR_BUILD;\
669 nMinorBuildVersion = TD_MINOR_BUILD;\
672 void deleteModuleObject()\
674 g_pSingletonModule = NULL;\
683# define ODRX_GET_MODULE_OBJECT(_UserModuleClass) g_pSingletonModule
687#define ODRX_STATIC_MODULE_PATH ""
689#define ODRX_STATIC_APP_MODULE_NAME(AppName) AppName
691#define ODRX_DEFINE_DYNAMIC_MODULE(_UserModuleClass) ODRX_DEFINE_STATIC_MODULE(_UserModuleClass)
693# define ODRX_GET_MODULE_OBJECT(_UserModuleClass) g_pSingletonModule##_UserModuleClass
700#if defined(_TOOLKIT_IN_DLL_) && (defined(_MSC_VER) || (defined(_WIN32) && defined(__GNUC__)))
705#define DISABLE_THREAD_LIBRARY_CALLS()\
706extern "C" int APIENTRY DllMain(HINSTANCE h, DWORD reason, LPVOID ) {\
707 if(reason==DLL_PROCESS_ATTACH)\
708 DisableThreadLibraryCalls((HMODULE)h);\
714#define DISABLE_THREAD_LIBRARY_CALLS()
#define ODRX_HEAP_OPERATORS()
OdRxModule *(* StaticModuleEntryPoint)(const OdString &szModuleName)
FIRSTDLL_EXPORT void odrxInitStaticModuleMap(STATIC_MODULE_DESC *pMap)
static OdRxModule * createModule(const OdString &name)
OdString moduleName() const
static OdRxModule * createModule(const OdString &name)
OdString moduleName() const
GLuint const GLchar * name
StaticModuleEntryPoint entryPoint
const wchar_t * szAppName