Elements  6.2
A C++ base framework for the Euclid Software.
System.h
Go to the documentation of this file.
1 
31 #ifndef ELEMENTSKERNEL_ELEMENTSKERNEL_SYSTEM_H_
32 #define ELEMENTSKERNEL_ELEMENTSKERNEL_SYSTEM_H_
33 
34 // STL include files
35 #include <climits>
36 #include <memory>
37 #include <string>
38 #include <typeinfo>
39 #include <vector>
40 
41 // Framework include files
42 #include "ElementsKernel/Export.h" // ELEMENTS_API
43 #include "ElementsKernel/Unused.h" // ELEMENTS_UNUSED
44 
45 namespace Elements {
46 namespace System {
47 
48 // --------------------------------------------------------------------------------------
49 // various constants
50 // --------------------------------------------------------------------------------------
51 
55 #if defined(__APPLE__)
56 const std::string SHLIB_VAR_NAME{"DYLD_LIBRARY_PATH"};
57 #else
58 const std::string SHLIB_VAR_NAME{"LD_LIBRARY_PATH"};
59 #endif
60 
64 const std::string LIB_PREFIX{"lib"};
65 
69 #ifdef __APPLE__
70 const std::string LIB_EXTENSION{"dylib"};
71 #else
73 #endif
74 
80 
85 
91 
92 const int STACK_OFFSET{2};
93 
94 #if defined(__linux__) || defined(__APPLE__)
95 #define TEMPLATE_SPECIALIZATION
96 #endif
97 
98 #ifndef HOST_NAME_MAX
99 
100 #ifdef _POSIX_HOST_NAME_MAX
101 #define HOST_NAME_MAX _POSIX_HOST_NAME_MAX
102 #else
103 #define HOST_NAME_MAX 255
104 #endif
105 
106 #endif
107 
109 using ImageHandle = void*;
111 using ProcessHandle = void*;
113 using EntryPoint = unsigned long (*)(const unsigned long iid, void** ppvObject);
115 using Creator = void* (*)();
116 
118 ELEMENTS_API unsigned long loadDynamicLib(const std::string& name, ImageHandle* handle);
120 ELEMENTS_API unsigned long unloadDynamicLib(ImageHandle handle);
122 ELEMENTS_API unsigned long getProcedureByName(ImageHandle handle, const std::string& name, EntryPoint* pFunction);
124 ELEMENTS_API unsigned long getProcedureByName(ImageHandle handle, const std::string& name, Creator* pFunction);
126 ELEMENTS_API unsigned long getLastError();
130 ELEMENTS_API const std::string getErrorString(unsigned long error);
133 ELEMENTS_API const std::string typeinfoName(const char*);
146 ELEMENTS_API bool getEnv(const std::string& var, std::string& value);
154 ELEMENTS_API int setEnv(const std::string& name, const std::string& value, bool overwrite = true);
156 ELEMENTS_API int unSetEnv(const std::string& name);
158 ELEMENTS_API bool isEnvSet(const std::string& var);
159 
161 ELEMENTS_API const std::vector<std::string> backTrace(const int depth, const int offset = 0);
162 
163 ELEMENTS_API bool getStackLevel(ELEMENTS_UNUSED void* addresses, ELEMENTS_UNUSED void*& addr,
165 
166 } // namespace System
167 } // namespace Elements
168 
169 #endif // ELEMENTSKERNEL_ELEMENTSKERNEL_SYSTEM_H_
170 
Elements::System::getEnv
ELEMENTS_API std::string getEnv(const std::string &var)
get a particular environment variable
Definition: System.cpp:324
Elements::System::getErrorString
const ELEMENTS_API std::string getErrorString(unsigned long error)
Retrieve error code as string for a given error.
Definition: System.cpp:165
Elements::System::STACK_OFFSET
const int STACK_OFFSET
Definition: System.h:92
Export.h
defines the macros to be used for explicit export of the symbols
std::string
STL class.
Elements::System::machineType
const ELEMENTS_API std::string & machineType()
Machine type.
Definition: System.cpp:313
std::shared_ptr
STL class.
Elements::System::LIB_EXTENSION
const std::string LIB_EXTENSION
constant that represent the common extension of the libraries
Definition: System.h:72
Elements::System::typeinfoName
const ELEMENTS_API std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:186
std::vector< std::string >
std::type_info
Elements::System::getLastError
ELEMENTS_API unsigned long getLastError()
Get last system known error.
Definition: System.cpp:153
Elements::System::backTrace
ELEMENTS_API int backTrace(ELEMENTS_UNUSED std::shared_ptr< void * > addresses, ELEMENTS_UNUSED const int depth)
Elements::System::osVersion
const ELEMENTS_API std::string & osVersion()
OS version.
Definition: System.cpp:301
Elements::System::unSetEnv
ELEMENTS_API int unSetEnv(const std::string &name)
Simple wrap around unsetenv for strings.
Definition: System.cpp:379
Elements::System::Creator
void *(*)() Creator
Definition of the "generic" DLL entry point function.
Definition: System.h:115
ELEMENTS_API
#define ELEMENTS_API
Dummy definitions for the backward compatibility mode.
Definition: Export.h:74
Elements::System::LIB_PREFIX
const std::string LIB_PREFIX
constant that represent the common prefix of the libraries
Definition: System.h:64
Elements::System::hostName
const ELEMENTS_API std::string & hostName()
Host name.
Definition: System.cpp:278
Elements::System::isEnvSet
ELEMENTS_API bool isEnvSet(const std::string &var)
Check if an environment variable is set or not.
Definition: System.cpp:347
Elements::System::getLastErrorString
const ELEMENTS_API std::string getLastErrorString()
Get last system error as string.
Definition: System.cpp:159
Elements::System::LIB_SUFFIX
const std::string LIB_SUFFIX
constant that represents the standard suffix of the libraries: usually "."+LIB_EXTENSION
Definition: System.h:79
Elements::System::loadDynamicLib
ELEMENTS_API unsigned long loadDynamicLib(const std::string &name, ImageHandle *handle)
Load dynamic link library.
Definition: System.cpp:88
Elements::System::SHLIB_VAR_NAME
const std::string SHLIB_VAR_NAME
name of the shared dynamic library path
Definition: System.h:58
Elements::System::SHLIB_SUFFIX
const std::string SHLIB_SUFFIX
alias for LIB_SUFFIX
Definition: System.h:84
Elements::System::getStackLevel
ELEMENTS_API bool getStackLevel(ELEMENTS_UNUSED void *addresses, ELEMENTS_UNUSED void *&addr, ELEMENTS_UNUSED std::string &fnc, ELEMENTS_UNUSED std::string &lib)
Elements::System::getProcedureByName
ELEMENTS_API unsigned long getProcedureByName(ImageHandle handle, const std::string &name, EntryPoint *pFunction)
Get a specific function defined in the DLL.
Definition: System.cpp:124
Elements::System::ImageHandle
void * ImageHandle
Definition of an image handle.
Definition: System.h:109
Unused.h
Macro to silence unused variables warnings from the compiler.
Elements::System::unloadDynamicLib
ELEMENTS_API unsigned long unloadDynamicLib(ImageHandle handle)
unload dynamic link library
Definition: System.cpp:115
Elements::System::DEFAULT_INSTALL_PREFIX
const std::string DEFAULT_INSTALL_PREFIX
constant for the canonical installation prefix (on Linux and MacOSX at least)
Definition: System.h:90
ELEMENTS_UNUSED
#define ELEMENTS_UNUSED
Definition: Unused.h:39
Elements::System::setEnv
ELEMENTS_API int setEnv(const std::string &name, const std::string &value, bool overwrite=true)
set an environment variables.
Definition: System.cpp:369
Elements::System::EntryPoint
unsigned long(*)(const unsigned long iid, void **ppvObject) EntryPoint
Definition of the "generic" DLL entry point function.
Definition: System.h:113
Elements::System::osName
const ELEMENTS_API std::string & osName()
OS name.
Definition: System.cpp:289
Elements::System::ProcessHandle
void * ProcessHandle
Definition of the process handle.
Definition: System.h:111
Elements
Definition: callBackExample.h:35
Elements::System::InfoType::System
@ System