| # Gaudi Framework, version v21r11 |

Home |  | Generated: 30 Sep 2010

# DllMain.icpp

Go to the documentation of this file.

    00001 //====================================================================
    00002 //      DllMain.cpp
    00003 //--------------------------------------------------------------------
    00004 //
    00005 //      Package    : Gaudi/System
    00006 //
    00007 //  Description: The DLL initialisation must be done seperately for
    00008 //               each DLL.
    00009 //
    00010 //      Author     : M.Frank
    00011 //  Created    : 13/1/99
    00012 //      Changes    :
    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 // Avoid conflicts between Windows' headers and MSG.
    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,  // handle to DLL module
    00044         win::DWORD fdwReason,     // reason for calling function
    00045         win::LPVOID lpvReserved   // reserved
    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       // Since the System class is shared now, we may no longer close the
    00061       // Process handle!  M.F.
    00062       //win::CloseHandle(System::processHandle());
    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       //FIXME GaudiDll::initialize(0);
    00085 }
    00086 static void _fini()   {
    00087       //FIXME GaudiDll::finalize(0);
    00088 }
    00089
    00090 #endif // WIN32
    00091
    00092 #endif // SYSTEM_DLLMAIN_ICPP