Elements
5.8
A C++ base framework for the Euclid Software.
|
Classes | |
class | ModuleInfo |
Typedefs | |
using | ImageHandle = void * |
Definition of an image handle. More... | |
using | ProcessHandle = void * |
Definition of the process handle. More... | |
using | EntryPoint = unsigned long(*)(const unsigned long iid, void **ppvObject) |
Definition of the "generic" DLL entry point function. More... | |
using | Creator ) = void *(*)( |
Definition of the "generic" DLL entry point function. More... | |
Enumerations | |
enum | ModuleType { ModuleType::UNKNOWN, ModuleType::SHAREDLIB, ModuleType::EXECUTABLE } |
enum | InfoType { InfoType::NoFetch, InfoType::RemainTime, InfoType::Times, InfoType::ProcessBasics, InfoType::PriorityBoost, InfoType::Memory, InfoType::Quota, InfoType::System, InfoType::Modules, InfoType::IO } |
Enumeration for fetching information. More... | |
Functions | |
template<typename DESTPTR , typename SRCPTR > | |
DESTPTR | FuncPtrCast (SRCPTR ptr) |
Cast from void * to function pointer. More... | |
ELEMENTS_API const std::string & | moduleName () |
Get the name of the (executable/DLL) file without file-type. More... | |
ELEMENTS_API const std::string & | moduleNameFull () |
Get the full name of the (executable/DLL) file. More... | |
ELEMENTS_API ModuleType | moduleType () |
Get type of the module. More... | |
ELEMENTS_API ProcessHandle | processHandle () |
Handle to running process. More... | |
ELEMENTS_API ImageHandle | moduleHandle () |
Handle to currently executed module. More... | |
ELEMENTS_API ImageHandle | exeHandle () |
Handle to the executable file running. More... | |
ELEMENTS_API const std::string & | exeName () |
Name of the executable file running. More... | |
ELEMENTS_API const std::vector < std::string > | linkedModules () |
Vector of names of linked modules. More... | |
ELEMENTS_API std::vector < boost::filesystem::path > | linkedModulePaths () |
ELEMENTS_API void | setModuleHandle (ImageHandle handle) |
Attach module handle. More... | |
ELEMENTS_API boost::filesystem::path | getExecutablePath () |
Get the full executable path. More... | |
ELEMENTS_API unsigned long | loadDynamicLib (const std::string &name, ImageHandle *handle) |
Load dynamic link library. More... | |
ELEMENTS_API unsigned long | unloadDynamicLib (ImageHandle handle) |
unload dynamic link library More... | |
ELEMENTS_API unsigned long | getProcedureByName (ImageHandle handle, const std::string &name, EntryPoint *pFunction) |
Get a specific function defined in the DLL. More... | |
ELEMENTS_API unsigned long | getProcedureByName (ImageHandle handle, const std::string &name, Creator *pFunction) |
Get a specific function defined in the DLL. More... | |
ELEMENTS_API unsigned long | getLastError () |
Get last system known error. More... | |
ELEMENTS_API const std::string | getLastErrorString () |
Get last system error as string. More... | |
ELEMENTS_API const std::string | getErrorString (unsigned long error) |
Retrieve error code as string for a given error. More... | |
ELEMENTS_API const std::string | typeinfoName (const std::type_info &) |
Get platform independent information about the class type. More... | |
ELEMENTS_API const std::string | typeinfoName (const char *) |
ELEMENTS_API const std::string & | hostName () |
Host name. More... | |
ELEMENTS_API const std::string & | osName () |
OS name. More... | |
ELEMENTS_API const std::string & | osVersion () |
OS version. More... | |
ELEMENTS_API const std::string & | machineType () |
Machine type. More... | |
ELEMENTS_API std::string | getEnv (const std::string &var) |
get a particular environment variable More... | |
ELEMENTS_API bool | getEnv (const string &var, string &value) |
get a particular env var, storing the value in the passed string (if set) More... | |
ELEMENTS_API std::vector < std::string > | getEnv () |
get all environment variables More... | |
ELEMENTS_API int | setEnv (const string &name, const string &value, bool overwrite) |
set an environment variables. More... | |
ELEMENTS_API int | unSetEnv (const std::string &name) |
Simple wrap around unsetenv for strings. More... | |
ELEMENTS_API bool | isEnvSet (const std::string &var) |
Check if an environment variable is set or not. More... | |
ELEMENTS_API int | backTrace (ELEMENTS_UNUSED std::shared_ptr< void * > addresses, ELEMENTS_UNUSED const int depth) |
ELEMENTS_API bool | backTrace (std::string &btrace, const int depth, const int offset=0) |
ELEMENTS_API const std::vector < std::string > | backTrace (const int depth, const int offset=0) |
ELEMENTS_API bool | getStackLevel (ELEMENTS_UNUSED void *addresses, ELEMENTS_UNUSED void *&addr, ELEMENTS_UNUSED std::string &fnc, ELEMENTS_UNUSED std::string &lib) |
static const ModuleInfo & | getThisModuleInfo () |
ELEMENTS_API const ModuleInfo & | getThisExecutableInfo () |
path | getSelfProc () |
bool | getStackLevel (void *addresses ELEMENTS_UNUSED, void *&addr ELEMENTS_UNUSED, string &fnc ELEMENTS_UNUSED, string &lib ELEMENTS_UNUSED) |
Variables | |
const std::string | SHLIB_VAR_NAME { "LD_LIBRARY_PATH" } |
name of the shared dynamic library path More... | |
const std::string | LIB_PREFIX { "lib" } |
constant that represent the common prefix of the libraries More... | |
const std::string | LIB_EXTENSION { "so" } |
constant that represent the common extension of the libraries More... | |
const std::string | LIB_SUFFIX { "." + LIB_EXTENSION } |
constant that represents the standard suffix of the libraries: usually "."+LIB_EXTENSION More... | |
const std::string | SHLIB_SUFFIX { LIB_SUFFIX } |
alias for LIB_SUFFIX More... | |
const std::string | DEFAULT_INSTALL_PREFIX { "/usr" } |
constant for the canonical installation prefix (on Linux and MacOSX at least) More... | |
const int | STACK_OFFSET {2} |
using Elements::System::Creator = typedef void* (*)( |
using Elements::System::EntryPoint = typedef unsigned long (*)(const unsigned long iid, void** ppvObject) |
using Elements::System::ImageHandle = typedef void* |
using Elements::System::ProcessHandle = typedef void* |
|
strong |
Enumeration for fetching information.
Enumerator | |
---|---|
NoFetch | |
RemainTime | |
Times | |
ProcessBasics | |
PriorityBoost | |
Memory | |
Quota | |
System | |
Modules | |
IO |
Definition at line 28 of file SystemBase.h.
|
strong |
Enumerator | |
---|---|
UNKNOWN | |
SHAREDLIB | |
EXECUTABLE |
Definition at line 58 of file ModuleInfo.h.
int Elements::System::backTrace | ( | ELEMENTS_UNUSED std::shared_ptr< void * > | addresses, |
ELEMENTS_UNUSED const int | depth | ||
) |
Definition at line 396 of file System.cpp.
Referenced by backTrace(), and Elements::ProgramManager::onTerminate().
bool Elements::System::backTrace | ( | std::string & | btrace, |
const int | depth, | ||
const int | offset = 0 |
||
) |
Definition at line 408 of file System.cpp.
References backTrace(), std::dec(), std::endl(), getStackLevel(), std::hex(), std::setiosflags(), std::setw(), STACK_OFFSET, and std::ostringstream::str().
Definition at line 437 of file System.cpp.
References backTrace(), std::dec(), getStackLevel(), std::hex(), std::string::push_back(), std::setiosflags(), std::setw(), STACK_OFFSET, and std::ostringstream::str().
ImageHandle Elements::System::exeHandle | ( | ) |
Handle to the executable file running.
Definition at line 166 of file ModuleInfo.cpp.
const string & Elements::System::exeName | ( | ) |
Name of the executable file running.
Definition at line 186 of file ModuleInfo.cpp.
References getExecutablePath(), and std::string::length().
|
inline |
Cast from void * to function pointer.
Small helper function that allows the cast from void * to function pointer and vice versa without the message
* warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object *
It is an ugly trick but works. See:
ptr | pointer address to convert |
SRCPTR | source pointer type |
DESTPTR | destination pointer type |
Definition at line 55 of file FuncPtrCast.h.
string Elements::System::getEnv | ( | const std::string & | var | ) |
get a particular environment variable
Definition at line 331 of file System.cpp.
Referenced by ElementsServices::DataSync::environmentVariable(), Elements::Environment::get(), Elements::Path::getLocationsFromEnv(), isEnvSet(), loadDynamicLib(), Elements::pathSearchInEnvVariable(), Elements::Environment::set(), and Elements::Environment::unSet().
bool Elements::System::getEnv | ( | const std::string & | var, |
std::string & | value | ||
) |
get a particular env var, storing the value in the passed string (if set)
get a particular environment variable, storing the value in the passed string if the variable is set. Returns true if the variable is set, false otherwise.
Definition at line 341 of file System.cpp.
References std::string::c_str().
get all environment variables
get all defined environment vars
Definition at line 365 of file System.cpp.
References std::vector< T >::push_back().
const string Elements::System::getErrorString | ( | unsigned long | error | ) |
Retrieve error code as string for a given error.
Definition at line 169 of file System.cpp.
References std::strerror().
Referenced by getLastErrorString().
path Elements::System::getExecutablePath | ( | ) |
Get the full executable path.
Definition at line 248 of file ModuleInfo.cpp.
References getSelfProc().
Referenced by exeName(), Elements::ProgramManager::setProgramName(), and Elements::ProgramManager::setProgramPath().
unsigned long Elements::System::getLastError | ( | ) |
Get last system known error.
Retrieve last error code.
Definition at line 157 of file System.cpp.
Referenced by getLastErrorString(), and unloadDynamicLib().
const string Elements::System::getLastErrorString | ( | ) |
Get last system error as string.
Retrieve last error code as string.
Definition at line 163 of file System.cpp.
References getErrorString(), and getLastError().
Referenced by getProcedureByName().
unsigned long Elements::System::getProcedureByName | ( | ImageHandle | handle, |
const std::string & | name, | ||
EntryPoint * | pFunction | ||
) |
Get a specific function defined in the DLL.
Definition at line 125 of file System.cpp.
References std::string::c_str(), std::endl(), and getLastErrorString().
Referenced by getProcedureByName().
unsigned long Elements::System::getProcedureByName | ( | ImageHandle | handle, |
const std::string & | name, | ||
Creator * | pFunction | ||
) |
Get a specific function defined in the DLL.
Definition at line 151 of file System.cpp.
References getProcedureByName().
path Elements::System::getSelfProc | ( | ) |
Definition at line 194 of file ModuleInfo.cpp.
Referenced by getExecutablePath(), and linkedModulePaths().
ELEMENTS_API bool Elements::System::getStackLevel | ( | ELEMENTS_UNUSED void * | addresses, |
ELEMENTS_UNUSED void *& | addr, | ||
ELEMENTS_UNUSED std::string & | fnc, | ||
ELEMENTS_UNUSED std::string & | lib | ||
) |
Referenced by backTrace().
bool Elements::System::getStackLevel | ( | void *addresses | ELEMENTS_UNUSED, |
void *&addr | ELEMENTS_UNUSED, | ||
string &fnc | ELEMENTS_UNUSED, | ||
string &lib | ELEMENTS_UNUSED | ||
) |
Definition at line 465 of file System.cpp.
References std::unique_ptr< T >::get().
const ModuleInfo & Elements::System::getThisExecutableInfo | ( | ) |
Definition at line 34 of file ThisModule.cpp.
References Elements::System::ModuleInfo::isEmpty().
|
inlinestatic |
Definition at line 35 of file ThisModule.h.
References Elements::System::ModuleInfo::isEmpty().
const string & Elements::System::hostName | ( | ) |
Host name.
Definition at line 285 of file System.cpp.
References std::unique_ptr< T >::get(), and HOST_NAME_MAX.
bool Elements::System::isEnvSet | ( | const std::string & | var | ) |
Check if an environment variable is set or not.
Definition at line 355 of file System.cpp.
References getEnv().
Referenced by Elements::Environment::hasKey().
vector< path > Elements::System::linkedModulePaths | ( | ) |
Definition at line 210 of file ModuleInfo.cpp.
References std::getline(), getSelfProc(), and std::vector< T >::push_back().
Referenced by linkedModules().
Vector of names of linked modules.
Definition at line 236 of file ModuleInfo.cpp.
References linkedModulePaths(), Elements::Units::m, and std::vector< T >::push_back().
unsigned long Elements::System::loadDynamicLib | ( | const std::string & | name, |
ImageHandle * | handle | ||
) |
Load dynamic link library.
Definition at line 89 of file System.cpp.
References getEnv(), std::string::length(), and SHLIB_SUFFIX.
const string & Elements::System::machineType | ( | ) |
Machine type.
Definition at line 320 of file System.cpp.
ImageHandle Elements::System::moduleHandle | ( | ) |
Handle to currently executed module.
Definition at line 154 of file ModuleInfo.cpp.
References processHandle().
Referenced by moduleName(), and moduleNameFull().
const string & Elements::System::moduleName | ( | ) |
Get the name of the (executable/DLL) file without file-type.
Retrieve base name of module.
Definition at line 96 of file ModuleInfo.cpp.
References moduleHandle(), processHandle(), std::string::rfind(), and std::string::substr().
const string & Elements::System::moduleNameFull | ( | ) |
Get the full name of the (executable/DLL) file.
Retrieve full name of module.
Definition at line 108 of file ModuleInfo.cpp.
References moduleHandle(), and processHandle().
Referenced by moduleType().
ModuleType Elements::System::moduleType | ( | ) |
Get type of the module.
Definition at line 125 of file ModuleInfo.cpp.
References EXECUTABLE, moduleNameFull(), std::string::rfind(), SHAREDLIB, and UNKNOWN.
const string & Elements::System::osName | ( | ) |
OS name.
Definition at line 296 of file System.cpp.
const string & Elements::System::osVersion | ( | ) |
OS version.
Definition at line 308 of file System.cpp.
void * Elements::System::processHandle | ( | ) |
Handle to running process.
Retrieve process handle.
Definition at line 144 of file ModuleInfo.cpp.
Referenced by moduleHandle(), moduleName(), and moduleNameFull().
int Elements::System::setEnv | ( | const std::string & | name, |
const std::string & | value, | ||
bool | overwrite = true |
||
) |
set an environment variables.
Set an environment variables. If value is empty, the variable is removed from the environment. When overwrite is 0, the variable is not set if already present. Returns 0 on success, -1 on failure. See man 3 setenv.
Definition at line 377 of file System.cpp.
References std::string::c_str().
Referenced by Elements::Environment::restore(), and Elements::Environment::set().
void Elements::System::setModuleHandle | ( | ImageHandle | handle | ) |
Attach module handle.
Definition at line 150 of file ModuleInfo.cpp.
const string Elements::System::typeinfoName | ( | const std::type_info & | tinfo | ) |
Get platform independent information about the class type.
Definition at line 191 of file System.cpp.
References std::type_info::name().
const string Elements::System::typeinfoName | ( | const char * | class_name | ) |
substitute ', ' with ','
substitute ', ' with ','
Definition at line 195 of file System.cpp.
References std::string::find(), and std::string::replace().
unsigned long Elements::System::unloadDynamicLib | ( | ImageHandle | handle | ) |
unload dynamic link library
Definition at line 116 of file System.cpp.
References getLastError().
int Elements::System::unSetEnv | ( | const std::string & | name | ) |
Simple wrap around unsetenv for strings.
Definition at line 388 of file System.cpp.
References std::string::c_str().
Referenced by Elements::Environment::restore(), and Elements::Environment::unSet().
const std::string Elements::System::DEFAULT_INSTALL_PREFIX { "/usr" } |
constant for the canonical installation prefix (on Linux and MacOSX at least)
Definition at line 90 of file System.h.
Referenced by Elements::getAuxiliaryLocations(), and Elements::getConfigurationLocations().
const std::string Elements::System::LIB_EXTENSION { "so" } |
const std::string Elements::System::LIB_PREFIX { "lib" } |
const std::string Elements::System::LIB_SUFFIX { "." + LIB_EXTENSION } |
const std::string Elements::System::SHLIB_SUFFIX { LIB_SUFFIX } |
const std::string Elements::System::SHLIB_VAR_NAME { "LD_LIBRARY_PATH" } |
const int Elements::System::STACK_OFFSET {2} |
Definition at line 98 of file System.h.
Referenced by backTrace().