sipxportlib  Version 3.3
OsSharedLibMgr.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // $$
10 
11 
12 #ifndef _OsSharedLibMgrBase_h_
13 #define _OsSharedLibMgrBase_h_
14 
15 // SYSTEM INCLUDES
16 //#include <...>
17 
18 // APPLICATION INCLUDES
19 #include <os/OsStatus.h>
20 #include <os/OsBSem.h>
21 #include "utl/UtlHashBag.h"
22 
23 // DEFINES
24 // MACROS
25 // EXTERNAL FUNCTIONS
26 // EXTERNAL VARIABLES
27 // CONSTANTS
28 // STRUCTS
29 // TYPEDEFS
30 // FORWARD DECLARATIONS
31 
32 //: Singleton manager class to load shared libraries and access symbols in the libs
33 // Class detailed description which may extend to multiple lines
35 {
36 /* //////////////////////////// PUBLIC //////////////////////////////////// */
37 public:
38 
40 
41 /* ============================ CREATORS ================================== */
42 
43  virtual
45  //:Destructor
46 
47 /* ============================ MANIPULATORS ============================== */
48 
49  virtual OsStatus loadSharedLib(const char* libName) = 0;
50  //: Loads the given shared library
52 
53  virtual OsStatus getSharedLibSymbol(const char* libName,
54  const char* symbolName,
55  void*& symbolAddress) = 0;
56  //: Gets the address of a symbol in the shared lib
60 
61  virtual OsStatus unloadSharedLib(const char* libName) = 0;
62  //: Unloads the given shared library
63  // Before unloading library make sure that no one else use it!
65 
66 /* ============================ ACCESSORS ================================= */
67 
68 /* ============================ INQUIRY =================================== */
69 
70 /* //////////////////////////// PROTECTED ///////////////////////////////// */
71 protected:
73  //:Default constructor disallowed, use getOsSharedLibMgr
74 
75  // Static data members used to enforce Singleton behavior
76  static OsSharedLibMgrBase* spInstance; // pointer to the single instance of
77  // the OsProtectEventMgr class
78  static OsBSem sLock; // semaphore used to ensure that there
79  // is only one instance of this class
80 
82  // List of all the shared libraries and the os specific handle for each
83 
84 /* //////////////////////////// PRIVATE /////////////////////////////////// */
85 private:
86  OsSharedLibMgrBase(const OsSharedLibMgrBase& rOsSharedLibMgrBase);
87  //:Copy constructor
88 
89  OsSharedLibMgrBase& operator=(const OsSharedLibMgrBase& rhs);
90  //:Assignment operator
91 
92 };
93 
94 /* ============================ INLINE METHODS ============================ */
95 #if defined(_WIN32)
97  typedef class OsSharedLibMgrWnt OsSharedLibMgr;
98 #elif defined(_VXWORKS)
99 # include "os/Vxw/OsSharedLibMgrVxw.h"
100  typedef class OsSharedLibMgrVxw OsSharedLibMgr;
101 #elif defined(__pingtel_on_posix__)
103  typedef class OsSharedLibMgrLinux OsSharedLibMgr;
104 #else
105 # error Unsupported target platform.
106 #endif
107 
108 #endif // _OsSharedLibMgrBase_h_
109 
virtual OsStatus getSharedLibSymbol(const char *libName, const char *symbolName, void *&symbolAddress)=0
param: libName - name of library, may include absolute or relative path
static OsSharedLibMgrBase * getOsSharedLibMgr()
Definition: OsSharedLibMgr.cpp:29
OsStatus
Definition: OsStatus.h:27
OsSharedLibMgrBase()
param: libName - name of library, may include absolute or relative path
Definition: OsSharedLibMgr.cpp:47
Definition: OsSharedLibMgrLinux.h:31
virtual OsStatus unloadSharedLib(const char *libName)=0
param: (in) libName - name of library, may include absolute or relative path param: (in) symbolName -...
Definition: OsSharedLibMgr.h:34
virtual ~OsSharedLibMgrBase()
Definition: OsSharedLibMgr.cpp:57
Definition: UtlHashBag.h:41
static OsBSem sLock
Definition: OsSharedLibMgr.h:78
static OsSharedLibMgrBase * spInstance
Definition: OsSharedLibMgr.h:76
virtual OsStatus loadSharedLib(const char *libName)=0
Definition: OsSharedLibMgrWnt.h:32
UtlHashBag mLibraryHandles
Definition: OsSharedLibMgr.h:81