Elements  6.2
A C++ base framework for the Euclid Software.
ThisModule.cpp
Go to the documentation of this file.
1 
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 
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
Elements::System::ModuleInfo
Definition: ModuleInfo.h:44
Elements::System::getThisExecutableInfo
const ELEMENTS_API ModuleInfo & getThisExecutableInfo()
Definition: ThisModule.cpp:33
Elements::System::ModuleInfo::isEmpty
bool isEmpty() const
Definition: ModuleInfo.cpp:83
ThisModule.h
header to get the module info statically
ModuleInfo.h
OS specific details to access at run-time the module configuration of the process.
Elements
Definition: callBackExample.h:35
Elements::System::InfoType::System
@ System