| The Gaudi Framework v32r1 (f65d50dc)

DllMain.icpp
Go to the documentation of this file.
1 //====================================================================
2 // DllMain.cpp
3 //--------------------------------------------------------------------
4 //
5 // Package : Gaudi/System
6 //
7 // Description: The DLL initialisation must be done seperately for
8 // each DLL.
9 //
10 // Author : M.Frank
11 // Created : 13/1/99
12 // Changes :
13 //
14 //====================================================================
15 #ifndef SYSTEM_DLLMAIN_ICPP
16 #define SYSTEM_DLLMAIN_ICPP 1
17
18 #include "GaudiKernel/Kernel.h"
19 #include "GaudiKernel/System.h"
20
21 #if !defined( __APPLE__ )
22 class GaudiDll {
23 GaudiDll() {}
24
25 public:
26 static void initialize( void* hinstDLL );
27 static void finalize( void* hinstDLL );
28 };
29 #endif
30
31 #if defined( _WIN32 ) && defined( _DLL )
32 namespace win {
33 // Avoid conflicts between Windows' headers and MSG.
34 # ifndef NOMSG
35 # define NOMSG
36 # ifndef NOGDI
37 # define NOGDI
38 # endif
39 # endif
40 # include <windows.h>
41 } // namespace win
42
43 win::BOOL APIENTRY DllMain( win::HINSTANCE hinstDLL, // handle to DLL module
44 win::DWORD fdwReason, // reason for calling function
45 win::LPVOID lpvReserved // reserved
46 ) {
47 System::setModuleHandle( hinstDLL );
48 switch ( fdwReason ) {
49 case DLL_PROCESS_ATTACH: {
50 GaudiDll::initialize( hinstDLL );
51 } break;
52 case DLL_THREAD_ATTACH:
53 break;
54 case DLL_THREAD_DETACH:
55 break;
56 case DLL_PROCESS_DETACH: {
57 GaudiDll::finalize( hinstDLL );
58 // Since the System class is shared now, we may no longer close the
59 // Process handle! M.F.
60 // win::CloseHandle(System::processHandle());
61 } break;
62 }
63 return TRUE;
64 }
65 #elif __linux
66 static void _init() __attribute__( ( constructor ) );
67 static void _fini() __attribute__( ( destructor ) );
68
69 static void _init() { GaudiDll::initialize( 0 ); }
70 static void _fini() { GaudiDll::finalize( 0 ); }
71 #elif defined( __APPLE__ )
72 static void _init() __attribute__( ( constructor ) );
73 static void _fini() __attribute__( ( destructor ) );
74
75 static void _init() {
76 // FIXME GaudiDll::initialize(0);
77 }
78 static void _fini() {
79 // FIXME GaudiDll::finalize(0);
80 }
81
82 #endif // WIN32
83
84 #endif // SYSTEM_DLLMAIN_ICPP
System.h
Kernel.h
GaudiDll::initialize
static void initialize(void *hinstDLL)
Definition: LoadFactoryEntries.h:19
System::setModuleHandle
GAUDI_API void setModuleHandle(ImageHandle handle)
Attach module handle.
Definition: ModuleInfo.cpp:135
GaudiDll
Definition: DllMain.icpp:22
GaudiKernel.Constants.TRUE
bool TRUE
Definition: Constants.py:20
GaudiDll::finalize
static void finalize(void *hinstDLL)
Definition: LoadFactoryEntries.h:20
GaudiDll::GaudiDll
GaudiDll()
Definition: DllMain.icpp:23