Elements
6.2
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... | |
const ELEMENTS_API std::string & | moduleName () |
Get the name of the (executable/DLL) file without file-type. More... | |
const ELEMENTS_API 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... | |
const ELEMENTS_API std::string & | exeName () |
Name of the executable file running. More... | |
const ELEMENTS_API std::vector< std::string > | linkedModules () |
Vector of names of linked modules. More... | |
ELEMENTS_API std::vector< Path::Item > | linkedModulePaths () |
ELEMENTS_API void | setModuleHandle (ImageHandle handle) |
Attach module handle. More... | |
ELEMENTS_API Path::Item | getExecutablePath () |
Get the full executable path. More... | |
ELEMENTS_API Path::Item | getSelfProc () |
Get the path to the /proc directory of the process. 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... | |
const ELEMENTS_API std::string | getLastErrorString () |
Get last system error as string. More... | |
const ELEMENTS_API std::string | getErrorString (unsigned long error) |
Retrieve error code as string for a given error. More... | |
const ELEMENTS_API std::string | typeinfoName (const std::type_info &) |
Get platform independent information about the class type. More... | |
const ELEMENTS_API std::string | typeinfoName (const char *) |
const ELEMENTS_API std::string & | hostName () |
Host name. More... | |
const ELEMENTS_API std::string & | osName () |
OS name. More... | |
const ELEMENTS_API std::string & | osVersion () |
OS version. More... | |
const ELEMENTS_API 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) |
const ELEMENTS_API 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 () |
function to retrieve the current module More... | |
const ELEMENTS_API ModuleInfo & | getThisExecutableInfo () |
__attribute__ ((noinline)) int backTrace(ELEMENTS_UNUSED std | |
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.
Elements::System::__attribute__ | ( | (noinline) | ) |
Definition at line 386 of file System.cpp.
Definition at line 397 of file System.cpp.
References backTrace(), std::dec(), getStackLevel(), std::hex(), std::setiosflags(), std::setw(), STACK_OFFSET, and std::ostringstream::str().
ELEMENTS_API int Elements::System::backTrace | ( | ELEMENTS_UNUSED std::shared_ptr< void * > | addresses, |
ELEMENTS_UNUSED const int | depth | ||
) |
Referenced by backTrace(), and Elements::ProgramManager::onTerminate().
ImageHandle Elements::System::exeHandle | ( | ) |
Handle to the executable file running.
Definition at line 164 of file ModuleInfo.cpp.
const string & Elements::System::exeName | ( | ) |
Name of the executable file running.
Definition at line 183 of file ModuleInfo.cpp.
References getExecutablePath().
get all environment variables
get all defined environment vars
Definition at line 357 of file System.cpp.
References std::vector< T >::emplace_back().
string Elements::System::getEnv | ( | const std::string & | var | ) |
get a particular environment variable
Definition at line 324 of file System.cpp.
Referenced by Elements::Environment::get(), isEnvSet(), loadDynamicLib(), 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 334 of file System.cpp.
References std::string::c_str().
const string Elements::System::getErrorString | ( | unsigned long | error | ) |
Retrieve error code as string for a given error.
Definition at line 165 of file System.cpp.
References std::strerror().
Referenced by getLastErrorString().
Path::Item Elements::System::getExecutablePath | ( | ) |
Get the full executable path.
Definition at line 246 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 153 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 159 of file System.cpp.
References getErrorString(), and getLastError().
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 148 of file System.cpp.
References 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 124 of file System.cpp.
References std::string::c_str(), std::endl(), and getLastErrorString().
Referenced by getProcedureByName().
Path::Item Elements::System::getSelfProc | ( | ) |
Get the path to the /proc directory of the process.
Definition at line 191 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 427 of file System.cpp.
References std::unique_ptr< T >::get().
const ModuleInfo & Elements::System::getThisExecutableInfo | ( | ) |
Definition at line 33 of file ThisModule.cpp.
References Elements::System::ModuleInfo::isEmpty().
Referenced by ExtProgram::mainMethod(), and Elements::Examples::Program::mainMethod().
const string & Elements::System::hostName | ( | ) |
Host name.
Definition at line 278 of file System.cpp.
References std::array< T >::data(), and HOST_NAME_MAX.
bool Elements::System::isEnvSet | ( | const std::string & | var | ) |
Check if an environment variable is set or not.
Definition at line 347 of file System.cpp.
References getEnv().
Referenced by Elements::Environment::hasKey().
vector< Path::Item > Elements::System::linkedModulePaths | ( | ) |
Definition at line 206 of file ModuleInfo.cpp.
References std::ifstream::close(), std::vector< T >::emplace_back(), std::getline(), and getSelfProc().
Referenced by linkedModules().
Vector of names of linked modules.
Definition at line 235 of file ModuleInfo.cpp.
References std::vector< T >::emplace_back(), linkedModulePaths(), and Elements::Kernel::Units::m.
unsigned long Elements::System::loadDynamicLib | ( | const std::string & | name, |
ImageHandle * | handle | ||
) |
Load dynamic link library.
Definition at line 88 of file System.cpp.
References getEnv(), std::string::length(), and SHLIB_SUFFIX.
const string & Elements::System::machineType | ( | ) |
Machine type.
Definition at line 313 of file System.cpp.
ImageHandle Elements::System::moduleHandle | ( | ) |
Handle to currently executed module.
Definition at line 152 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 95 of file ModuleInfo.cpp.
References std::string::find(), moduleHandle(), processHandle(), 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 107 of file ModuleInfo.cpp.
References moduleHandle(), and processHandle().
Referenced by moduleType().
ModuleType Elements::System::moduleType | ( | ) |
Get type of the module.
Definition at line 123 of file ModuleInfo.cpp.
References EXECUTABLE, moduleNameFull(), std::string::rfind(), SHAREDLIB, and UNKNOWN.
const string & Elements::System::osName | ( | ) |
OS name.
Definition at line 289 of file System.cpp.
const string & Elements::System::osVersion | ( | ) |
OS version.
Definition at line 301 of file System.cpp.
void * Elements::System::processHandle | ( | ) |
Handle to running process.
Retrieve process handle.
Definition at line 142 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 369 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 148 of file ModuleInfo.cpp.
const string Elements::System::typeinfoName | ( | const char * | class_name | ) |
substitute ', ' with ','
substitute ', ' with ','
Definition at line 190 of file System.cpp.
References std::string::find(), std::unique_ptr< T >::get(), and std::string::replace().
const string Elements::System::typeinfoName | ( | const std::type_info & | tinfo | ) |
Get platform independent information about the class type.
Definition at line 186 of file System.cpp.
References std::type_info::name().
unsigned long Elements::System::unloadDynamicLib | ( | ImageHandle | handle | ) |
unload dynamic link library
Definition at line 115 of file System.cpp.
References getLastError().
int Elements::System::unSetEnv | ( | const std::string & | name | ) |
Simple wrap around unsetenv for strings.
Definition at line 379 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::Kernel::getAuxiliaryLocations(), and Elements::Kernel::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 92 of file System.h.
Referenced by backTrace().