Mantid
|
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 FacilityInfo & | getFacility () const |
Get the default facility. More... | |
const FacilityInfo & | getFacility (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 InstrumentInfo & | getInstrument (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::ProxyInfo & | getProxy (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... | |
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).
Definition at line 63 of file ConfigService.h.
|
private |
Private constructor for singleton class.
Definition at line 117 of file ConfigService.cpp.
References cacheInstrumentPaths(), Mantid::Kernel::Logger::debug(), Mantid::Kernel::Logger::error(), Mantid::Kernel::DateAndTimeHelpers::g_log, getAppDataDir(), getComputerName(), getLocalFilename(), getPropertiesDir(), getUserFilename(), getVTPFileDirectory(), Mantid::Kernel::Logger::information(), m_configPaths, m_properties_file_name, Mantid::Kernel::MantidVersion::revision(), setBaseDirectory(), updateConfig(), updateFacilities(), and Mantid::Kernel::MantidVersion::version().
|
private |
Private copy constructor. Prevents singleton being copied.
|
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().
|
private |
Verifies the directory exists and add it to the back of the directory list if valid.
directoryName | the directory name to add |
directoryList | the list to add the directory to |
Definition at line 1531 of file ConfigService.cpp.
References Mantid::Kernel::DateAndTimeHelpers::g_log, and Mantid::Kernel::Logger::information().
Referenced by cacheInstrumentPaths().
void Mantid::Kernel::ConfigServiceImpl::addObserver | ( | const Poco::AbstractObserver & | observer | ) | const |
Add an observer for a notification.
Add an observer to a notification.
observer | :: Reference to the observer to add |
Definition at line 1794 of file ConfigService.cpp.
References m_notificationCenter.
Referenced by MantidQt::MantidWidgets::InstrumentSelector::InstrumentSelector().
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.
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().
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.
subdir | :: the subdirectory path to add (relative) |
Definition at line 1399 of file ConfigService.cpp.
References m_dataSearchDirs, and setDataSearchDirs().
Referenced by export_ConfigService().
|
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().
|
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
Definition at line 1500 of file ConfigService.cpp.
References addDirectoryifExists(), getAppDataDir(), getPropertiesDir(), getString(), and m_instrumentDirs.
Referenced by ConfigServiceImpl(), setString(), and updateConfig().
|
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().
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().
|
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().
std::string Mantid::Kernel::ConfigServiceImpl::getAppDataDir | ( | ) |
Returns the system's appdata directory.
Gets the absolute path of the appdata directory.
Definition at line 1205 of file ConfigService.cpp.
Referenced by cacheInstrumentPaths(), ConfigServiceImpl(), export_ConfigService(), and getVTPFileDirectory().
std::string Mantid::Kernel::ConfigServiceImpl::getComputerName | ( | ) |
Returns the computer name.
Gets the name of the operating system Architecture.
Definition at line 1014 of file ConfigService.cpp.
References m_pSysConfig.
Referenced by ConfigServiceImpl().
std::string Mantid::Kernel::ConfigServiceImpl::getCurrentDir | ( | ) |
Returns the current directory.
Gets the absolute path of the current directory containing the dll.
Definition at line 1186 of file ConfigService.cpp.
References m_pSysConfig.
std::string Mantid::Kernel::ConfigServiceImpl::getCurrentDir | ( | ) | const |
Returns the current directory.
Gets the absolute path of the current directory containing the dll.
Const version.
Definition at line 1193 of file ConfigService.cpp.
References m_pSysConfig.
const std::vector< std::string > & Mantid::Kernel::ConfigServiceImpl::getDataSearchDirs | ( | ) | const |
Get the list of search paths.
Return the list of search paths.
Definition at line 1374 of file ConfigService.cpp.
References m_dataSearchDirs.
Referenced by export_ConfigService(), and getFullPath().
std::string Mantid::Kernel::ConfigServiceImpl::getDirectoryOfExecutable | ( | ) | const |
Get the directory containing the program executable.
Definition at line 1227 of file ConfigService.cpp.
References getPathToExecutable().
Referenced by setBaseDirectory().
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.
keyName | :: The name of the environment variable that you need the value of. |
Definition at line 994 of file ConfigService.cpp.
References m_pSysConfig.
const std::vector< FacilityInfo * > Mantid::Kernel::ConfigServiceImpl::getFacilities | ( | ) | const |
Get the list of facilities.
Gets a vector of the facility Information objects.
Definition at line 1719 of file ConfigService.cpp.
References m_facilities.
Referenced by export_ConfigService(), and Mantid::Kernel::MultiFileNameParsing::Parser::Parser().
const FacilityInfo & Mantid::Kernel::ConfigServiceImpl::getFacility | ( | ) | const |
Get the default facility.
Definition at line 1735 of file ConfigService.cpp.
References getFacility(), and getString().
Referenced by export_ConfigService(), MantidQt::MantidWidgets::InstrumentSelector::fillWithInstrumentsFromFacility(), getFacility(), getInstrument(), and setFacility().
const FacilityInfo & Mantid::Kernel::ConfigServiceImpl::getFacility | ( | const std::string & | facilityName | ) | const |
Get a facility.
facilityName | :: Facility name |
NotFoundException | if the facility is not found |
Definition at line 1749 of file ConfigService.cpp.
References getFacility(), and m_facilities.
|
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().
const std::vector< std::string > Mantid::Kernel::ConfigServiceImpl::getFacilityNames | ( | ) | const |
Get the list of facility names.
Gets 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().
std::string Mantid::Kernel::ConfigServiceImpl::getFullPath | ( | const std::string & | filename, |
const bool | ignoreDirs, | ||
const int | options | ||
) | const |
Definition at line 1831 of file ConfigService.cpp.
References Mantid::Kernel::Logger::debug(), Mantid::Kernel::DateAndTimeHelpers::g_log, getDataSearchDirs(), getInstrumentDirectories(), Mantid::Kernel::Glob::glob(), and Mantid::Kernel::Strings::strip().
const InstrumentInfo & Mantid::Kernel::ConfigServiceImpl::getInstrument | ( | const std::string & | instrumentName = "" | ) | const |
Look for an instrument.
Returns instruments with given name.
instrumentName | Instrument name |
NotFoundError | if 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().
const std::vector< std::string > & Mantid::Kernel::ConfigServiceImpl::getInstrumentDirectories | ( | ) | const |
Get instrument search directories.
Return the search directories for XML instrument definition files (IDFs)
Definition at line 1466 of file ConfigService.cpp.
References m_instrumentDirs.
Referenced by export_ConfigService(), getFacilityFilenames(), getFullPath(), and Mantid::API::InstrumentFileFinder::getParameterPath().
const std::string Mantid::Kernel::ConfigServiceImpl::getInstrumentDirectory | ( | ) | const |
Get instrument search directory.
Return the base search directories for XML instrument definition files (IDFs)
Definition at line 1472 of file ConfigService.cpp.
References m_instrumentDirs.
Referenced by export_ConfigService().
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.
keyName | :: The case sensitive name of the property that you need the key for. |
Definition at line 784 of file ConfigService.cpp.
References m_pConf.
Referenced by getKeysRecursive().
|
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.
Definition at line 795 of file ConfigService.cpp.
References getKeys(), and getKeysRecursive().
Referenced by getKeysRecursive(), and keys().
std::string Mantid::Kernel::ConfigServiceImpl::getLocalFilename | ( | ) | const |
Return the local properties filename.
Return the full filename of the local properties file.
Definition at line 973 of file ConfigService.cpp.
Referenced by ConfigServiceImpl(), and export_ConfigService().
std::string Mantid::Kernel::ConfigServiceImpl::getOSArchitecture | ( | ) |
Returns the architecture.
Gets the name of the computer running Mantid.
Definition at line 1008 of file ConfigService.cpp.
References m_pSysConfig.
std::string Mantid::Kernel::ConfigServiceImpl::getOSName | ( | ) |
Returns the OS name.
Gets the name of the host operating system.
Definition at line 1002 of file ConfigService.cpp.
References m_pSysConfig.
std::string Mantid::Kernel::ConfigServiceImpl::getOSVersion | ( | ) |
Returns the OS version.
Gets the name of the operating system version.
Definition at line 1020 of file ConfigService.cpp.
References m_pSysConfig.
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.
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.
std::string Mantid::Kernel::ConfigServiceImpl::getPathToExecutable | ( | ) | const |
Get the full path to the executing program (i.e.
whatever Mantid is embedded in)
Definition at line 1236 of file ConfigService.cpp.
Referenced by getDirectoryOfExecutable().
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.
Definition at line 1349 of file ConfigService.cpp.
References m_strBaseDir.
Referenced by cacheInstrumentPaths(), ConfigServiceImpl(), export_ConfigService(), makeAbsolute(), and reset().
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.
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.
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. |
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().
std::string Mantid::Kernel::ConfigServiceImpl::getTempDir | ( | ) |
Returns the system's temp directory.
Gets the absolute path of the temp directory.
Definition at line 1199 of file ConfigService.cpp.
References m_pSysConfig.
std::string Mantid::Kernel::ConfigServiceImpl::getUserFilename | ( | ) | const |
Return the user properties filename.
Return the full filename of the user properties file.
Definition at line 985 of file ConfigService.cpp.
References getUserPropertiesDir(), and m_user_properties_file_name.
Referenced by ConfigServiceImpl(), export_ConfigService(), and reset().
std::string Mantid::Kernel::ConfigServiceImpl::getUsername | ( | ) |
Returns the username.
Definition at line 1155 of file ConfigService.cpp.
References m_pSysConfig, and UNUSED_ARG.
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
Definition at line 1358 of file ConfigService.cpp.
References m_pSysConfig, and m_strBaseDir.
Referenced by createUserPropertiesFile(), export_ConfigService(), getUserFilename(), and loadConfig().
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.
keyName | :: The case sensitive name of the property that you need the value of. |
Definition at line 930 of file ConfigService.cpp.
References Mantid::Kernel::Strings::convert(), and getString().
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.
keyName | :: The case sensitive name of the property that you need the value of. |
Definition at line 949 of file ConfigService.cpp.
const std::string Mantid::Kernel::ConfigServiceImpl::getVTPFileDirectory | ( | ) |
get the vtp file directory
Return the search directory for vtp files.
Definition at line 1477 of file ConfigService.cpp.
References getAppDataDir(), and getString().
Referenced by ConfigServiceImpl().
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.
rootName | :: The case sensitive key that you are looking to see if exists. |
Definition at line 846 of file ConfigService.cpp.
References m_pConf.
Referenced by export_ConfigService(), and saveConfig().
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.
target | :: The path to the file you wish to see whether it's an executable. |
Definition at line 856 of file ConfigService.cpp.
|
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.
path | :: the absolute path name to search for |
Definition at line 495 of file ConfigService.cpp.
References m_dataSearchDirs.
Referenced by appendDataSearchDir().
bool Mantid::Kernel::ConfigServiceImpl::isNetworkDrive | ( | const std::string & | path | ) |
Check if the path is on a network drive.
path | :: The path to be checked |
Definition at line 1268 of file ConfigService.cpp.
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.
Definition at line 821 of file ConfigService.cpp.
References getKeysRecursive().
Referenced by export_ConfigService().
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.
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.
|
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.
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().
|
private |
Make a relative path or a list of relative paths into an absolute one.
dir | :: The directory to convert |
key | :: The key variable this relates to |
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().
|
private |
Read a file and place its contents into the given string.
filename | :: The filename of the file to read |
contents | :: The file contents will be placed here |
Definition at line 376 of file ConfigService.cpp.
Referenced by loadConfig().
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.
rootName | :: The key that is to be deleted |
Definition at line 835 of file ConfigService.cpp.
References m_changed_keys, and m_pConf.
void Mantid::Kernel::ConfigServiceImpl::removeObserver | ( | const Poco::AbstractObserver & | observer | ) | const |
Remove an observer.
observer | :: Reference to the observer to remove |
Definition at line 1801 of file ConfigService.cpp.
References m_notificationCenter.
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().
void Mantid::Kernel::ConfigServiceImpl::saveConfig | ( | const std::string & | filename | ) | const |
Save the configuration to the user file.
filename | :: The filename for the saved configuration |
std::runtime_error | if 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().
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:
Definition at line 239 of file ConfigService.cpp.
References getDirectoryOfExecutable(), m_properties_file_name, and m_strBaseDir.
Referenced by ConfigServiceImpl().
void Mantid::Kernel::ConfigServiceImpl::setDataSearchDirs | ( | const std::string & | searchDirs | ) |
Set a list of search paths via a string.
searchDirs | :: A string containing a list of search directories separated by a semi colon (;). |
Definition at line 1390 of file ConfigService.cpp.
References setString().
void Mantid::Kernel::ConfigServiceImpl::setDataSearchDirs | ( | const std::vector< std::string > & | searchDirs | ) |
Set a list of search paths via a vector.
searchDirs | :: A list of search directories |
Definition at line 1380 of file ConfigService.cpp.
References setDataSearchDirs().
Referenced by appendDataSearchSubDir(), and setDataSearchDirs().
void Mantid::Kernel::ConfigServiceImpl::setFacility | ( | const std::string & | facilityName | ) |
Set the default facility.
facilityName | the facility name |
NotFoundException | if 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().
void Mantid::Kernel::ConfigServiceImpl::setInstrumentDirectories | ( | const std::vector< std::string > & | directories | ) |
Sets instrument directories.
Sets the search directories for XML instrument definition files (IDFs)
directories | An ordered list of paths for instrument searching |
Definition at line 1458 of file ConfigService.cpp.
References m_instrumentDirs.
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.
logLevel | the integer value of the log level to set, 1=Critical, 7=Debug |
quiet | If 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().
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.
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().
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.
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().
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.
fName | :: An alternative file name for loading facilities information. |
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().
|
friend |
Definition at line 224 of file ConfigService.h.
|
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().
|
private |
List of config paths that may be relative.
Definition at line 289 of file ConfigService.h.
Referenced by ConfigServiceImpl(), and getString().
|
private |
Store a list of data search paths.
Definition at line 281 of file ConfigService.h.
Referenced by appendDataSearchDir(), appendDataSearchSubDir(), cacheDataSearchPaths(), getDataSearchDirs(), and isInDataSearchList().
|
private |
The list of available facilities.
Definition at line 286 of file ConfigService.h.
Referenced by clearFacilities(), getFacilities(), getFacility(), getFacilityNames(), getInstrument(), and updateFacilities().
|
private |
Store a list of instrument directory paths.
Definition at line 283 of file ConfigService.h.
Referenced by cacheInstrumentPaths(), getInstrumentDirectories(), getInstrumentDirectory(), and setInstrumentDirectories().
|
private |
whether the proxy has been populated yet
Definition at line 294 of file ConfigService.h.
Referenced by getProxy().
|
mutableprivate |
Handles distribution of Poco signals.
Definition at line 229 of file ConfigService.h.
Referenced by addObserver(), removeObserver(), and setString().
|
private |
the POCO file config object
Definition at line 265 of file ConfigService.h.
Referenced by configureLogging(), getKeys(), getString(), hasProperty(), loadConfig(), remove(), and setString().
|
private |
The filename of the Mantid properties file.
Definition at line 277 of file ConfigService.h.
Referenced by ConfigServiceImpl(), reset(), and setBaseDirectory().
|
private |
The configuration properties in string format.
Definition at line 275 of file ConfigService.h.
Referenced by loadConfig().
|
private |
local cache of proxy details
Definition at line 292 of file ConfigService.h.
Referenced by getProxy().
|
private |
the POCO system Config Object
Definition at line 267 of file ConfigService.h.
Referenced by getComputerName(), getCurrentDir(), getEnvironment(), getOSArchitecture(), getOSName(), getOSVersion(), getTempDir(), getUsername(), and getUserPropertiesDir().
|
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().
|
private |
The filename of the Mantid user properties file.
Definition at line 279 of file ConfigService.h.
Referenced by createUserPropertiesFile(), getUserFilename(), and loadConfig().