Elements 6.3.1
A C++ base framework for the Euclid Software.
|
Classes | |
class | ModuleInfo |
Typedefs | |
using | ImageHandle = void* |
Definition of an image handle. | |
using | ProcessHandle = void* |
Definition of the process handle. | |
using | EntryPoint = unsigned long (*)(const unsigned long iid, void** ppvObject) |
Definition of the "generic" DLL entry point function. | |
using | Creator = void* (*)() |
Definition of the "generic" DLL entry point function. | |
Enumerations | |
enum class | ModuleType { UNKNOWN , SHAREDLIB , EXECUTABLE } |
enum class | InfoType { NoFetch , RemainTime , Times , ProcessBasics , PriorityBoost , Memory , Quota , System , Modules , IO } |
Enumeration for fetching information. More... | |
Functions | |
template<typename DESTPTR , typename SRC > | |
constexpr DESTPTR | FuncPtrCast (SRC *const src_p) noexcept |
Cast from void * to function pointer. | |
ELEMENTS_API const std::string & | moduleName () |
Get the name of the (executable/DLL) file without file-type. | |
ELEMENTS_API const std::string & | moduleNameFull () |
Get the full name of the (executable/DLL) file. | |
ELEMENTS_API ModuleType | moduleType () |
Get type of the module. | |
ELEMENTS_API ProcessHandle | processHandle () |
Handle to running process. | |
ELEMENTS_API ImageHandle | moduleHandle () |
Handle to currently executed module. | |
ELEMENTS_API ImageHandle | exeHandle () |
Handle to the executable file running. | |
ELEMENTS_API const std::string & | exeName () |
Name of the executable file running. | |
ELEMENTS_API const std::vector< std::string > | linkedModules () |
Vector of names of linked modules. | |
ELEMENTS_API std::vector< Path::Item > | linkedModulePaths () |
ELEMENTS_API void | setModuleHandle (ImageHandle handle) |
Attach module handle. | |
ELEMENTS_API Path::Item | getExecutablePath () |
Get the full executable path. | |
ELEMENTS_API Path::Item | getSelfProc () |
Get the path to the /proc directory of the process. | |
ELEMENTS_API unsigned long | loadDynamicLib (const std::string &name, ImageHandle *handle) |
Load dynamic link library. | |
ELEMENTS_API unsigned long | unloadDynamicLib (ImageHandle handle) |
unload dynamic link library | |
ELEMENTS_API unsigned long | getProcedureByName (ImageHandle handle, const std::string &name, EntryPoint *pFunction) |
Get a specific function defined in the DLL. | |
ELEMENTS_API unsigned long | getProcedureByName (ImageHandle handle, const std::string &name, Creator *pFunction) |
Get a specific function defined in the DLL. | |
ELEMENTS_API unsigned long | getLastError () |
Get last system known error. | |
ELEMENTS_API const std::string | getLastErrorString () |
Get last system error as string. | |
ELEMENTS_API const std::string | getErrorString (unsigned long error) |
Retrieve error code as string for a given error. | |
ELEMENTS_API const std::string | typeinfoName (const std::type_info &) |
Get platform independent information about the class type. | |
ELEMENTS_API const std::string | typeinfoName (const char *) |
ELEMENTS_API const std::string & | hostName () |
Host name. | |
ELEMENTS_API const std::string & | osName () |
OS name. | |
ELEMENTS_API const std::string & | osVersion () |
OS version. | |
ELEMENTS_API const std::string & | machineType () |
Machine type. | |
ELEMENTS_API std::string | getEnv (const std::string &var) |
get a particular environment variable | |
ELEMENTS_API bool | getEnv (const string &variable_name, string &variable_value) |
get a particular env var, storing the value in the passed string (if set) | |
ELEMENTS_API std::vector< std::string > | getEnv () |
get all environment variables | |
ELEMENTS_API int | setEnv (const string &name, const string &value, bool overwrite) |
set an environment variables. | |
ELEMENTS_API int | unSetEnv (const std::string &name) |
Simple wrap around unsetenv for strings. | |
ELEMENTS_API bool | isEnvSet (const std::string &var) |
Check if an environment variable is set or not. | |
ELEMENTS_API int | backTrace (ELEMENTS_UNUSED std::shared_ptr< void * > addresses, ELEMENTS_UNUSED const int depth) |
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 () |
function to retrieve the current module | |
ELEMENTS_API const 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 | |
const std::string | LIB_PREFIX {"lib"} |
constant that represent the common prefix of the libraries | |
const std::string | LIB_EXTENSION {"so"} |
constant that represent the common extension of the libraries | |
const std::string | LIB_SUFFIX {"." + LIB_EXTENSION} |
constant that represents the standard suffix of the libraries: usually "."+LIB_EXTENSION | |
const std::string | SHLIB_SUFFIX {LIB_SUFFIX} |
alias for LIB_SUFFIX | |
const std::string | DEFAULT_INSTALL_PREFIX {"/usr"} |
constant for the canonical installation prefix (on Linux and MacOSX at least) | |
const int | STACK_OFFSET {2} |
using Elements::System::Creator = void* (*)() |
using Elements::System::EntryPoint = unsigned long (*)(const unsigned long iid, void** ppvObject) |
using Elements::System::ImageHandle = void* |
using Elements::System::ProcessHandle = 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 379 of file System.cpp.
Definition at line 390 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 158 of file ModuleInfo.cpp.
const string & Elements::System::exeName | ( | ) |
Name of the executable file running.
Definition at line 177 of file ModuleInfo.cpp.
get all environment variables
get all defined environment vars
Definition at line 350 of file System.cpp.
References std::vector< T >::emplace_back().
Referenced by getEnv(), isEnvSet(), and loadDynamicLib().
string Elements::System::getEnv | ( | const std::string & | var | ) |
get a particular environment variable
Definition at line 317 of file System.cpp.
References getEnv().
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 327 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 158 of file System.cpp.
References std::strerror().
Referenced by getLastErrorString().
Path::Item Elements::System::getExecutablePath | ( | ) |
Get the full executable path.
Definition at line 240 of file ModuleInfo.cpp.
References getSelfProc().
unsigned long Elements::System::getLastError | ( | ) |
Get last system known error.
Retrieve last error code.
Definition at line 146 of file System.cpp.
Referenced by getLastErrorString().
const string Elements::System::getLastErrorString | ( | ) |
Get last system error as string.
Retrieve last error code as string.
Definition at line 152 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 141 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 117 of file System.cpp.
References std::string::c_str(), std::endl(), FuncPtrCast(), and getLastErrorString().
Referenced by getProcedureByName().
Path::Item Elements::System::getSelfProc | ( | ) |
Get the path to the /proc directory of the process.
Definition at line 185 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 420 of file System.cpp.
const ModuleInfo & Elements::System::getThisExecutableInfo | ( | ) |
Definition at line 31 of file ThisModule.cpp.
References FuncPtrCast(), and Elements::System::ModuleInfo::isEmpty().
const string & Elements::System::hostName | ( | ) |
Host name.
Definition at line 271 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 340 of file System.cpp.
References getEnv().
vector< Path::Item > Elements::System::linkedModulePaths | ( | ) |
Definition at line 200 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 229 of file ModuleInfo.cpp.
References std::vector< T >::emplace_back(), and linkedModulePaths().
unsigned long Elements::System::loadDynamicLib | ( | const std::string & | name, |
ImageHandle * | handle ) |
Load dynamic link library.
Definition at line 84 of file System.cpp.
References getEnv(), std::string::length(), and SHLIB_SUFFIX.
const string & Elements::System::machineType | ( | ) |
Machine type.
Definition at line 306 of file System.cpp.
ImageHandle Elements::System::moduleHandle | ( | ) |
Handle to currently executed module.
Definition at line 146 of file ModuleInfo.cpp.
References FuncPtrCast(), moduleHandle(), and processHandle().
Referenced by moduleHandle(), 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 89 of file ModuleInfo.cpp.
References moduleHandle(), and processHandle().
const string & Elements::System::moduleNameFull | ( | ) |
Get the full name of the (executable/DLL) file.
Retrieve full name of module.
Definition at line 101 of file ModuleInfo.cpp.
References moduleHandle(), and processHandle().
Referenced by moduleType().
ModuleType Elements::System::moduleType | ( | ) |
Get type of the module.
Definition at line 117 of file ModuleInfo.cpp.
References EXECUTABLE, moduleNameFull(), SHAREDLIB, and UNKNOWN.
const string & Elements::System::osName | ( | ) |
OS name.
Definition at line 282 of file System.cpp.
const string & Elements::System::osVersion | ( | ) |
OS version.
Definition at line 294 of file System.cpp.
void * Elements::System::processHandle | ( | ) |
Handle to running process.
Retrieve process handle.
Definition at line 136 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 362 of file System.cpp.
References std::string::c_str().
void Elements::System::setModuleHandle | ( | ImageHandle | handle | ) |
Attach module handle.
Definition at line 142 of file ModuleInfo.cpp.
const string Elements::System::typeinfoName | ( | const char * | class_name | ) |
substitute ', ' with ','
substitute ', ' with ','
Definition at line 183 of file System.cpp.
References std::string::find(), 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 179 of file System.cpp.
References std::type_info::name(), and typeinfoName().
Referenced by typeinfoName().
unsigned long Elements::System::unloadDynamicLib | ( | ImageHandle | handle | ) |
unload dynamic link library
Definition at line 111 of file System.cpp.
int Elements::System::unSetEnv | ( | const std::string & | name | ) |
Simple wrap around unsetenv for strings.
Definition at line 372 of file System.cpp.
References std::string::c_str().
const std::string Elements::System::DEFAULT_INSTALL_PREFIX {"/usr"} |
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().