Go to the documentation of this file.00001 #ifndef maciLibraryManager_h
00002 #define maciLibraryManager_h
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef __cplusplus
00015 #error This is a C++ include file and cannot be used from plain C
00016 #endif
00017
00018 #include <acsutil.h>
00019
00020 #include <tao/corba.h>
00021 #include <tao/PortableServer/PortableServer.h>
00022
00023 #include <maciRegistrar.h>
00024
00025 #include <acsutilThreadInit.h>
00026 #include <ace/SString.h>
00027 #include <ace/Synch.h>
00028
00029 #include <logging.h>
00030
00031 namespace maci {
00032
00036 class LibraryManager
00037 {
00038
00039 public:
00040
00050 typedef bool (*DLLOpenFunc)(int argc, char *argv[]);
00051
00052
00059 typedef void (*DLLCloseFunc)(void);
00060
00061
00071 typedef void (*DLLSetupCORBAFunc)(CORBA::ORB_ptr m_orb,
00072 PortableServer::POAManager_ptr m_poaManager,
00073 PortableServer::POA_ptr m_poaRoot,
00074 PortableServer::POA_ptr m_poaPersistent,
00075 PortableServer::POA_ptr m_poaTransient);
00076
00086 typedef void (*DLLInitThreadsFunc)(InitThreadFunc initFunc, DoneThreadFunc doneFunc);
00087
00091 LibraryManager();
00092
00096 ~LibraryManager();
00097
00102 void setSearchPath(const char * path);
00103
00108 const char * getSearchPath() { return m_path; }
00109
00114 void closeAllLibraries(bool inform = true);
00115
00121 char * locateLibrary(const char * name);
00122
00123
00129 void lock(int h);
00130
00136 void unlock(int h);
00137
00144 int load(const char * path, int argc = 0, char *argv[] = 0);
00145
00149 void unload(int h);
00150
00154 void unload(const char* name);
00155
00161 void * getSymbol(int h, const char * symbol);
00162
00171 bool setupCORBAinDLL(int handle,
00172 CORBA::ORB_ptr m_orb,
00173 PortableServer::POAManager_ptr m_poaManager,
00174 PortableServer::POA_ptr m_poaRoot,
00175 PortableServer::POA_ptr m_poaPersistent,
00176 PortableServer::POA_ptr m_poaTransient);
00177
00185 bool initThreadsInDLL(int handle, InitThreadFunc initFunc, DoneThreadFunc doneFunc);
00186
00187 private:
00188
00190 struct LibraryInfo
00191 {
00193 ACE_SHLIB_HANDLE hLib;
00195 int nRefCount;
00197 ACE_CString path;
00198 };
00199
00201 Registrar<int, LibraryInfo> m_libraries;
00202
00204 char * m_path;
00205
00212 int ldfind(const ACE_TCHAR filename[],
00213 ACE_TCHAR pathname[],
00214 size_t maxpathnamelen);
00215
00217 ACE_Recursive_Thread_Mutex mutex;
00218
00223 Logging::Logger::LoggerSmartPtr
00224 getLogger() {return logger_m;}
00225
00227 Logging::Logger::LoggerSmartPtr logger_m;
00228
00229 };
00230
00231 };
00232
00233 #endif // maciLibraryManager_h
00234