Mantid
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
Mantid::Kernel::ConfigServiceImpl Class Referencefinal

The ConfigService class provides a simple facade to access the Configuration functionality of the Mantid Framework. More...

#include <ConfigService.h>

Classes

class  ConfigServiceNotification
 This is the base class for POCO Notifications sent out from the Config Service. More...
 
class  ValueChanged
 This is the class for the notification that is to be sent when a value has been changed in config service. More...
 

Public Member Functions

std::vector< std::string > getKeys (const std::string &keyName) const
 Searches for a key in the configuration property. More...
 
std::string getLocalFilename () const
 Return the local properties filename. More...
 
std::string getString (const std::string &keyName, bool pathAbsolute=true) const
 Searches for a configuration property. More...
 
std::string getUserFilename () const
 Return the user properties filename. More...
 
template<typename T >
boost::optional< T > getValue (const std::string &keyName)
 Searches for a string within the currently loaded configuration values and attempts to convert the values to the template type supplied. More...
 
template<>
boost::optional< bool > getValue (const std::string &keyName)
 Searches for a string within the currently loaded configuration values and attempts to convert the values to a boolean value. More...
 
bool hasProperty (const std::string &rootName) const
 Checks to see whether a key has a value assigned to it. More...
 
bool isExecutable (const std::string &target) const
 Checks to see whether the target passed is an executable file. More...
 
std::vector< std::string > keys () const
 Returns a list of all full keys in the config. More...
 
void launchProcess (const std::string &programFilePath, const std::vector< std::string > &programArguments) const
 Launches a process i.e opening a program. More...
 
void remove (const std::string &rootName)
 Removes the value from a selected keyName. More...
 
void reset ()
 Reset to "factory" settings. Removes current user properties. More...
 
void saveConfig (const std::string &filename) const
 Save the configuration to the user file. More...
 
void setBaseDirectory ()
 Setup the base directory. More...
 
void setString (const std::string &key, const std::string &value)
 Sets a configuration property. More...
 
void updateConfig (const std::string &filename, const bool append=false, const bool update_caches=true)
 Wipe out the current configuration and load a new one. More...
 
Host information
std::string getEnvironment (const std::string &keyName)
 Searches for the given environment variable and returns it as a string. More...
 
std::string getOSName ()
 Returns the OS name. More...
 
std::string getComputerName ()
 Returns the computer name. More...
 
std::string getOSArchitecture ()
 Returns the architecture. More...
 
std::string getOSVersion ()
 Returns the OS version. More...
 
std::string getOSVersionReadable ()
 Returns a human readable version of the OS version. More...
 
std::string getUsername ()
 Returns the username. More...
 
std::string getCurrentDir ()
 Returns the current directory. More...
 
std::string getCurrentDir () const
 Returns the current directory. More...
 
std::string getTempDir ()
 Returns the system's temp directory. More...
 
std::string getAppDataDir ()
 Returns the system's appdata directory. More...
 
std::string getDirectoryOfExecutable () const
 Get the directory containing the program executable. More...
 
std::string getPathToExecutable () const
 Get the full path to the executing program (i.e. More...
 
bool isNetworkDrive (const std::string &path)
 Check if the path is on a network drive. More...
 
std::string getPropertiesDir () const
 Returns the directory where the Mantid.properties file is found. More...
 
std::string getUserPropertiesDir () const
 Returns a directory to use to write out Mantid information. More...
 

Search paths handling

struct Mantid::Kernel::CreateUsingNew< ConfigServiceImpl >
 
Poco::NotificationCenter m_notificationCenter
 Handles distribution of Poco signals. More...
 
Poco::AutoPtr< Poco::Util::PropertyFileConfiguration > m_pConf
 the POCO file config object More...
 
Poco::AutoPtr< Poco::Util::SystemConfiguration > m_pSysConfig
 the POCO system Config Object More...
 
std::set< std::string > m_changed_keys
 A set of property keys that have been changed. More...
 
std::string m_strBaseDir
 The directory that is considered to be the base directory. More...
 
std::string m_propertyString
 The configuration properties in string format. More...
 
const std::string m_properties_file_name
 The filename of the Mantid properties file. More...
 
const std::string m_user_properties_file_name
 The filename of the Mantid user properties file. More...
 
std::vector< std::string > m_dataSearchDirs
 Store a list of data search paths. More...
 
std::vector< std::string > m_instrumentDirs
 Store a list of instrument directory paths. More...
 
std::vector< FacilityInfo * > m_facilities
 The list of available facilities. More...
 
std::set< std::string > m_configPaths
 List of config paths that may be relative. More...
 
Kernel::ProxyInfo m_proxyInfo
 local cache of proxy details More...
 
bool m_isProxySet
 whether the proxy has been populated yet More...
 
const std::vector< std::string > & getDataSearchDirs () const
 Get the list of search paths. More...
 
void setDataSearchDirs (const std::vector< std::string > &searchDirs)
 Set a list of search paths via a vector. More...
 
void setDataSearchDirs (const std::string &searchDirs)
 Set a list of search paths via a string. More...
 
void appendDataSearchDir (const std::string &path)
 Adds the passed path to the end of the list of data search paths. More...
 
void appendDataSearchSubDir (const std::string &subdir)
 Appends subdirectory to each of the specified data search directories. More...
 
void setInstrumentDirectories (const std::vector< std::string > &directories)
 Sets instrument directories. More...
 
const std::vector< std::string > & getInstrumentDirectories () const
 Get instrument search directories. More...
 
const std::string getInstrumentDirectory () const
 Get instrument search directory. More...
 
const std::string getVTPFileDirectory ()
 get the vtp file directory More...
 
void updateFacilities (const std::string &fName="")
 Load facility information from instrumentDir/Facilities.xml file. More...
 
const std::vector< FacilityInfo * > getFacilities () const
 Get the list of facilities. More...
 
const std::vector< std::string > getFacilityNames () const
 Get the list of facility names. More...
 
const FacilityInfogetFacility () const
 Get the default facility. More...
 
const FacilityInfogetFacility (const std::string &facilityName) const
 Get a facility. More...
 
void setFacility (const std::string &facilityName)
 Set the default facility. More...
 
void setLogLevel (int logLevel, bool quiet=false)
 Sets the log level priority for all log channels. More...
 
const InstrumentInfogetInstrument (const std::string &instrumentName="") const
 Look for an instrument. More...
 
void addObserver (const Poco::AbstractObserver &observer) const
 Add an observer for a notification. More...
 
void removeObserver (const Poco::AbstractObserver &observer) const
 Remove an observer. More...
 
void configureLogging ()
 Configures the Poco logging and starts it up. More...
 
Kernel::ProxyInfogetProxy (const std::string &url)
 Gets the proxy for the system. More...
 
std::string getFullPath (const std::string &filename, const bool ignoreDirs, const int options) const
 
 ConfigServiceImpl ()
 Private constructor for singleton class. More...
 
 ConfigServiceImpl (const ConfigServiceImpl &)
 Private copy constructor. Prevents singleton being copied. More...
 
virtual ~ConfigServiceImpl ()
 Private Destructor Prevents client from calling 'delete' on the pointer handed out by Instance. More...
 
void loadConfig (const std::string &filename, const bool append=false)
 Loads a config file. More...
 
bool readFile (const std::string &filename, std::string &contents) const
 Read a file and place its contents into the given string. More...
 
void createUserPropertiesFile () const
 Writes out a fresh user properties file. More...
 
std::string makeAbsolute (const std::string &dir, const std::string &key) const
 Make a relative path or a list of relative paths into an absolute one. More...
 
void cacheDataSearchPaths ()
 Create the storage of the data search directories. More...
 
void cacheInstrumentPaths ()
 Create the storage of the instrument directories. More...
 
bool isInDataSearchList (const std::string &path) const
 Returns true if the path is in the data search list. More...
 
void clearFacilities ()
 Empty the list of facilities, deleting the FacilityInfo objects in the process. More...
 
const std::vector< std::string > getFacilityFilenames (const std::string &fName)
 Determine the name of the facilities file to use. More...
 
bool addDirectoryifExists (const std::string &directoryName, std::vector< std::string > &directoryList)
 Verifies the directory exists and add it to the back of the directory list if valid. More...
 
void getKeysRecursive (const std::string &root, std::vector< std::string > &allKeys) const
 Returns a list of all keys under a given root key. More...
 

Detailed Description

The ConfigService class provides a simple facade to access the Configuration functionality of the Mantid Framework.

The class gathers information from config files and the system variables. This information is available to all the objects within the framework as well as being used to configure the logging framework. This class currently uses the Logging functionality provided through the POCO (portable components library).

Author
Nicholas Draper, Tessella Support Services plc
Date
15/10/2007

Definition at line 63 of file ConfigService.h.

Constructor & Destructor Documentation

◆ ConfigServiceImpl() [1/2]

Mantid::Kernel::ConfigServiceImpl::ConfigServiceImpl ( )
private

◆ ConfigServiceImpl() [2/2]

Mantid::Kernel::ConfigServiceImpl::ConfigServiceImpl ( const ConfigServiceImpl )
private

Private copy constructor. Prevents singleton being copied.

◆ ~ConfigServiceImpl()

Mantid::Kernel::ConfigServiceImpl::~ConfigServiceImpl ( )
privatevirtual

Private Destructor Prevents client from calling 'delete' on the pointer handed out by Instance.

Definition at line 222 of file ConfigService.cpp.

References clearFacilities(), and Mantid::Kernel::Logger::shutdown().

Member Function Documentation

◆ addDirectoryifExists()

bool Mantid::Kernel::ConfigServiceImpl::addDirectoryifExists ( const std::string &  directoryName,
std::vector< std::string > &  directoryList 
)
private

Verifies the directory exists and add it to the back of the directory list if valid.

Parameters
directoryNamethe directory name to add
directoryListthe list to add the directory to
Returns
true if the directory was valid and added to the list

Definition at line 1531 of file ConfigService.cpp.

References Mantid::Kernel::DateAndTimeHelpers::g_log, and Mantid::Kernel::Logger::information().

Referenced by cacheInstrumentPaths().

◆ addObserver()

void Mantid::Kernel::ConfigServiceImpl::addObserver ( const Poco::AbstractObserver &  observer) const

Add an observer for a notification.

Add an observer to a notification.

Parameters
observer:: Reference to the observer to add

Definition at line 1794 of file ConfigService.cpp.

References m_notificationCenter.

Referenced by MantidQt::MantidWidgets::InstrumentSelector::InstrumentSelector().

◆ appendDataSearchDir()

void Mantid::Kernel::ConfigServiceImpl::appendDataSearchDir ( const std::string &  path)

Adds the passed path to the end of the list of data search paths.

Adds the passed path to the end of the list of data search paths the path name must be absolute.

Parameters
path:: the absolute path to add

Definition at line 1436 of file ConfigService.cpp.

References isInDataSearchList(), Mantid::Kernel::Strings::join(), m_dataSearchDirs, and setString().

Referenced by export_ConfigService(), setString(), and updateConfig().

◆ appendDataSearchSubDir()

void Mantid::Kernel::ConfigServiceImpl::appendDataSearchSubDir ( const std::string &  subdir)

Appends subdirectory to each of the specified data search directories.

Appends the passed subdirectory path to the end of each of data search dirs and adds these new dirs to data search directories.

Parameters
subdir:: the subdirectory path to add (relative)

Definition at line 1399 of file ConfigService.cpp.

References m_dataSearchDirs, and setDataSearchDirs().

Referenced by export_ConfigService().

◆ cacheDataSearchPaths()

void Mantid::Kernel::ConfigServiceImpl::cacheDataSearchPaths ( )
private

Create the storage of the data search directories.

Create the store of data search paths from the 'datasearch.directories' key within the Mantid.properties file.

The value of the key should be a semi-colon separated list of directories

Definition at line 480 of file ConfigService.cpp.

References getString(), and m_dataSearchDirs.

Referenced by setString(), and updateConfig().

◆ cacheInstrumentPaths()

void Mantid::Kernel::ConfigServiceImpl::cacheInstrumentPaths ( )
private

Create the storage of the instrument directories.

Fills the internal cache of instrument definition directories and creates The appdata%/mantidproject/mantid or $home/.mantid directory.

This will normally contain from Index 0

  • The download directory (win appdata%/mantidproject/mantid/instrument) (linux $home/.mantid/instrument )
  • The user instrument area /etc/mantid/instrument (not on windows)
  • The install directory/instrument

Definition at line 1500 of file ConfigService.cpp.

References addDirectoryifExists(), getAppDataDir(), getPropertiesDir(), getString(), and m_instrumentDirs.

Referenced by ConfigServiceImpl(), setString(), and updateConfig().

◆ clearFacilities()

void Mantid::Kernel::ConfigServiceImpl::clearFacilities ( )
private

Empty the list of facilities, deleting the FacilityInfo objects in the process.

Definition at line 1672 of file ConfigService.cpp.

References m_facilities.

Referenced by updateFacilities(), and ~ConfigServiceImpl().

◆ configureLogging()

void Mantid::Kernel::ConfigServiceImpl::configureLogging ( )

Configures the Poco logging and starts it up.

Definition at line 396 of file ConfigService.cpp.

References m_pConf.

Referenced by setString(), and updateConfig().

◆ createUserPropertiesFile()

void Mantid::Kernel::ConfigServiceImpl::createUserPropertiesFile ( ) const
private

Writes out a fresh user properties file.

writes a basic placeholder user.properties file to disk any errors are caught and logged, but not propagated

Definition at line 511 of file ConfigService.cpp.

References Mantid::Kernel::DateAndTimeHelpers::g_log, getUserPropertiesDir(), m_user_properties_file_name, and Mantid::Kernel::Logger::warning().

Referenced by loadConfig(), and reset().

◆ getAppDataDir()

std::string Mantid::Kernel::ConfigServiceImpl::getAppDataDir ( )

Returns the system's appdata directory.

Gets the absolute path of the appdata directory.

Returns
The absolute path of the appdata directory

Definition at line 1205 of file ConfigService.cpp.

Referenced by cacheInstrumentPaths(), ConfigServiceImpl(), export_ConfigService(), and getVTPFileDirectory().

◆ getComputerName()

std::string Mantid::Kernel::ConfigServiceImpl::getComputerName ( )

Returns the computer name.

Gets the name of the operating system Architecture.

Returns
The operating system architecture

Definition at line 1014 of file ConfigService.cpp.

References m_pSysConfig.

Referenced by ConfigServiceImpl().

◆ getCurrentDir() [1/2]

std::string Mantid::Kernel::ConfigServiceImpl::getCurrentDir ( )

Returns the current directory.

Gets the absolute path of the current directory containing the dll.

Returns
The absolute path of the current directory containing the dll

Definition at line 1186 of file ConfigService.cpp.

References m_pSysConfig.

◆ getCurrentDir() [2/2]

std::string Mantid::Kernel::ConfigServiceImpl::getCurrentDir ( ) const

Returns the current directory.

Gets the absolute path of the current directory containing the dll.

Const version.

Returns
The absolute path of the current directory containing the dll

Definition at line 1193 of file ConfigService.cpp.

References m_pSysConfig.

◆ getDataSearchDirs()

const std::vector< std::string > & Mantid::Kernel::ConfigServiceImpl::getDataSearchDirs ( ) const

Get the list of search paths.

Return the list of search paths.

Returns
A vector of strings containing the defined search directories

Definition at line 1374 of file ConfigService.cpp.

References m_dataSearchDirs.

Referenced by export_ConfigService(), and getFullPath().

◆ getDirectoryOfExecutable()

std::string Mantid::Kernel::ConfigServiceImpl::getDirectoryOfExecutable ( ) const

Get the directory containing the program executable.

Returns
A string containing the path of the directory containing the executable, including a trailing slash

Definition at line 1227 of file ConfigService.cpp.

References getPathToExecutable().

Referenced by setBaseDirectory().

◆ getEnvironment()

std::string Mantid::Kernel::ConfigServiceImpl::getEnvironment ( const std::string &  keyName)

Searches for the given environment variable and returns it as a string.

Searches for the string within the environment variables and returns the value as a string.

Parameters
keyName:: The name of the environment variable that you need the value of.
Returns
The string value of the property

Definition at line 994 of file ConfigService.cpp.

References m_pSysConfig.

◆ getFacilities()

const std::vector< FacilityInfo * > Mantid::Kernel::ConfigServiceImpl::getFacilities ( ) const

Get the list of facilities.

Gets a vector of the facility Information objects.

Returns
A vector of FacilityInfo objects

Definition at line 1719 of file ConfigService.cpp.

References m_facilities.

Referenced by export_ConfigService(), and Mantid::Kernel::MultiFileNameParsing::Parser::Parser().

◆ getFacility() [1/2]

const FacilityInfo & Mantid::Kernel::ConfigServiceImpl::getFacility ( ) const

Get the default facility.

Returns
the facility information object

Definition at line 1735 of file ConfigService.cpp.

References getFacility(), and getString().

Referenced by export_ConfigService(), MantidQt::MantidWidgets::InstrumentSelector::fillWithInstrumentsFromFacility(), getFacility(), getInstrument(), and setFacility().

◆ getFacility() [2/2]

const FacilityInfo & Mantid::Kernel::ConfigServiceImpl::getFacility ( const std::string &  facilityName) const

Get a facility.

Parameters
facilityName:: Facility name
Returns
the facility information object
Exceptions
NotFoundExceptionif the facility is not found

Definition at line 1749 of file ConfigService.cpp.

References getFacility(), and m_facilities.

◆ getFacilityFilenames()

const std::vector< std::string > Mantid::Kernel::ConfigServiceImpl::getFacilityFilenames ( const std::string &  fName)
private

Determine the name of the facilities file to use.

Definition at line 1550 of file ConfigService.cpp.

References getInstrumentDirectories(), and getString().

Referenced by updateFacilities().

◆ getFacilityNames()

const std::vector< std::string > Mantid::Kernel::ConfigServiceImpl::getFacilityNames ( ) const

Get the list of facility names.

Gets a vector of the facility names.

Returns
A vector of the facility Names

Definition at line 1724 of file ConfigService.cpp.

References m_facilities.

Referenced by export_ConfigService(), and MantidQt::MantidWidgets::InstrumentSelector::fillWithInstrumentsFromFacility().

◆ getFullPath()

std::string Mantid::Kernel::ConfigServiceImpl::getFullPath ( const std::string &  filename,
const bool  ignoreDirs,
const int  options 
) const

◆ getInstrument()

const InstrumentInfo & Mantid::Kernel::ConfigServiceImpl::getInstrument ( const std::string &  instrumentName = "") const

Look for an instrument.

Returns instruments with given name.

Parameters
instrumentNameInstrument name
Returns
the instrument information object
Exceptions
NotFoundErrorif iName was not found

Definition at line 1685 of file ConfigService.cpp.

References Mantid::Kernel::Logger::debug(), Mantid::Kernel::DateAndTimeHelpers::g_log, getFacility(), Mantid::Kernel::FacilityInfo::instrument(), m_facilities, and Mantid::Kernel::FacilityInfo::name().

◆ getInstrumentDirectories()

const std::vector< std::string > & Mantid::Kernel::ConfigServiceImpl::getInstrumentDirectories ( ) const

Get instrument search directories.

Return the search directories for XML instrument definition files (IDFs)

Returns
An ordered list of paths for instrument searching

Definition at line 1466 of file ConfigService.cpp.

References m_instrumentDirs.

Referenced by export_ConfigService(), getFacilityFilenames(), getFullPath(), and Mantid::API::InstrumentFileFinder::getParameterPath().

◆ getInstrumentDirectory()

const std::string Mantid::Kernel::ConfigServiceImpl::getInstrumentDirectory ( ) const

Get instrument search directory.

Return the base search directories for XML instrument definition files (IDFs)

Returns
a last entry of getInstrumentDirectories

Definition at line 1472 of file ConfigService.cpp.

References m_instrumentDirs.

Referenced by export_ConfigService().

◆ getKeys()

std::vector< std::string > Mantid::Kernel::ConfigServiceImpl::getKeys ( const std::string &  keyName) const

Searches for a key in the configuration property.

Searches for keys within the currently loaded configuaration values and returns them as strings in a vector.

Parameters
keyName:: The case sensitive name of the property that you need the key for.
Returns
The string value of each key within a vector, or an empty vector if there isn't a key or it couldn't be found.

Definition at line 784 of file ConfigService.cpp.

References m_pConf.

Referenced by getKeysRecursive().

◆ getKeysRecursive()

void Mantid::Kernel::ConfigServiceImpl::getKeysRecursive ( const std::string &  root,
std::vector< std::string > &  allKeys 
) const
private

Returns a list of all keys under a given root key.

Recursively gets a list of all config options from a given root node.

Returns
Vector containing all config options

Definition at line 795 of file ConfigService.cpp.

References getKeys(), and getKeysRecursive().

Referenced by getKeysRecursive(), and keys().

◆ getLocalFilename()

std::string Mantid::Kernel::ConfigServiceImpl::getLocalFilename ( ) const

Return the local properties filename.

Return the full filename of the local properties file.

Returns
A string containing the full path to the local file.

Definition at line 973 of file ConfigService.cpp.

Referenced by ConfigServiceImpl(), and export_ConfigService().

◆ getOSArchitecture()

std::string Mantid::Kernel::ConfigServiceImpl::getOSArchitecture ( )

Returns the architecture.

Gets the name of the computer running Mantid.

Returns
The name of the computer

Definition at line 1008 of file ConfigService.cpp.

References m_pSysConfig.

◆ getOSName()

std::string Mantid::Kernel::ConfigServiceImpl::getOSName ( )

Returns the OS name.

Gets the name of the host operating system.

Returns
The name pf the OS version

Definition at line 1002 of file ConfigService.cpp.

References m_pSysConfig.

◆ getOSVersion()

std::string Mantid::Kernel::ConfigServiceImpl::getOSVersion ( )

Returns the OS version.

Gets the name of the operating system version.

Returns
The operating system version

Definition at line 1020 of file ConfigService.cpp.

References m_pSysConfig.

◆ getOSVersionReadable()

std::string Mantid::Kernel::ConfigServiceImpl::getOSVersionReadable ( )

Returns a human readable version of the OS version.

Gets the name of the operating system version in a human readable form.

Returns
The operating system desciption

Definition at line 1055 of file ConfigService.cpp.

References Mantid::Kernel::canRead(), Mantid::Kernel::Logger::debug(), Mantid::Kernel::DateAndTimeHelpers::g_log, Mantid::Kernel::getValueFromStdOut(), and UNUSED_ARG.

◆ getPathToExecutable()

std::string Mantid::Kernel::ConfigServiceImpl::getPathToExecutable ( ) const

Get the full path to the executing program (i.e.

whatever Mantid is embedded in)

Returns
A string containing the full path the the executable

Definition at line 1236 of file ConfigService.cpp.

Referenced by getDirectoryOfExecutable().

◆ getPropertiesDir()

std::string Mantid::Kernel::ConfigServiceImpl::getPropertiesDir ( ) const

Returns the directory where the Mantid.properties file is found.

Gets the directory that we consider to be the directory containing the Mantid.properties file.

Basically, this is the either the directory pointed to by MANTIDPATH or the directory of the current executable if this is not set.

Returns
The directory to consider as the base directory, including a trailing slash

Definition at line 1349 of file ConfigService.cpp.

References m_strBaseDir.

Referenced by cacheInstrumentPaths(), ConfigServiceImpl(), export_ConfigService(), makeAbsolute(), and reset().

◆ getProxy()

Kernel::ProxyInfo & Mantid::Kernel::ConfigServiceImpl::getProxy ( const std::string &  url)

Gets the proxy for the system.

Definition at line 1810 of file ConfigService.cpp.

References Mantid::Kernel::NetworkProxy::getHttpProxy(), m_isProxySet, and m_proxyInfo.

◆ getString()

std::string Mantid::Kernel::ConfigServiceImpl::getString ( const std::string &  keyName,
bool  pathAbsolute = true 
) const

Searches for a configuration property.

Searches for a string within the currently loaded configuaration values and returns the value as a string.

If the key is one of those that was a possible relative path then the local store is searched first.

Parameters
keyName:: The case sensitive name of the property that you need the value of.
pathAbsolute:: If true then any key that looks like it contains a path has this path converted to an absolute path.
Returns
The string value of the property, or an empty string if the key cannot be found

Definition at line 761 of file ConfigService.cpp.

References Mantid::Kernel::Logger::debug(), Mantid::Kernel::DateAndTimeHelpers::g_log, m_configPaths, m_pConf, makeAbsolute(), and value.

Referenced by cacheDataSearchPaths(), cacheInstrumentPaths(), export_ConfigService(), getFacility(), getFacilityFilenames(), getValue(), getVTPFileDirectory(), MantidQt::API::RepoModel::RepoModel(), saveConfig(), setString(), and updateConfig().

◆ getTempDir()

std::string Mantid::Kernel::ConfigServiceImpl::getTempDir ( )

Returns the system's temp directory.

Gets the absolute path of the temp directory.

Returns
The absolute path of the temp directory

Definition at line 1199 of file ConfigService.cpp.

References m_pSysConfig.

◆ getUserFilename()

std::string Mantid::Kernel::ConfigServiceImpl::getUserFilename ( ) const

Return the user properties filename.

Return the full filename of the user properties file.

Returns
A string containing the full path to the user file

Definition at line 985 of file ConfigService.cpp.

References getUserPropertiesDir(), and m_user_properties_file_name.

Referenced by ConfigServiceImpl(), export_ConfigService(), and reset().

◆ getUsername()

std::string Mantid::Kernel::ConfigServiceImpl::getUsername ( )

Returns the username.

Returns
The name of the current user as reported by the environment.

Definition at line 1155 of file ConfigService.cpp.

References m_pSysConfig, and UNUSED_ARG.

◆ getUserPropertiesDir()

std::string Mantid::Kernel::ConfigServiceImpl::getUserPropertiesDir ( ) const

Returns a directory to use to write out Mantid information.

Return the directory that Mantid should use for writing any files it needs so that this is kept separated to user saved files.

Needs to be writable

A trailing slash is appended so that filenames can more easily be concatenated with this

Returns
the directory that Mantid should use for writing files

Definition at line 1358 of file ConfigService.cpp.

References m_pSysConfig, and m_strBaseDir.

Referenced by createUserPropertiesFile(), export_ConfigService(), getUserFilename(), and loadConfig().

◆ getValue() [1/2]

template<typename T >
boost::optional< T > Mantid::Kernel::ConfigServiceImpl::getValue ( const std::string &  keyName)

Searches for a string within the currently loaded configuration values and attempts to convert the values to the template type supplied.

Parameters
keyName:: The case sensitive name of the property that you need the value of.
Returns
An optional container with the value if found

Definition at line 930 of file ConfigService.cpp.

References Mantid::Kernel::Strings::convert(), and getString().

◆ getValue() [2/2]

template<>
boost::optional< bool > Mantid::Kernel::ConfigServiceImpl::getValue ( const std::string &  keyName)

Searches for a string within the currently loaded configuration values and attempts to convert the values to a boolean value.

Parameters
keyName:: The case sensitive name of the property that you need the value of.
Returns
An optional container with the value if found

Definition at line 949 of file ConfigService.cpp.

◆ getVTPFileDirectory()

const std::string Mantid::Kernel::ConfigServiceImpl::getVTPFileDirectory ( )

get the vtp file directory

Return the search directory for vtp files.

Returns
a path

Definition at line 1477 of file ConfigService.cpp.

References getAppDataDir(), and getString().

Referenced by ConfigServiceImpl().

◆ hasProperty()

bool Mantid::Kernel::ConfigServiceImpl::hasProperty ( const std::string &  rootName) const

Checks to see whether a key has a value assigned to it.

Checks to see whether the given key exists.

Parameters
rootName:: The case sensitive key that you are looking to see if exists.
Returns
Boolean value denoting whether the exists or not.

Definition at line 846 of file ConfigService.cpp.

References m_pConf.

Referenced by export_ConfigService(), and saveConfig().

◆ isExecutable()

bool Mantid::Kernel::ConfigServiceImpl::isExecutable ( const std::string &  target) const

Checks to see whether the target passed is an executable file.

Checks to see whether the given file target is an executable one and it exists.

This method will expand environment variables found in the given file path.

Parameters
target:: The path to the file you wish to see whether it's an executable.
Returns
Boolean value denoting whether the file is an executable or not.

Definition at line 856 of file ConfigService.cpp.

◆ isInDataSearchList()

bool Mantid::Kernel::ConfigServiceImpl::isInDataSearchList ( const std::string &  path) const
private

Returns true if the path is in the data search list.

The path that is passed should be as returned by makeAbsolute() and this function will return true if that path is in the list.

Parameters
path:: the absolute path name to search for
Returns
true if the path was found

Definition at line 495 of file ConfigService.cpp.

References m_dataSearchDirs.

Referenced by appendDataSearchDir().

◆ isNetworkDrive()

bool Mantid::Kernel::ConfigServiceImpl::isNetworkDrive ( const std::string &  path)

Check if the path is on a network drive.

Parameters
path:: The path to be checked
Returns
True if the path is on a network drive.

Definition at line 1268 of file ConfigService.cpp.

◆ keys()

std::vector< std::string > Mantid::Kernel::ConfigServiceImpl::keys ( ) const

Returns a list of all full keys in the config.

Recursively gets a list of all config options.

This function is needed as Boost Python does not like calling function with default arguments.

Returns
Vector containing all config options

Definition at line 821 of file ConfigService.cpp.

References getKeysRecursive().

Referenced by export_ConfigService().

◆ launchProcess()

void Mantid::Kernel::ConfigServiceImpl::launchProcess ( const std::string &  programFilePath,
const std::vector< std::string > &  programArguments 
) const

Launches a process i.e opening a program.

Runs a command line string to open a program.

The function can take program arguments. i.e it can load in a file to the program on startup.

This method will expand environment variables found in the given file path.

Parameters
programFilePath:: The directory where the program is located.
programArguments:: The arguments that the program can take on startup. For example, the file to load up.

Definition at line 882 of file ConfigService.cpp.

◆ loadConfig()

void Mantid::Kernel::ConfigServiceImpl::loadConfig ( const std::string &  filename,
const bool  append = false 
)
private

Loads a config file.

Loads the config file provided.

If the file contains logging setup instructions then these will be used to setup the logging framework.

Parameters
filename:: The filename and optionally path of the file to load
append:: If false (default) then any previous configuration is discarded, otherwise the new keys are added, and repeated keys will override existing ones.

Definition at line 326 of file ConfigService.cpp.

References createUserPropertiesFile(), Mantid::Kernel::Logger::error(), Mantid::Kernel::DateAndTimeHelpers::g_log, getUserPropertiesDir(), m_changed_keys, m_pConf, m_propertyString, m_user_properties_file_name, and readFile().

Referenced by updateConfig().

◆ makeAbsolute()

std::string Mantid::Kernel::ConfigServiceImpl::makeAbsolute ( const std::string &  dir,
const std::string &  key 
) const
private

Make a relative path or a list of relative paths into an absolute one.

Parameters
dir:: The directory to convert
key:: The key variable this relates to
Returns
A string containing an absolute path by resolving the relative directory with the executable directory

Definition at line 417 of file ConfigService.cpp.

References Mantid::Kernel::DateAndTimeHelpers::g_log, getPropertiesDir(), makeAbsolute(), and Mantid::Kernel::Logger::warning().

Referenced by getString(), and makeAbsolute().

◆ readFile()

bool Mantid::Kernel::ConfigServiceImpl::readFile ( const std::string &  filename,
std::string &  contents 
) const
private

Read a file and place its contents into the given string.

Parameters
filename:: The filename of the file to read
contents:: The file contents will be placed here
Returns
A boolean indicating whether opening the file was successful

Definition at line 376 of file ConfigService.cpp.

Referenced by loadConfig().

◆ remove()

void Mantid::Kernel::ConfigServiceImpl::remove ( const std::string &  rootName)

Removes the value from a selected keyName.

Removes a key from the memory stored properties file and inserts the key into the changed key list so that when the program calls saveConfig the properties file will be the same and not contain the key no more.

Parameters
rootName:: The key that is to be deleted

Definition at line 835 of file ConfigService.cpp.

References m_changed_keys, and m_pConf.

◆ removeObserver()

void Mantid::Kernel::ConfigServiceImpl::removeObserver ( const Poco::AbstractObserver &  observer) const

Remove an observer.

Parameters
observer:: Reference to the observer to remove

Definition at line 1801 of file ConfigService.cpp.

References m_notificationCenter.

◆ reset()

void Mantid::Kernel::ConfigServiceImpl::reset ( )

Reset to "factory" settings. Removes current user properties.

Removes the user properties file & loads a fresh configuration.

Definition at line 595 of file ConfigService.cpp.

References createUserPropertiesFile(), getPropertiesDir(), getUserFilename(), m_properties_file_name, and updateConfig().

Referenced by export_ConfigService().

◆ saveConfig()

void Mantid::Kernel::ConfigServiceImpl::saveConfig ( const std::string &  filename) const

Save the configuration to the user file.

Parameters
filename:: The filename for the saved configuration
Exceptions
std::runtime_errorif the file cannot be opened

Definition at line 648 of file ConfigService.cpp.

References Mantid::Kernel::Logger::error(), Mantid::Kernel::DateAndTimeHelpers::g_log, getString(), hasProperty(), m_changed_keys, and value.

Referenced by export_ConfigService().

◆ setBaseDirectory()

void Mantid::Kernel::ConfigServiceImpl::setBaseDirectory ( )

Setup the base directory.

Set the base directory path so we can file the Mantid.properties file.

This will search for the base directory that contains the .properties file by checking the following places:

  • The current working directory
  • The executable directory
  • The directory defined by the MANTIDPATH enviroment var
  • OSX only: the directory two directories up from the executable (which is the base on the OSX package.

Definition at line 239 of file ConfigService.cpp.

References getDirectoryOfExecutable(), m_properties_file_name, and m_strBaseDir.

Referenced by ConfigServiceImpl().

◆ setDataSearchDirs() [1/2]

void Mantid::Kernel::ConfigServiceImpl::setDataSearchDirs ( const std::string &  searchDirs)

Set a list of search paths via a string.

Parameters
searchDirs:: A string containing a list of search directories separated by a semi colon (;).

Definition at line 1390 of file ConfigService.cpp.

References setString().

◆ setDataSearchDirs() [2/2]

void Mantid::Kernel::ConfigServiceImpl::setDataSearchDirs ( const std::vector< std::string > &  searchDirs)

Set a list of search paths via a vector.

Parameters
searchDirs:: A list of search directories

Definition at line 1380 of file ConfigService.cpp.

References setDataSearchDirs().

Referenced by appendDataSearchSubDir(), and setDataSearchDirs().

◆ setFacility()

void Mantid::Kernel::ConfigServiceImpl::setFacility ( const std::string &  facilityName)

Set the default facility.

Parameters
facilityNamethe facility name
Exceptions
NotFoundExceptionif the facility is not found

Definition at line 1768 of file ConfigService.cpp.

References Mantid::Kernel::Logger::error(), Mantid::Kernel::DateAndTimeHelpers::g_log, getFacility(), Mantid::Kernel::FacilityInfo::instruments(), and setString().

Referenced by export_ConfigService().

◆ setInstrumentDirectories()

void Mantid::Kernel::ConfigServiceImpl::setInstrumentDirectories ( const std::vector< std::string > &  directories)

Sets instrument directories.

Sets the search directories for XML instrument definition files (IDFs)

Parameters
directoriesAn ordered list of paths for instrument searching

Definition at line 1458 of file ConfigService.cpp.

References m_instrumentDirs.

◆ setLogLevel()

void Mantid::Kernel::ConfigServiceImpl::setLogLevel ( int  logLevel,
bool  quiet = false 
)

Sets the log level priority for all log channels.

Sets the log level priority for all logging channels.

Parameters
logLevelthe integer value of the log level to set, 1=Critical, 7=Debug
quietIf true then no message regarding the level change is emitted

Definition at line 1887 of file ConfigService.cpp.

References Mantid::Kernel::DateAndTimeHelpers::g_log, Mantid::Kernel::Logger::log(), Mantid::Kernel::Logger::PriorityNames, and Mantid::Kernel::Logger::setLevelForAll().

Referenced by export_ConfigService().

◆ setString()

void Mantid::Kernel::ConfigServiceImpl::setString ( const std::string &  key,
const std::string &  value 
)

Sets a configuration property.

Set a configuration property.

An existing key will have its value updated.

Parameters
key:: The key to refer to this property
value:: The value of the property

Definition at line 897 of file ConfigService.cpp.

References appendDataSearchDir(), cacheDataSearchPaths(), cacheInstrumentPaths(), configureLogging(), getString(), m_changed_keys, m_notificationCenter, m_pConf, and value.

Referenced by appendDataSearchDir(), export_ConfigService(), setDataSearchDirs(), and setFacility().

◆ updateConfig()

void Mantid::Kernel::ConfigServiceImpl::updateConfig ( const std::string &  filename,
const bool  append = false,
const bool  update_caches = true 
)

Wipe out the current configuration and load a new one.

Updates and existing configuration and restarts the logging.

Parameters
filename:: The filename and optionally path of the file to load
append:: If false (default) then any previous configuration is discarded, otherwise the new keys are added, and repeated keys will override existing ones.
update_caches:: If true(default) then the various property caches are updated

Definition at line 619 of file ConfigService.cpp.

References appendDataSearchDir(), cacheDataSearchPaths(), cacheInstrumentPaths(), configureLogging(), getString(), and loadConfig().

Referenced by ConfigServiceImpl(), and reset().

◆ updateFacilities()

void Mantid::Kernel::ConfigServiceImpl::updateFacilities ( const std::string &  fName = "")

Load facility information from instrumentDir/Facilities.xml file.

Load facility information from instrumentDir/Facilities.xml file if fName parameter is not set.

If any of the steps fail, we cannot sensibly recover, because the Facilities.xml file is missing or corrupted.

Parameters
fName:: An alternative file name for loading facilities information.
Exceptions
std::runtime_error:: If the file is not found or fails to parse

Definition at line 1608 of file ConfigService.cpp.

References clearFacilities(), Mantid::Kernel::Logger::error(), Mantid::Kernel::DateAndTimeHelpers::g_log, getFacilityFilenames(), m_facilities, and n.

Referenced by ConfigServiceImpl(), and export_ConfigService().

Friends And Related Function Documentation

◆ Mantid::Kernel::CreateUsingNew< ConfigServiceImpl >

Definition at line 224 of file ConfigService.h.

Member Data Documentation

◆ m_changed_keys

std::set<std::string> Mantid::Kernel::ConfigServiceImpl::m_changed_keys
mutableprivate

A set of property keys that have been changed.

Definition at line 270 of file ConfigService.h.

Referenced by loadConfig(), remove(), saveConfig(), and setString().

◆ m_configPaths

std::set<std::string> Mantid::Kernel::ConfigServiceImpl::m_configPaths
private

List of config paths that may be relative.

Definition at line 289 of file ConfigService.h.

Referenced by ConfigServiceImpl(), and getString().

◆ m_dataSearchDirs

std::vector<std::string> Mantid::Kernel::ConfigServiceImpl::m_dataSearchDirs
private

Store a list of data search paths.

Definition at line 281 of file ConfigService.h.

Referenced by appendDataSearchDir(), appendDataSearchSubDir(), cacheDataSearchPaths(), getDataSearchDirs(), and isInDataSearchList().

◆ m_facilities

std::vector<FacilityInfo *> Mantid::Kernel::ConfigServiceImpl::m_facilities
private

The list of available facilities.

Definition at line 286 of file ConfigService.h.

Referenced by clearFacilities(), getFacilities(), getFacility(), getFacilityNames(), getInstrument(), and updateFacilities().

◆ m_instrumentDirs

std::vector<std::string> Mantid::Kernel::ConfigServiceImpl::m_instrumentDirs
private

Store a list of instrument directory paths.

Definition at line 283 of file ConfigService.h.

Referenced by cacheInstrumentPaths(), getInstrumentDirectories(), getInstrumentDirectory(), and setInstrumentDirectories().

◆ m_isProxySet

bool Mantid::Kernel::ConfigServiceImpl::m_isProxySet
private

whether the proxy has been populated yet

Definition at line 294 of file ConfigService.h.

Referenced by getProxy().

◆ m_notificationCenter

Poco::NotificationCenter Mantid::Kernel::ConfigServiceImpl::m_notificationCenter
mutableprivate

Handles distribution of Poco signals.

Definition at line 229 of file ConfigService.h.

Referenced by addObserver(), removeObserver(), and setString().

◆ m_pConf

Poco::AutoPtr<Poco::Util::PropertyFileConfiguration> Mantid::Kernel::ConfigServiceImpl::m_pConf
private

the POCO file config object

Definition at line 265 of file ConfigService.h.

Referenced by configureLogging(), getKeys(), getString(), hasProperty(), loadConfig(), remove(), and setString().

◆ m_properties_file_name

const std::string Mantid::Kernel::ConfigServiceImpl::m_properties_file_name
private

The filename of the Mantid properties file.

Definition at line 277 of file ConfigService.h.

Referenced by ConfigServiceImpl(), reset(), and setBaseDirectory().

◆ m_propertyString

std::string Mantid::Kernel::ConfigServiceImpl::m_propertyString
private

The configuration properties in string format.

Definition at line 275 of file ConfigService.h.

Referenced by loadConfig().

◆ m_proxyInfo

Kernel::ProxyInfo Mantid::Kernel::ConfigServiceImpl::m_proxyInfo
private

local cache of proxy details

Definition at line 292 of file ConfigService.h.

Referenced by getProxy().

◆ m_pSysConfig

Poco::AutoPtr<Poco::Util::SystemConfiguration> Mantid::Kernel::ConfigServiceImpl::m_pSysConfig
private

◆ m_strBaseDir

std::string Mantid::Kernel::ConfigServiceImpl::m_strBaseDir
private

The directory that is considered to be the base directory.

Definition at line 273 of file ConfigService.h.

Referenced by getPropertiesDir(), getUserPropertiesDir(), and setBaseDirectory().

◆ m_user_properties_file_name

const std::string Mantid::Kernel::ConfigServiceImpl::m_user_properties_file_name
private

The filename of the Mantid user properties file.

Definition at line 279 of file ConfigService.h.

Referenced by createUserPropertiesFile(), getUserFilename(), and loadConfig().


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