46 #ifndef OME_COMMON_MODULE_H 47 #define OME_COMMON_MODULE_H 49 #include <boost/filesystem/operations.hpp> 50 #include <boost/filesystem/path.hpp> 52 #include <ome/common/config.h> 75 const boost::filesystem::path&
149 Module(
const std::string& name,
150 const std::string& envvar,
151 const std::string& module_envvar,
152 const std::string& root_envvar,
153 const boost::filesystem::path& abspath,
154 const boost::filesystem::path& relpath,
155 const boost::filesystem::path& install_prefix,
156 const boost::filesystem::path& shlibpath,
192 const std::string& envvar,
193 const std::string& module_envvar,
194 const std::string& root_envvar,
195 const boost::filesystem::path& abspath,
196 const boost::filesystem::path& relpath,
197 const boost::filesystem::path& install_prefix,
198 const boost::filesystem::path& shlibpath,
213 #ifdef OME_COMMON_MODULE_INTROSPECTION 215 #ifdef OME_HAVE_DLADDR 217 # define _GNU_SOURCE 1 220 #endif // OME_HAVE_DLADDR 223 # include <windows.h> 229 #ifdef OME_HAVE_DLADDR 232 __attribute__((constructor))
236 if(!dladdr(reinterpret_cast<void *>(find_module), &this_module))
238 this_module.dli_fname = 0;
242 boost::filesystem::path
245 if (this_module.dli_fname)
246 return boost::filesystem::canonical(boost::filesystem::path(this_module.dli_fname));
247 return boost::filesystem::path();
253 static bool found_module =
false;
254 static HMODULE this_module;
258 if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
259 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
260 reinterpret_cast<LPCWSTR>(&find_module),
270 boost::filesystem::path
273 HMODULE this_module = find_module();
276 WCHAR win_wide_path[MAX_PATH];
277 GetModuleFileNameW(this_module, win_wide_path,
sizeof(win_wide_path));
278 return boost::filesystem::path(win_wide_path);
280 return boost::filesystem::path();
282 #else // No introspection available 283 boost::filesystem::path
286 return boost::filesystem::path();
290 #endif // OME_COMMON_MODULE_INTROSPECTION 292 #endif // OME_COMMON_MODULE_H boost::filesystem::path realpath
The detected path (used to cache search result).
Definition: module.h:126
std::string root_envvar
Name of the environment variable used to specify the installation root.
Definition: module.h:115
std::string name
Name of the path, e.g. "bin" or "ome-xml-schema".
Definition: module.h:169
boost::filesystem::path abspath
Absolute path (used when configured to use an absolute install path).
Definition: module.h:118
const fs::path & module_runtime_path(const std::string &dtype)
Get the runtime installation prefix path for a module.
Definition: module.cpp:372
boost::filesystem::path shlibpath
Shared library path (used for relocatable installs).
Definition: module.h:124
std::string name
Name of the path, e.g. "bin" or "ome-xml-schema".
Definition: module.h:106
boost::filesystem::path relpath
Relative path (used for relocatable installs).
Definition: module.h:120
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:273
bool registered
Is the path registered in the path map?
Definition: module.h:171
Open Microscopy Environment C++.
Definition: base64.h:49
A run-time path for a given module.
Definition: module.h:103
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:131
std::string module_envvar
Name of the environment variable used to specify the module installation root.
Definition: module.h:112
std::string envvar
Name of the environment variable used to override the autodetected path.
Definition: module.h:109
Register a module to make it available to module_runtime_path().
Definition: module.h:166
boost::filesystem::path install_prefix
Absolute installation path (used for non-relocatable installs).
Definition: module.h:122
void register_module_paths()
Register OME-Common module paths.
Definition: module.cpp:489