| Last change
 on this file since 2750 was             2496, checked in by ansari, 22 years ago | 
        
          | 
Implementation propre de la gestion de chargement dynamique (classe PDynLinkMgr) sur MacOSX/Darwin a travers les API NSObjectFileImage et NSModule + petite correction ds zthread.h (deplacement de unlock()) - Reza 3 Fevrier 2004
 | 
        
          | File size:
            1.4 KB | 
      
      
| Line |  | 
|---|
| 1 | // This may look like C code, but it is really -*- C++ -*- | 
|---|
| 2 | // Gestionnaire de lien dynamique   -   R. Ansari 12/98 | 
|---|
| 3 | // LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA | 
|---|
| 4 |  | 
|---|
| 5 | #ifndef PDYNLINKMGR_SEEN | 
|---|
| 6 | #define PDYNLINKMGR_SEEN | 
|---|
| 7 |  | 
|---|
| 8 | #include "machdefs.h" | 
|---|
| 9 | #include <string> | 
|---|
| 10 |  | 
|---|
| 11 |  | 
|---|
| 12 | #if defined(HPUX) | 
|---|
| 13 | #include <dl.h> | 
|---|
| 14 | #elif defined(Darwin) | 
|---|
| 15 | #include <mach-o/dyld.h> | 
|---|
| 16 | #else | 
|---|
| 17 | #include <dlfcn.h> | 
|---|
| 18 | #endif | 
|---|
| 19 |  | 
|---|
| 20 | namespace SOPHYA { | 
|---|
| 21 |  | 
|---|
| 22 | typedef void (* DlFunction) (void); | 
|---|
| 23 |  | 
|---|
| 24 | //! Dynamic Link Manager. | 
|---|
| 25 | class PDynLinkMgr { | 
|---|
| 26 | public: | 
|---|
| 27 | // ---- Methodes globales (static) | 
|---|
| 28 | static PDynLinkMgr*   BuildFromCFile(string const & fname);  // Compil+link fichier C | 
|---|
| 29 | static void           SetTmpDir(string const & path);        // Repertoire des fichiers temporaires | 
|---|
| 30 |  | 
|---|
| 31 | // ---- Constructeur et methodes | 
|---|
| 32 | // Constructeur a partir d'un shared lib - copie en zone temporaire si cp==true | 
|---|
| 33 | PDynLinkMgr(string& soname, bool cp=true); | 
|---|
| 34 | virtual               ~PDynLinkMgr(); | 
|---|
| 35 |  | 
|---|
| 36 | virtual DlFunction    GetFunction(string const & funcname); | 
|---|
| 37 | inline  DlFunction    GetFunction(const char * funcname) | 
|---|
| 38 | { string fname = funcname;   return GetFunction(fname); } | 
|---|
| 39 |  | 
|---|
| 40 | inline  string        GetName() const { return soName; } | 
|---|
| 41 |  | 
|---|
| 42 | protected : | 
|---|
| 43 | static string&        GetTmpDir(); | 
|---|
| 44 | static int      numSO; | 
|---|
| 45 | static string*  tmpDir; | 
|---|
| 46 |  | 
|---|
| 47 | #if defined(HPUX) | 
|---|
| 48 | shl_t dlhandle; | 
|---|
| 49 | #elif defined(Darwin) | 
|---|
| 50 | NSObjectFileImage nsobjfile; | 
|---|
| 51 | NSModule nsmod; | 
|---|
| 52 | #else | 
|---|
| 53 | void * dlhandle; | 
|---|
| 54 | #endif | 
|---|
| 55 | bool dylok; | 
|---|
| 56 | string soName; | 
|---|
| 57 | bool copy; | 
|---|
| 58 | }; | 
|---|
| 59 |  | 
|---|
| 60 | } // namespace SOPHYA | 
|---|
| 61 |  | 
|---|
| 62 | #endif | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.