Last change
on this file since 4079 was 3605, checked in by ansari, 16 years ago |
Remplacement (MacOS X) des fonctions deprecated NSxxx de chargement dynamique par dlopen()... , Reza 29/04/2009
|
File size:
1.7 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 | /* Les fonction NSCreateObjectFile...() sont deprecated - Il faut utiliser les dlopen()...
|
---|
15 | qui sont plus efficaces a partir de 10.4 - On se cale donc sur les versions de GCC */
|
---|
16 | #elif defined(Darwin) && ( GCC_VERSION <= 3350 )
|
---|
17 | #include <mach-o/dyld.h>
|
---|
18 | #else
|
---|
19 | #include <dlfcn.h>
|
---|
20 | #endif
|
---|
21 |
|
---|
22 | namespace SOPHYA {
|
---|
23 |
|
---|
24 | typedef void (* DlFunction) (void);
|
---|
25 |
|
---|
26 | //! Dynamic Link Manager.
|
---|
27 | class PDynLinkMgr {
|
---|
28 | public:
|
---|
29 | // ---- Methodes globales (static)
|
---|
30 | static PDynLinkMgr* BuildFromCFile(string const & fname); // Compil+link fichier C
|
---|
31 | static void SetTmpDir(string const & path); // Repertoire des fichiers temporaires
|
---|
32 |
|
---|
33 | // ---- Constructeur et methodes
|
---|
34 | // Constructeur a partir d'un shared lib - copie en zone temporaire si cp==true
|
---|
35 | PDynLinkMgr(string& soname, bool cp=true);
|
---|
36 | virtual ~PDynLinkMgr();
|
---|
37 |
|
---|
38 | virtual DlFunction GetFunction(string const & funcname);
|
---|
39 | inline DlFunction GetFunction(const char * funcname)
|
---|
40 | { string fname = funcname; return GetFunction(fname); }
|
---|
41 |
|
---|
42 | inline string GetName() const { return soName; }
|
---|
43 |
|
---|
44 | protected :
|
---|
45 | static string& GetTmpDir();
|
---|
46 | static int numSO;
|
---|
47 | static string* tmpDir;
|
---|
48 |
|
---|
49 | #if defined(HPUX)
|
---|
50 | shl_t dlhandle;
|
---|
51 | #elif defined(Darwin) && ( GCC_VERSION <= 3350 )
|
---|
52 | NSObjectFileImage nsobjfile;
|
---|
53 | NSModule nsmod;
|
---|
54 | #else
|
---|
55 | void * dlhandle;
|
---|
56 | #endif
|
---|
57 | bool dylok;
|
---|
58 | string soName;
|
---|
59 | bool copy;
|
---|
60 | };
|
---|
61 |
|
---|
62 | } // namespace SOPHYA
|
---|
63 |
|
---|
64 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.