DllMain.icpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef SYSTEM_DLLMAIN_ICPP
00016 #define SYSTEM_DLLMAIN_ICPP 1
00017
00018 #include "GaudiKernel/Kernel.h"
00019 #include "GaudiKernel/System.h"
00020
00021 #if !defined(__APPLE__)
00022 class GaudiDll {
00023 GaudiDll() {}
00024 public:
00025 static void initialize(void* hinstDLL);
00026 static void finalize(void* hinstDLL);
00027 };
00028 #endif
00029
00030 #if defined(_WIN32) && defined(_DLL)
00031 namespace win {
00032
00033 #ifndef NOMSG
00034 # define NOMSG
00035 # ifndef NOGDI
00036 # define NOGDI
00037 # endif
00038 #endif
00039 #include <windows.h>
00040 }
00041
00042 win::BOOL APIENTRY DllMain(
00043 win::HINSTANCE hinstDLL,
00044 win::DWORD fdwReason,
00045 win::LPVOID lpvReserved
00046 )
00047 {
00048 System::setModuleHandle(hinstDLL);
00049 switch( fdwReason ) {
00050 case DLL_PROCESS_ATTACH: {
00051 GaudiDll::initialize(hinstDLL);
00052 }
00053 break;
00054 case DLL_THREAD_ATTACH:
00055 break;
00056 case DLL_THREAD_DETACH:
00057 break;
00058 case DLL_PROCESS_DETACH: {
00059 GaudiDll::finalize(hinstDLL);
00060
00061
00062
00063 }
00064 break;
00065 }
00066 return TRUE;
00067
00068 }
00069 #elif linux
00070 static void _init() __attribute__((constructor));
00071 static void _fini() __attribute__((destructor));
00072
00073 static void _init() {
00074 GaudiDll::initialize(0);
00075 }
00076 static void _fini() {
00077 GaudiDll::finalize(0);
00078 }
00079 #elif defined(__APPLE__)
00080 static void _init() __attribute__((constructor));
00081 static void _fini() __attribute__((destructor));
00082
00083 static void _init() {
00084
00085 }
00086 static void _fini() {
00087
00088 }
00089
00090 #endif // WIN32
00091
00092 #endif // SYSTEM_DLLMAIN_ICPP