Elements
5.12
A C++ base framework for the Euclid Software.
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
34
const
ModuleInfo
&
getThisExecutableInfo
() {
35
static
ModuleInfo
this_module;
36
if
(this_module.
isEmpty
()) {
37
void
* handle = ::dlopen(
nullptr
, RTLD_LAZY);
38
if
(
nullptr
!= handle) {
39
void
* func = ::dlsym(handle,
"main"
);
40
if
(
nullptr
!= func) {
41
this_module =
ModuleInfo
(FuncPtrCast<void*>(func));
42
}
43
}
44
}
45
46
return
this_module;
47
}
48
49
50
}
// namespace System
51
}
// 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.
Elements::System::ModuleInfo
Definition:
ModuleInfo.h:44
Elements::System::getThisExecutableInfo
ELEMENTS_API const ModuleInfo & getThisExecutableInfo()
Definition:
ThisModule.cpp:34
Elements::System::ModuleInfo::isEmpty
bool isEmpty() const
Definition:
ModuleInfo.cpp:83
ThisModule.h
header to get the module info statically
Elements
Definition:
Auxiliary.h:43
Generated by
1.8.20