46 #ifndef OME_COMMON_MODULE_H 47 # define OME_COMMON_MODULE_H 49 # include <ome/common/config.h> 70 const boost::filesystem::path&
144 Module(
const std::string& name,
145 const std::string& envvar,
146 const std::string& module_envvar,
147 const std::string& root_envvar,
148 const boost::filesystem::path& abspath,
149 const boost::filesystem::path& relpath,
150 const boost::filesystem::path& install_prefix,
151 const boost::filesystem::path& shlibpath,
187 const std::string& envvar,
188 const std::string& module_envvar,
189 const std::string& root_envvar,
190 const boost::filesystem::path& abspath,
191 const boost::filesystem::path& relpath,
192 const boost::filesystem::path& install_prefix,
193 const boost::filesystem::path& shlibpath,
208 #ifdef OME_COMMON_MODULE_INTROSPECTION 210 #ifdef OME_HAVE_DLADDR 212 # define _GNU_SOURCE 1 215 #endif // OME_HAVE_DLADDR 218 # include <windows.h> 224 #ifdef OME_HAVE_DLADDR 227 __attribute__((constructor))
231 if(!dladdr(reinterpret_cast<void *>(find_module), &this_module))
233 this_module.dli_fname = 0;
237 boost::filesystem::path
240 if (this_module.dli_fname)
241 return canonical(boost::filesystem::path(this_module.dli_fname));
242 return boost::filesystem::path();
248 static bool found_module =
false;
249 static HMODULE this_module;
253 if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
254 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
255 reinterpret_cast<LPCWSTR>(&find_module),
265 boost::filesystem::path
268 HMODULE this_module = find_module();
271 WCHAR win_wide_path[MAX_PATH];
272 GetModuleFileNameW(this_module, win_wide_path,
sizeof(win_wide_path));
273 return boost::filesystem::path(win_wide_path);
275 return boost::filesystem::path();
277 #else // No introspection available 278 boost::filesystem::path
281 return boost::filesystem::path();
285 #endif // OME_COMMON_MODULE_INTROSPECTION 287 #endif // OME_COMMON_MODULE_H boost::filesystem::path canonical(const boost::filesystem::path &p, const boost::filesystem::path &base=boost::filesystem::current_path(), boost::system::error_code *ec=0)
Get a canonical path.
Definition: filesystem.h:105
boost::filesystem::path realpath
The detected path (used to cache search result).
Definition: module.h:121
std::string root_envvar
Name of the environment variable used to specify the installation root.
Definition: module.h:110
std::string name
Name of the path, e.g. "bin" or "ome-xml-schema".
Definition: module.h:164
boost::filesystem::path abspath
Absolute path (used when configured to use an absolute install path).
Definition: module.h:113
const fs::path & module_runtime_path(const std::string &dtype)
Get the runtime installation prefix path for a module.
Definition: module.cpp:371
boost::filesystem::path shlibpath
Shared library path (used for relocatable installs).
Definition: module.h:119
std::string name
Name of the path, e.g. "bin" or "ome-xml-schema".
Definition: module.h:101
boost::filesystem::path relpath
Relative path (used for relocatable installs).
Definition: module.h:115
Module(const std::string &name, const std::string &envvar, const std::string &module_envvar, const std::string &root_envvar, const boost::filesystem::path &abspath, const boost::filesystem::path &relpath, const boost::filesystem::path &install_prefix, const boost::filesystem::path &shlibpath, boost::filesystem::path(*module_path)())
Constructor.
Definition: module.cpp:272
bool registered
Is the path registered in the path map?
Definition: module.h:166
Boost.Filesystem compatibility.
A run-time path for a given module.
Definition: module.h:98
boost::filesystem::path(* module_path)()
Function to obtain the absolute path of the module providing the path (from the shared library or DLL...
Definition: module.h:126
std::string module_envvar
Name of the environment variable used to specify the module installation root.
Definition: module.h:107
std::string envvar
Name of the environment variable used to override the autodetected path.
Definition: module.h:104
Register a module to make it available to module_runtime_path().
Definition: module.h:161
boost::filesystem::path install_prefix
Absolute installation path (used for non-relocatable installs).
Definition: module.h:117
void register_module_paths()
Register OME-Common module paths.
Definition: module.cpp:488