14#include <boost/python/class.hpp>
15#include <boost/python/copy_const_reference.hpp>
16#include <boost/python/def.hpp>
17#include <boost/python/overloads.hpp>
18#include <boost/python/reference_existing_object.hpp>
36 if (singleString.check()) {
44std::string getStringUsingCache(
ConfigServiceImpl const *
const self,
const std::string &key) {
56std::string getStringUsingCacheElseDefault(
ConfigServiceImpl const *
const self,
const std::string &key,
57 const std::string &defaultValue) {
69BOOST_PYTHON_FUNCTION_OVERLOADS(getInstrument_Overload, getInstrument, 1, 2)
80 std_vector_exporter<FacilityInfo *>::wrap(
"std_vector_facilityinfo");
82 class_<ConfigServiceImpl, boost::noncopyable>(
"ConfigServiceImpl", no_init)
84 "Clears all user settings and removes the user properties file")
86 "Returns the path to Mantid's application directory")
88 "Returns the path to the system wide properties file.")
90 "Returns the path to the user properties file")
92 "Returns the directory containing the Mantid.properties file.")
94 "Returns the directory to use to write out Mantid information")
96 "Returns the directory used for the instrument definitions")
98 return_value_policy<reference_existing_object>(),
99 "Returns the list of directories searched for the instrument "
104 arg(
"self"), return_value_policy<reference_existing_object>(),
"Returns the default facility")
107 (arg(
"self"), arg(
"facilityName")), return_value_policy<reference_existing_object>(),
108 "Returns the named facility. Raises an RuntimeError if it does not "
111 "Sets the current facility to the given name")
113 "Loads facility information from a provided file")
114 .def(
"getInstrument", &getInstrument,
115 getInstrument_Overload(
116 "Returns the named instrument. If name = \"\" then the "
117 "default.instrument is returned",
119 arg(
"instrumentName") = boost::python::object()))[return_value_policy<copy_const_reference>()])
121 getString_Overload(
"Returns the named key's value. If use_cache = "
122 "true [default] then relative paths->absolute",
123 (arg(
"self"), arg(
"key"), arg(
"pathAbsolute") =
true)))
126 "Set the given property name. "
127 "If it does not exist it is added to the current configuration")
130 return_value_policy<copy_const_reference>(),
"Return the current list of data search paths")
132 "Append a directory to the current list of data search paths")
134 "Appends a sub-directory to each data search directory "
135 "and appends the new paths back to datasearch directories")
136 .def(
"setDataSearchDirs", &setDataSearchDirs, (arg(
"self"), arg(
"searchDirs")),
137 "Set the datasearch.directories property from a list of strings or "
138 "a single ';' separated string.")
140 "Saves the keys that have changed from their default to the given "
143 "Sets the log level priority for all the log channels, logLevel "
144 "1 = Fatal, 6 = information, 7 = Debug")
148 .def(
"get", &getStringUsingCache, (arg(
"self"), arg(
"key")),
149 "get the string value of a property; return empty string value if the property "
150 "is not found in the configuration")
151 .def(
"get", &getStringUsingCacheElseDefault, (arg(
"self"), arg(
"key")), arg(
"default"),
152 "get the string value of a property; return a default string value if the property "
153 "is not found in the configuration")
154 .def(
"__getitem__", &getStringUsingCache, (arg(
"self"), arg(
"key")))
157 .def(
"Instance", &ConfigService::Instance, return_value_policy<reference_existing_object>(),
158 "Returns a reference to the ConfigService")
159 .staticmethod(
"Instance");
#define GET_POINTER_SPECIALIZATION(TYPE)
void export_ConfigService()
boost::python::extract< std::string > ExtractStdString
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(valueAsPrettyStrOverloader, valueAsPrettyStr, 0, 2) void export_Property()
#define GNU_DIAG_OFF(x)
This is a collection of macros for turning compiler warnings off in a controlled manner.
The ConfigService class provides a simple facade to access the Configuration functionality of the Man...
const std::vector< std::string > & getInstrumentDirectories() const
Get instrument search directories.
const FacilityInfo & getFacility() const
Get the default facility.
void reset()
Reset to "factory" settings. Removes current user properties.
std::string getLocalFilename() const
Return the local properties filename.
std::string getAppDataDir()
Returns the system's appdata directory.
std::string getPropertiesDir() const
Returns the directory where the Mantid.properties file is found.
std::string getUserPropertiesDir() const
Returns a directory to use to write out Mantid information.
void saveConfig(const std::string &filename) const
Save the configuration to the user file.
const std::vector< std::string > & getDataSearchDirs() const
Get the list of search paths.
const InstrumentInfo & getInstrument(const std::string &instrumentName="") const
Look for an instrument.
void updateFacilities(const std::string &fName="")
Load facility information from instrumentDir/Facilities.xml file.
const std::vector< FacilityInfo * > getFacilities() const
Get the list of facilities.
void appendDataSearchDir(const std::string &path)
Adds the passed path to the end of the list of data search paths.
void setLogLevel(int logLevel, bool quiet=false)
Sets the log level priority for all log channels.
void setDataSearchDirs(const std::vector< std::string > &searchDirs)
Set a list of search paths via a vector.
std::string getString(const std::string &keyName, bool pathAbsolute=true) const
Searches for a configuration property.
const std::string getInstrumentDirectory() const
Get instrument search directory.
void setString(const std::string &key, const std::string &value)
Sets a configuration property.
std::string getUserFilename() const
Return the user properties filename.
void setFacility(const std::string &facilityName)
Set the default facility.
void appendDataSearchSubDir(const std::string &subdir)
Appends subdirectory to each of the specified data search directories.
std::vector< std::string > keys() const
Returns a list of all full keys in the config.
const std::vector< std::string > getFacilityNames() const
Get the list of facility names.
bool hasProperty(const std::string &rootName) const
Checks to see whether a key has a value assigned to it.
A class that holds information about a facility.
A class that holds information about an instrument.
Manage the lifetime of a class intended to be a singleton.
Converts a Python sequence type to a C++ std::vector, where the element type is defined by the templa...
A struct to help export std::vector types.