Elements 6.1.2
A C++ base framework for the Euclid Software.
Loading...
Searching...
No Matches
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
45namespace Elements {
46namespace System {
47
48// --------------------------------------------------------------------------------------
49// various constants
50// --------------------------------------------------------------------------------------
51
55#if defined(__APPLE__)
56const std::string SHLIB_VAR_NAME{"DYLD_LIBRARY_PATH"};
57#else
58const std::string SHLIB_VAR_NAME{"LD_LIBRARY_PATH"};
59#endif
60
65
69#ifdef __APPLE__
70const std::string LIB_EXTENSION{"dylib"};
71#else
73#endif
74
80
85
91
92const 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
109using ImageHandle = void*;
111using ProcessHandle = void*;
113using EntryPoint = unsigned long (*)(const unsigned long iid, void** ppvObject);
115using Creator = void* (*)();
116
118ELEMENTS_API unsigned long loadDynamicLib(const std::string& name, ImageHandle* handle);
120ELEMENTS_API unsigned long unloadDynamicLib(ImageHandle handle);
122ELEMENTS_API unsigned long getProcedureByName(ImageHandle handle, const std::string& name, EntryPoint* pFunction);
124ELEMENTS_API unsigned long getProcedureByName(ImageHandle handle, const std::string& name, Creator* pFunction);
126ELEMENTS_API unsigned long getLastError();
130ELEMENTS_API const std::string getErrorString(unsigned long error);
133ELEMENTS_API const std::string typeinfoName(const char*);
146ELEMENTS_API bool getEnv(const std::string& var, std::string& value);
154ELEMENTS_API int setEnv(const std::string& name, const std::string& value, bool overwrite = true);
156ELEMENTS_API int unSetEnv(const std::string& name);
158ELEMENTS_API bool isEnvSet(const std::string& var);
159
161ELEMENTS_API const std::vector<std::string> backTrace(const int depth, const int offset = 0);
162
165
166} // namespace System
167} // namespace Elements
168
169#endif // ELEMENTSKERNEL_ELEMENTSKERNEL_SYSTEM_H_
170
defines the macros to be used for explicit export of the symbols
Macro to silence unused variables warnings from the compiler.
#define ELEMENTS_API
Dummy definitions for the backward compatibility mode.
Definition: Export.h:74
#define ELEMENTS_UNUSED
Definition: Unused.h:39
ELEMENTS_API bool isEnvSet(const std::string &var)
Check if an environment variable is set or not.
Definition: System.cpp:347
const std::string SHLIB_SUFFIX
alias for LIB_SUFFIX
Definition: System.h:84
unsigned long(*)(const unsigned long iid, void **ppvObject) EntryPoint
Definition of the "generic" DLL entry point function.
Definition: System.h:113
const std::string DEFAULT_INSTALL_PREFIX
constant for the canonical installation prefix (on Linux and MacOSX at least)
Definition: System.h:90
const std::string LIB_SUFFIX
constant that represents the standard suffix of the libraries: usually "."+LIB_EXTENSION
Definition: System.h:79
ELEMENTS_API const std::string getErrorString(unsigned long error)
Retrieve error code as string for a given error.
Definition: System.cpp:165
void * ImageHandle
Definition of an image handle.
Definition: System.h:109
ELEMENTS_API int setEnv(const std::string &name, const std::string &value, bool overwrite=true)
set an environment variables.
Definition: System.cpp:369
ELEMENTS_API bool getStackLevel(ELEMENTS_UNUSED void *addresses, ELEMENTS_UNUSED void *&addr, ELEMENTS_UNUSED std::string &fnc, ELEMENTS_UNUSED std::string &lib)
ELEMENTS_API unsigned long unloadDynamicLib(ImageHandle handle)
unload dynamic link library
Definition: System.cpp:115
ELEMENTS_API int backTrace(ELEMENTS_UNUSED std::shared_ptr< void * > addresses, ELEMENTS_UNUSED const int depth)
ELEMENTS_API std::vector< std::string > getEnv()
get all environment variables
Definition: System.cpp:357
const std::string SHLIB_VAR_NAME
name of the shared dynamic library path
Definition: System.h:58
ELEMENTS_API unsigned long getLastError()
Get last system known error.
Definition: System.cpp:153
ELEMENTS_API const std::string & osName()
OS name.
Definition: System.cpp:289
ELEMENTS_API unsigned long loadDynamicLib(const std::string &name, ImageHandle *handle)
Load dynamic link library.
Definition: System.cpp:88
ELEMENTS_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:186
ELEMENTS_API int unSetEnv(const std::string &name)
Simple wrap around unsetenv for strings.
Definition: System.cpp:379
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_API const std::string & osVersion()
OS version.
Definition: System.cpp:301
ELEMENTS_API const std::string getLastErrorString()
Get last system error as string.
Definition: System.cpp:159
ELEMENTS_API const std::string & machineType()
Machine type.
Definition: System.cpp:313
void *(*)() Creator
Definition of the "generic" DLL entry point function.
Definition: System.h:115
const std::string LIB_PREFIX
constant that represent the common prefix of the libraries
Definition: System.h:64
void * ProcessHandle
Definition of the process handle.
Definition: System.h:111
const std::string LIB_EXTENSION
constant that represent the common extension of the libraries
Definition: System.h:72
ELEMENTS_API const std::string & hostName()
Host name.
Definition: System.cpp:278
const int STACK_OFFSET
Definition: System.h:92