15#include <boost/python/class.hpp>
16#include <boost/python/copy_const_reference.hpp>
17#include <boost/python/def.hpp>
18#include <boost/python/overloads.hpp>
19#include <boost/python/reference_existing_object.hpp>
38 if (singleString.check()) {
46std::string getStringUsingCache(
ConfigServiceImpl const *
const self,
const std::string &key) {
59std::string getStringUsingCacheElseDefault(
ConfigServiceImpl const *
const self,
const std::string &key,
60 const std::string &defaultValue) {
74BOOST_PYTHON_FUNCTION_OVERLOADS(getInstrument_Overload, getInstrument, 1, 2)
85 std_vector_exporter<FacilityInfo *>::wrap(
"std_vector_facilityinfo");
87 class_<ConfigServiceImpl, boost::noncopyable>(
"ConfigServiceImpl", no_init)
89 "Clears all user settings and removes the user properties file")
91 "Returns the path to Mantid's application directory")
93 "Returns the path to the system wide properties file.")
95 "Returns the path to the user properties file")
97 "Returns the directory containing the Mantid.properties file.")
99 "Returns the directory to use to write out Mantid information")
101 "Returns the directory used for the instrument definitions")
103 return_value_policy<reference_existing_object>(),
104 "Returns the list of directories searched for the instrument "
109 "Configure and start the logging framework")
112 arg(
"self"), return_value_policy<reference_existing_object>(),
"Returns the default facility")
115 (arg(
"self"), arg(
"facilityName")), return_value_policy<reference_existing_object>(),
116 "Returns the named facility. Raises an RuntimeError if it does not "
119 "Sets the current facility to the given name")
121 "Loads facility information from a provided file")
122 .def(
"getInstrument", &getInstrument,
123 getInstrument_Overload(
124 "Returns the named instrument. If name = \"\" then the "
125 "default.instrument is returned",
127 arg(
"instrumentName") = boost::python::object()))[return_value_policy<copy_const_reference>()])
129 getString_Overload(
"Returns the named key's value. If use_cache = "
130 "true [default] then relative paths->absolute",
131 (arg(
"self"), arg(
"key"), arg(
"pathAbsolute") =
true)))
134 "Set the given property name. "
135 "If it does not exist it is added to the current configuration")
138 return_value_policy<copy_const_reference>(),
"Return the current list of data search paths")
140 "Append a directory to the current list of data search paths")
142 "Appends a sub-directory to each data search directory "
143 "and appends the new paths back to datasearch directories")
144 .def(
"setDataSearchDirs", &setDataSearchDirs, (arg(
"self"), arg(
"searchDirs")),
145 "Set the datasearch.directories property from a list of strings or "
146 "a single ';' separated string.")
148 "Saves the keys that have changed from their default to the given "
151 "Return the string value for the log representation")
153 (arg(
"self"), arg(
"logLevel"), arg(
"quiet") =
false),
154 "Sets the log level priority for all the log channels, logLevel 1 = Fatal, 6 = information, 7 = Debug")
156 (arg(
"self"), arg(
"logLevel"), arg(
"quiet") =
false),
157 "Sets the log level priority for all the log channels. Allowed values are fatal, critical, error, warning, "
158 "notice, information, debug, and trace.")
162 .def(
"get", &getStringUsingCache, (arg(
"self"), arg(
"key")),
163 "get the string value of a property; return empty string value if the property "
164 "is not found in the configuration")
165 .def(
"get", &getStringUsingCacheElseDefault, (arg(
"self"), arg(
"key")), arg(
"default"),
166 "get the string value of a property; return a default string value if the property "
167 "is not found in the configuration")
168 .def(
"__getitem__", &getStringUsingCache, (arg(
"self"), arg(
"key")))
171 .def(
"Instance", &ConfigService::Instance, return_value_policy<reference_existing_object>(),
172 "Returns a reference to the ConfigService")
173 .staticmethod(
"Instance");
#define GET_POINTER_SPECIALIZATION(TYPE)
void export_ConfigService()
boost::python::extract< std::string > ExtractStdString
#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.
void configureLogging()
Configures the Poco logging and starts it up.
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.
std::string getLogLevel()
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 remove(const std::string &rootName)
Removes the value from a selected keyName.
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.
Defines a structure for releasing the Python GIL using the RAII pattern.
Mantid::Kernel::SingletonHolder< ConfigServiceImpl > ConfigService
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.