Bayeux  3.4.1
Core Foundation library for SuperNEMO
DynamicLoader.h
Go to the documentation of this file.
1 /*============================================================================
2  KWSys - Kitware System Library
3  Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4 
5  Distributed under the OSI-approved BSD License (the "License");
6  see accompanying file Copyright.txt for details.
7 
8  This software is distributed WITHOUT ANY WARRANTY; without even the
9  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  See the License for more information.
11  ============================================================================*/
12 #ifndef DATATOOLS_DYNAMICLOADER_HXX
13 #define DATATOOLS_DYNAMICLOADER_HXX
14 
16 
17 #if defined(__hpux)
18 #include <dl.h>
19 #elif defined(_WIN32) && !defined(__CYGWIN__)
20 #include <windows.h>
21 #elif defined(__APPLE__)
22 #include <AvailabilityMacros.h>
23 #if MAC_OS_X_VERSION_MAX_ALLOWED < 1030
24 #include <mach-o/dyld.h>
25 #endif
26 #elif defined(__BEOS__)
27 #include <be/kernel/image.h>
28 #endif
29 
30 namespace datatools
31 {
32  namespace detail
33  {
55  {
56  public:
57  // Ugly stuff for library handles
58  // They are different on several different OS's
59 #if defined(__hpux)
60  typedef shl_t LibraryHandle;
61 #elif defined(_WIN32) && !defined(__CYGWIN__)
62  typedef HMODULE LibraryHandle;
63 #elif defined(__APPLE__)
64 #if MAC_OS_X_VERSION_MAX_ALLOWED < 1030
65  typedef NSModule LibraryHandle;
66 #else
67  typedef void* LibraryHandle;
68 #endif
69 #elif defined(__BEOS__)
70  typedef image_id LibraryHandle;
71 #else // POSIX
72  typedef void* LibraryHandle;
73 #endif
74 
75  // Return type from DynamicLoader::GetSymbolAddress.
76  typedef void (*SymbolPointer)();
77 
81  static LibraryHandle OpenLibrary(const char*);
82 
85  static int CloseLibrary(LibraryHandle);
86 
88  static SymbolPointer GetSymbolAddress(LibraryHandle, const char*);
89 
91  static const char* LibPrefix() { return "lib"; }
92 
94  static const char* LibExtension() {
95 #if defined(__APPLE__)
96  // NB could also be ".bundle"
97  return ".dylib";
98 #else // default POSIX
99  return ".so";
100 #endif
101  }
102 
104  static const char* LastError();
105  }; // End Class: DynamicLoader
106 
107  } // namespace detail
108 
109 } // namespace datatools
110 
111 #endif // DATATOOLS_DYNAMICLOADER_HXX
112 
113 // Local Variables: --
114 // mode: c++ --
115 // c-file-style: "gnu" --
116 // tab-width: 2 --
117 // End: --
static const char * LibExtension()
Definition: DynamicLoader.h:94
void * LibraryHandle
Definition: DynamicLoader.h:72
#define datatools_EXPORT
Definition: Configure.h:108
Portable loading of dynamic libraries or dll's.
Definition: DynamicLoader.h:54
static const char * LibPrefix()
Definition: DynamicLoader.h:91
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13