![]() |
|
|
Generated: 24 Nov 2008 |
00001 // $Header: /local/reps/Gaudi/GaudiKernel/GaudiKernel/System.h,v 1.17 2008/10/28 10:40:19 marcocle Exp $ 00002 #ifndef GAUDIKERNEL_SYSTEM_H 00003 #define GAUDIKERNEL_SYSTEM_H 00004 00005 // Framework include files 00006 #include "GaudiKernel/Kernel.h" 00007 // STL include files 00008 #include <string> 00009 #include <vector> 00010 #include <typeinfo> 00011 00012 #include "GaudiKernel/Timing.h" 00013 #include "GaudiKernel/ModuleInfo.h" 00014 00015 #ifdef __linux 00016 # include <pthread.h> 00017 #ifndef __APPLE__ 00018 # include <execinfo.h> 00019 #endif 00020 #endif 00021 00030 namespace System { 00032 typedef void* ImageHandle; 00034 typedef void* ProcessHandle; 00036 typedef unsigned long (*EntryPoint)(const unsigned long iid, void** ppvObject); 00038 typedef void* (*Creator)(); 00040 unsigned long loadDynamicLib(const std::string& name, ImageHandle* handle); 00042 unsigned long unloadDynamicLib(ImageHandle handle); 00044 unsigned long getProcedureByName(ImageHandle handle, const std::string& name, EntryPoint* pFunction); 00046 unsigned long getProcedureByName(ImageHandle handle, const std::string& name, Creator* pFunction); 00048 unsigned long getLastError(); 00050 const std::string getLastErrorString(); 00052 const std::string getErrorString(unsigned long error); 00054 const std::string typeinfoName( const std::type_info& ); 00055 const std::string typeinfoName( const char* ); 00057 const std::string& hostName(); 00059 const std::string& osName(); 00061 const std::string& osVersion(); 00063 const std::string& machineType(); 00065 const std::string& accountName(); 00067 long numCmdLineArgs(); 00069 long argc(); 00071 const std::vector<std::string> cmdLineArgs(); 00073 char** argv(); 00075 const std::string getEnv(const char* var); 00077 const std::vector<std::string> getEnv(); 00083 int setEnv(const std::string &name, const std::string &value, int overwrite = 1); 00084 #ifdef __linux 00086 typedef pthread_t ThreadHandle; 00088 inline ThreadHandle threadSelf() { return pthread_self(); } 00089 #else 00091 typedef void* ThreadHandle; 00093 inline ThreadHandle threadSelf() { return (void*)0; } 00094 #endif 00095 int backTrace(void** addresses, const int depth); 00096 bool backTrace(std::string& btrace, const int depth, const int offset = 0); 00097 bool getStackLevel(void* addresses, void*& addr, std::string& fnc, std::string& lib) ; 00098 00099 #if __GNUC__ >= 4 00112 template <typename DESTPTR, typename SRCPTR> 00113 inline DESTPTR FuncPtrCast(SRCPTR ptr) { 00114 union { 00115 SRCPTR src; 00116 DESTPTR dst; 00117 } p2p; 00118 p2p.src = ptr; 00119 return p2p.dst; 00120 } 00121 #endif 00122 } 00123 #endif // SYSTEM_SYSTEM_H