source: Sophya/trunk/SophyaLib/SysTools/pdlmgr.h@ 3217

Last change on this file since 3217 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
RevLine 
[219]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
[241]8#include "machdefs.h"
[219]9#include <string>
10
11
12#if defined(HPUX)
13#include <dl.h>
[1796]14#elif defined(Darwin)
[2496]15#include <mach-o/dyld.h>
[230]16#else
17#include <dlfcn.h>
[219]18#endif
19
[895]20namespace SOPHYA {
21
[219]22typedef void (* DlFunction) (void);
23
[895]24//! Dynamic Link Manager.
[219]25class PDynLinkMgr {
26public:
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);
[2496]37 inline DlFunction GetFunction(const char * funcname)
38 { string fname = funcname; return GetFunction(fname); }
[219]39
[2496]40 inline string GetName() const { return soName; }
41
[219]42protected :
43 static string& GetTmpDir();
44 static int numSO;
45 static string* tmpDir;
46
47#if defined(HPUX)
48 shl_t dlhandle;
[2496]49#elif defined(Darwin)
50 NSObjectFileImage nsobjfile;
51 NSModule nsmod;
[480]52#else
[230]53 void * dlhandle;
[219]54#endif
[2496]55 bool dylok;
[219]56 string soName;
57 bool copy;
58};
59
[895]60} // namespace SOPHYA
61
[219]62#endif
Note: See TracBrowser for help on using the repository browser.