OpenWalnut  1.5.0dev
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Static Private Attributes | List of all members
WPathHelper Class Reference

Singleton class helping to find files and paths. More...

#include <WPathHelper.h>

+ Collaboration diagram for WPathHelper:

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< WPathHelpergetPathHelper ()
 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< WPathHelperm_instance = std::shared_ptr< WPathHelper >()
 Singleton instance of WPathHelper. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ~WPathHelper()

WPathHelper::~WPathHelper ( )
virtual

Destructor.

Definition at line 47 of file WPathHelper.cpp.

◆ WPathHelper()

WPathHelper::WPathHelper ( )
protected

Constructors are protected because this is a Singleton.

Definition at line 42 of file WPathHelper.cpp.

Referenced by getPathHelper().

+ Here is the caller graph for this function:

Member Function Documentation

◆ addAdditionalModulePath()

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.

Parameters
paththe path to add.

Definition at line 207 of file WPathHelper.cpp.

References m_additionalModulePaths.

◆ getAdditionalModulePaths()

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.

Returns
the list of additional paths

Definition at line 215 of file WPathHelper.cpp.

References m_additionalModulePaths.

◆ getAllFonts()

WPathHelper::Fonts WPathHelper::getAllFonts ( )
static

◆ getAllModulePaths()

std::vector< boost::filesystem::path > WPathHelper::getAllModulePaths ( )
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.

Returns
list of search paths for modules

Definition at line 173 of file WPathHelper.cpp.

References getHomePath(), getModulePath(), getPathHelper(), and m_additionalModulePaths.

Referenced by WModuleLoader::load().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAppPath()

boost::filesystem::path WPathHelper::getAppPath ( )
static

◆ getConfigPath()

boost::filesystem::path WPathHelper::getConfigPath ( )
static

The path where the config files reside in.

Returns
the config file path.

Definition at line 144 of file WPathHelper.cpp.

References getPathHelper().

+ Here is the call graph for this function:

◆ getDocPath()

boost::filesystem::path WPathHelper::getDocPath ( )
static

The path where the doc files reside in.

Returns
the doc file path.

Definition at line 139 of file WPathHelper.cpp.

References getPathHelper().

Referenced by WMainWindow::openAboutDialog(), WMainWindow::openOpenWalnutHelpDialog(), and WMainWindow::showWelcomeDialog().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFontPath()

boost::filesystem::path WPathHelper::getFontPath ( )
static

The path where font files reside in.

Returns
the font path.

Definition at line 98 of file WPathHelper.cpp.

References getPathHelper().

Referenced by getAllFonts().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHomePath()

boost::filesystem::path WPathHelper::getHomePath ( )
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.

Returns
OW home path

Definition at line 124 of file WPathHelper.cpp.

References getPathHelper().

Referenced by WQtModuleConfig::addModulePath(), getAllModulePaths(), WFilterPropertyHandler::getParticleNameFilePath(), WMWriteCSV::properties(), WQtGui::run(), and WScriptUI::run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLibPath()

boost::filesystem::path WPathHelper::getLibPath ( )
static

The path to the OW libs.

You normally should not need this.

Returns
the path to the libs.

Definition at line 129 of file WPathHelper.cpp.

References getPathHelper().

+ Here is the call graph for this function:

◆ getModulePath()

boost::filesystem::path WPathHelper::getModulePath ( )
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().

Returns
path to globally installed modules.

Definition at line 119 of file WPathHelper.cpp.

References getPathHelper().

Referenced by getAllModulePaths().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getModuleResourcePath()

boost::filesystem::path WPathHelper::getModuleResourcePath ( boost::filesystem::path  moduleLibPath,
std::string  packageName 
)
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.

Parameters
moduleLibPaththe 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
packageNamethe name of the resource. This is usually the package name.
Returns
the absolute path for the given module path.

Definition at line 149 of file WPathHelper.cpp.

References getPathHelper().

Referenced by WModuleLoader::load().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPathHelper()

std::shared_ptr< WPathHelper > WPathHelper::getPathHelper ( )
static

Returns instance of the path helper.

If it does not exists, it will be created.

Returns
the running path helper instance.

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getShaderPath()

boost::filesystem::path WPathHelper::getShaderPath ( )
static

The path to the global shaders.

Modules usually have their own local shader directory.

Returns
global shader path.

Definition at line 103 of file WPathHelper.cpp.

References getPathHelper().

Referenced by WGEShader::processShaderRecursive().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSharePath()

boost::filesystem::path WPathHelper::getSharePath ( )
static

The path where shared files reside in.

Returns
the shared files path.

Definition at line 134 of file WPathHelper.cpp.

References getPathHelper().

Referenced by WGEViewerEffectImageOverlay::WGEViewerEffectImageOverlay().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setBasePaths()

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.

Parameters
appPaththe application path
homePaththe 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().

+ Here is the caller graph for this function:

◆ 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.

Parameters
appPaththe application path
homePaththe 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().

+ Here is the call graph for this function:

Member Data Documentation

◆ m_additionalModulePaths

std::vector< boost::filesystem::path > WPathHelper::m_additionalModulePaths
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().

◆ m_appPath

boost::filesystem::path WPathHelper::m_appPath
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().

◆ m_configPath

boost::filesystem::path WPathHelper::m_configPath
private

The path where all the config files reside in.

Definition at line 233 of file WPathHelper.h.

Referenced by setBasePaths(), and setBasePathsOSXBundle().

◆ m_docPath

boost::filesystem::path WPathHelper::m_docPath
private

The path where all the documentation files reside in.

Definition at line 228 of file WPathHelper.h.

Referenced by setBasePaths(), and setBasePathsOSXBundle().

◆ m_homePath

boost::filesystem::path WPathHelper::m_homePath
private

The path of a user specific OW directory.

Definition at line 248 of file WPathHelper.h.

Referenced by setBasePaths().

◆ m_instance

std::shared_ptr< WPathHelper > WPathHelper::m_instance = std::shared_ptr< WPathHelper >()
staticprivate

Singleton instance of WPathHelper.

Definition at line 264 of file WPathHelper.h.

Referenced by getPathHelper().

◆ m_libPath

boost::filesystem::path WPathHelper::m_libPath
private

The path to the OW libs.

Definition at line 243 of file WPathHelper.h.

Referenced by setBasePaths().

◆ m_modulePath

boost::filesystem::path WPathHelper::m_modulePath
private

The path to the globally installed modules.

Definition at line 238 of file WPathHelper.h.

Referenced by setBasePaths(), and setBasePathsOSXBundle().

◆ m_moduleResourcePathRelative

boost::filesystem::path WPathHelper::m_moduleResourcePathRelative
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().

◆ m_sharePath

boost::filesystem::path WPathHelper::m_sharePath
private

The path where all the shared files reside in.

Definition at line 223 of file WPathHelper.h.

Referenced by setBasePaths(), and setBasePathsOSXBundle().


The documentation for this class was generated from the following files: