Elements
6.2.3
A C++ base framework for the Euclid Software.
Loading...
Searching...
No Matches
ElementsKernel
src
Lib
ThisModule.cpp
Go to the documentation of this file.
1
22
#include "
ElementsKernel/ThisModule.h
"
23
24
#include <cstddef>
25
#include <dlfcn.h>
26
27
#include "
ElementsKernel/FuncPtrCast.h
"
// for FuncPtrCast
28
#include "
ElementsKernel/ModuleInfo.h
"
// for ModuleInfo
29
30
namespace
Elements
{
31
namespace
System
{
32
33
const
ModuleInfo
&
getThisExecutableInfo
() {
34
static
ModuleInfo
this_module;
35
if
(this_module.
isEmpty
()) {
36
void
* handle = ::dlopen(
nullptr
, RTLD_LAZY);
37
if
(
nullptr
!= handle) {
38
void
* func = ::dlsym(handle,
"main"
);
39
if
(
nullptr
!= func) {
40
this_module =
ModuleInfo
(FuncPtrCast<void*>(func));
41
}
42
}
43
}
44
45
return
this_module;
46
}
47
48
}
// namespace System
49
}
// namespace Elements
FuncPtrCast.h
defines a Small helper function that allows the cast from void * to function pointer
ModuleInfo.h
OS specific details to access at run-time the module configuration of the process.
ThisModule.h
header to get the module info statically
Elements::System::ModuleInfo
Definition
ModuleInfo.h:44
Elements::System::ModuleInfo::isEmpty
bool isEmpty() const
Definition
ModuleInfo.cpp:85
Elements::System::getThisExecutableInfo
ELEMENTS_API const ModuleInfo & getThisExecutableInfo()
Definition
ThisModule.cpp:33
Elements::System::InfoType::System
@ System
Elements
Definition
Auxiliary.h:43
Generated by
1.10.0