OpenWalnut
1.5.0dev
|
Singleton class helping to find files and paths. More...
#include <WPathHelper.h>
Classes | |
struct | Fonts |
Paths to all known fonts. More... | |
Public Member Functions | |
virtual | ~WPathHelper () |
Destructor. More... | |
void | setBasePaths (boost::filesystem::path appPath, boost::filesystem::path homePath) |
Set the current application path. More... | |
void | setBasePathsOSXBundle (boost::filesystem::path appPath, boost::filesystem::path homePath) |
Set the current application path. More... | |
void | addAdditionalModulePath (const boost::filesystem::path &path) |
This method adds the given path to the list of module paths. More... | |
const std::vector< boost::filesystem::path > & | getAdditionalModulePaths () const |
Returns the list of paths added using addAdditionalModulePath. More... | |
Static Public Member Functions | |
static std::shared_ptr< WPathHelper > | getPathHelper () |
Returns instance of the path helper. More... | |
static boost::filesystem::path | getAppPath () |
The path where the binary file resides in. More... | |
static boost::filesystem::path | getFontPath () |
The path where font files reside in. More... | |
static Fonts | getAllFonts () |
The paths to all fonts supported. More... | |
static boost::filesystem::path | getShaderPath () |
The path to the global shaders. More... | |
static boost::filesystem::path | getModulePath () |
The path to the globally installed modules. More... | |
static boost::filesystem::path | getHomePath () |
The path to the OW dir in the user's home. More... | |
static std::vector< boost::filesystem::path > | getAllModulePaths () |
This returns a list of search paths for modules. More... | |
static boost::filesystem::path | getLibPath () |
The path to the OW libs. More... | |
static boost::filesystem::path | getSharePath () |
The path where shared files reside in. More... | |
static boost::filesystem::path | getDocPath () |
The path where the doc files reside in. More... | |
static boost::filesystem::path | getConfigPath () |
The path where the config files reside in. More... | |
static boost::filesystem::path | getModuleResourcePath (boost::filesystem::path moduleLibPath, std::string packageName) |
The path to a given module's resources. More... | |
Protected Member Functions | |
WPathHelper () | |
Constructors are protected because this is a Singleton. More... | |
Private Attributes | |
boost::filesystem::path | m_appPath |
Application path. More... | |
boost::filesystem::path | m_sharePath |
The path where all the shared files reside in. More... | |
boost::filesystem::path | m_docPath |
The path where all the documentation files reside in. More... | |
boost::filesystem::path | m_configPath |
The path where all the config files reside in. More... | |
boost::filesystem::path | m_modulePath |
The path to the globally installed modules. More... | |
boost::filesystem::path | m_libPath |
The path to the OW libs. More... | |
boost::filesystem::path | m_homePath |
The path of a user specific OW directory. More... | |
boost::filesystem::path | m_moduleResourcePathRelative |
The path to module resources, relative to the module libraries path. More... | |
std::vector< boost::filesystem::path > | m_additionalModulePaths |
A list of additional paths to search for modules. More... | |
Static Private Attributes | |
static std::shared_ptr< WPathHelper > | m_instance = std::shared_ptr< WPathHelper >() |
Singleton instance of WPathHelper. More... | |
Singleton class helping to find files and paths.
It is a useful to to search for resources and the central place to "hardcode" relative paths. It contains global paths only. Modules have their OWN local paths.
Definition at line 38 of file WPathHelper.h.
|
virtual |
Destructor.
Definition at line 47 of file WPathHelper.cpp.
|
protected |
Constructors are protected because this is a Singleton.
Definition at line 42 of file WPathHelper.cpp.
Referenced by getPathHelper().
void WPathHelper::addAdditionalModulePath | ( | const boost::filesystem::path & | path | ) |
This method adds the given path to the list of module paths.
This way, arbitrary paths can be specified to search for modules. Each path is searched recursively.
path | the path to add. |
Definition at line 207 of file WPathHelper.cpp.
References m_additionalModulePaths.
const std::vector< boost::filesystem::path > & WPathHelper::getAdditionalModulePaths | ( | ) | const |
Returns the list of paths added using addAdditionalModulePath.
This does NOT contain the paths in OW_MODULE_PATH. Use getAllModulePaths for this.
Definition at line 215 of file WPathHelper.cpp.
References m_additionalModulePaths.
|
static |
The paths to all fonts supported.
Definition at line 108 of file WPathHelper.cpp.
References WPathHelper::Fonts::Bold, WPathHelper::Fonts::Default, getFontPath(), WPathHelper::Fonts::Italic, and WPathHelper::Fonts::Regular.
Referenced by wge::addLabel(), WRulerOrtho::addLabel(), WMHistogramView::createFrame(), WMMultiHistogramView::createFrame(), WMHistogramView::createInfo(), WMMultiHistogramView::createInfo(), WGELabel::WGELabel(), and WGETextureHud::WGETextureHudEntry::WGETextureHudEntry().
|
static |
This returns a list of search paths for modules.
This list is defined by the environment variable "OW_MODULE_PATH" and the list of additional module paths. All of these directories CAN contain modules. On startup, they get searched in the specified order.
Definition at line 173 of file WPathHelper.cpp.
References getHomePath(), getModulePath(), getPathHelper(), and m_additionalModulePaths.
Referenced by WModuleLoader::load().
|
static |
The path where the binary file resides in.
This is for example /usr/bin.
Definition at line 93 of file WPathHelper.cpp.
References getPathHelper().
Referenced by WMClusterDisplay::properties(), WMReadSphericalHarmonics::properties(), WMWriteNIfTI::properties(), WMReadAmiraMesh::properties(), WMReadDipoles::properties(), WMReadMesh::properties(), WMReadRawData::properties(), WMReadVCL::properties(), WMSplineSurface::properties(), WMTemplate::properties(), WMTemplateUI::properties(), WMWebglSupport::properties(), WMWriteField::properties(), WMWriteMesh::properties(), WMWriteRawData::properties(), and WMWriteTransferFunction::properties().
|
static |
The path where the config files reside in.
Definition at line 144 of file WPathHelper.cpp.
References getPathHelper().
|
static |
The path where the doc files reside in.
Definition at line 139 of file WPathHelper.cpp.
References getPathHelper().
Referenced by WMainWindow::openAboutDialog(), WMainWindow::openOpenWalnutHelpDialog(), and WMainWindow::showWelcomeDialog().
|
static |
The path where font files reside in.
Definition at line 98 of file WPathHelper.cpp.
References getPathHelper().
Referenced by getAllFonts().
|
static |
The path to the OW dir in the user's home.
This will not be the home dir directly. It is something like $HOME/.OpenWalnut.
Definition at line 124 of file WPathHelper.cpp.
References getPathHelper().
Referenced by WQtModuleConfig::addModulePath(), getAllModulePaths(), WFilterPropertyHandler::getParticleNameFilePath(), WMWriteCSV::properties(), WQtGui::run(), and WScriptUI::run().
|
static |
The path to the OW libs.
You normally should not need this.
Definition at line 129 of file WPathHelper.cpp.
References getPathHelper().
|
static |
The path to the globally installed modules.
This does not respect any environment variables or config options! Use this only to search global modules. To get a list of all module search paths, including user defined ones, use getAllModulePaths().
Definition at line 119 of file WPathHelper.cpp.
References getPathHelper().
Referenced by getAllModulePaths().
|
static |
The path to a given module's resources.
This should be used to get a share-like path for the module. The path is relative to the module's library path. This method is most useful for the module loader. You should not query your own resource path with this function. Use your module instance's m_localPath.
moduleLibPath | the path to the lib. Can be relative or absolute. This must be the directory the lib contains and NOT the path to the lib itself |
packageName | the name of the resource. This is usually the package name. |
Definition at line 149 of file WPathHelper.cpp.
References getPathHelper().
Referenced by WModuleLoader::load().
|
static |
Returns instance of the path helper.
If it does not exists, it will be created.
Definition at line 52 of file WPathHelper.cpp.
References m_instance, and WPathHelper().
Referenced by getAllModulePaths(), getAppPath(), getConfigPath(), getDocPath(), getFontPath(), getHomePath(), WIconManager::getIcon(), getLibPath(), getModulePath(), getModuleResourcePath(), getShaderPath(), getSharePath(), WQtModuleConfig::initPathHelper(), WScriptUI::loadToolboxes(), WQtGui::run(), and WScriptUI::run().
|
static |
The path to the global shaders.
Modules usually have their own local shader directory.
Definition at line 103 of file WPathHelper.cpp.
References getPathHelper().
Referenced by WGEShader::processShaderRecursive().
|
static |
The path where shared files reside in.
Definition at line 134 of file WPathHelper.cpp.
References getPathHelper().
Referenced by WGEViewerEffectImageOverlay::WGEViewerEffectImageOverlay().
void WPathHelper::setBasePaths | ( | boost::filesystem::path | appPath, |
boost::filesystem::path | homePath | ||
) |
Set the current application path.
This should be called only once. The home path hereby is NOT the users home. It is a directory, where OW can write user specific data. A good default here is to specify USERHOME/.OpenWalnut for example.
appPath | the application path |
homePath | the OW home path |
Definition at line 62 of file WPathHelper.cpp.
References m_appPath, m_configPath, m_docPath, m_homePath, m_libPath, m_modulePath, m_moduleResourcePathRelative, and m_sharePath.
Referenced by setBasePathsOSXBundle().
void WPathHelper::setBasePathsOSXBundle | ( | boost::filesystem::path | appPath, |
boost::filesystem::path | homePath | ||
) |
Set the current application path.
This should be called only once. The home path hereby is NOT the users home. It is a directory, where OW can write user specific data. A good default here is to specify USERHOME/.OpenWalnut for example.
appPath | the application path |
homePath | the OW home path |
Definition at line 80 of file WPathHelper.cpp.
References m_appPath, m_configPath, m_docPath, m_modulePath, m_moduleResourcePathRelative, m_sharePath, and setBasePaths().
|
private |
A list of additional paths to search for modules.
This does not contain the paths in the environment variable OW_MODULE_PATH. This method is not thread-safe. You should only use it before the module factory loads the modules.
Definition at line 259 of file WPathHelper.h.
Referenced by addAdditionalModulePath(), getAdditionalModulePaths(), and getAllModulePaths().
|
private |
Application path.
NOT the path of the binary. The application path is the directory in which the binary is placed. The binary path is m_appPath+"/openwalnut".
Definition at line 218 of file WPathHelper.h.
Referenced by setBasePaths(), and setBasePathsOSXBundle().
|
private |
The path where all the config files reside in.
Definition at line 233 of file WPathHelper.h.
Referenced by setBasePaths(), and setBasePathsOSXBundle().
|
private |
The path where all the documentation files reside in.
Definition at line 228 of file WPathHelper.h.
Referenced by setBasePaths(), and setBasePathsOSXBundle().
|
private |
The path of a user specific OW directory.
Definition at line 248 of file WPathHelper.h.
Referenced by setBasePaths().
|
staticprivate |
Singleton instance of WPathHelper.
Definition at line 264 of file WPathHelper.h.
Referenced by getPathHelper().
|
private |
The path to the OW libs.
Definition at line 243 of file WPathHelper.h.
Referenced by setBasePaths().
|
private |
The path to the globally installed modules.
Definition at line 238 of file WPathHelper.h.
Referenced by setBasePaths(), and setBasePathsOSXBundle().
|
private |
The path to module resources, relative to the module libraries path.
Definition at line 253 of file WPathHelper.h.
Referenced by setBasePaths(), and setBasePathsOSXBundle().
|
private |
The path where all the shared files reside in.
Definition at line 223 of file WPathHelper.h.
Referenced by setBasePaths(), and setBasePathsOSXBundle().