![]() |
GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
|
![]() |
The TUserSettings class defines user settings that can be read from text or root files. It stores them in separate maps for booleans, integers, floats, and strings as well as vectors of those types.
For helpers the reading of the user settings is done in the TGRSIHelper class and made available as the member fUserSettings. Code to read the user setting "MyDouble" into the member variable fMyMemberVariable
in the helper's constructor could be:
See the AngularCorrelationHelper's header file for more.
In general the user settings can be accessed via the static function TUserSettings* TGRSIOptions::UserSettings()
.
If TGRSIOptions are not available, the user settings can be read using the constructor:
or using the ReadSettings function:
where userSettings is of type TUserSettings* and filename is either a std::string or char*.
The settings file is expected to have the format parameter name: value where parameter name is a string w/o whitespace and value is the value of the parameter the type of the value (bool, int, double, std::string, or vectors of these types) will be determined automatically. Vectors are comma separated values of one type. The default type is std::string. Any lines starting with '#' or '//' or without a colon will be ignored. See "examples/AngularCorrelationSettings.par" for an example of a settings file.
Definition at line 63 of file TUserSettings.h.
Public Member Functions | |
TUserSettings ()=default | |
TUserSettings (const std::string &settingsFile) | |
TUserSettings (const TUserSettings &)=default | |
TUserSettings (TUserSettings &&) noexcept=default | |
~TUserSettings ()=default | |
void | Clear (Option_t *="") override |
bool | empty () |
template<typename T > | |
T | Get (const std::string ¶meter) const |
bool | GetBool (const std::string ¶meter, bool quiet=false) const |
std::vector< bool > | GetBoolVector (const std::string ¶meter, bool quiet=false) const |
double | GetDouble (const std::string ¶meter, bool quiet=false) const |
double | GetDouble (const std::string ¶meter, double def) const |
std::vector< double > | GetDoubleVector (const std::string ¶meter, bool quiet=false) const |
int | GetInt (const std::string ¶meter, bool quiet=false) const |
int | GetInt (const std::string ¶meter, int def) const |
std::vector< int > | GetIntVector (const std::string ¶meter, bool quiet=false) const |
std::string | GetString (const std::string ¶meter, bool quiet=false) const |
std::string | GetString (const std::string ¶meter, std::string def) const |
std::vector< std::string > | GetStringVector (const std::string ¶meter, bool quiet=false) const |
TUserSettings & | operator= (const TUserSettings &)=default |
TUserSettings & | operator= (TUserSettings &&) noexcept=default |
void | Print (Option_t *opt="") const override |
bool | ReadSettings (const std::string &settingsFile) |
void | SetBool (const std::string ¶meter, bool value) |
void | SetBoolVector (const std::string ¶meter, const std::vector< bool > &value) |
void | SetDouble (const std::string ¶meter, double value) |
void | SetDoubleVector (const std::string ¶meter, const std::vector< double > &value) |
void | SetInt (const std::string ¶meter, int value) |
void | SetIntVector (const std::string ¶meter, const std::vector< int > &value) |
void | SetString (const std::string ¶meter, const std::string &value) |
void | SetStringVector (const std::string ¶meter, const std::vector< std::string > &value) |
Private Member Functions | |
void | ParseValue (const std::string &name, const std::string &value, bool vector) |
Private Attributes | |
std::map< std::string, bool > | fBool |
std::map< std::string, std::vector< bool > > | fBoolVector |
std::map< std::string, double > | fDouble |
std::map< std::string, std::vector< double > > | fDoubleVector |
std::map< std::string, int > | fInt |
std::map< std::string, std::vector< int > > | fIntVector |
std::vector< std::string > | fSettingsFiles |
std::map< std::string, std::string > | fString |
std::map< std::string, std::vector< std::string > > | fStringVector |
|
default |
|
inlineexplicit |
Definition at line 66 of file TUserSettings.h.
References ReadSettings().
|
default |
|
defaultnoexcept |
|
default |
|
inlineoverride |
Definition at line 143 of file TUserSettings.h.
References fBool, fBoolVector, fDouble, fDoubleVector, fInt, fIntVector, fString, and fStringVector.
Referenced by TGRSIOptions::Clear().
|
inline |
Definition at line 79 of file TUserSettings.h.
References fBool, fBoolVector, fDouble, fDoubleVector, fInt, fIntVector, fString, and fStringVector.
Referenced by TGRSIOptions::WriteToFile().
|
inline |
Definition at line 83 of file TUserSettings.h.
References GetBool(), GetBoolVector(), GetDouble(), GetDoubleVector(), GetInt(), GetIntVector(), GetString(), and GetStringVector().
bool TUserSettings::GetBool | ( | const std::string & | parameter, |
bool | quiet = false ) const |
Definition at line 119 of file TUserSettings.cxx.
References fBool, and Print().
Referenced by AngularCorrelationHelper::AngularCorrelationHelper(), ComptonPolarimetryHelper::ComptonPolarimetryHelper(), and Get().
std::vector< bool > TUserSettings::GetBoolVector | ( | const std::string & | parameter, |
bool | quiet = false ) const |
Definition at line 171 of file TUserSettings.cxx.
References fBoolVector, and Print().
Referenced by Get().
double TUserSettings::GetDouble | ( | const std::string & | parameter, |
bool | quiet = false ) const |
Definition at line 145 of file TUserSettings.cxx.
References fDouble, and Print().
Referenced by AngularCorrelationHelper::AngularCorrelationHelper(), ComptonPolarimetryHelper::ComptonPolarimetryHelper(), and Get().
|
inline |
Definition at line 115 of file TUserSettings.h.
References fDouble.
std::vector< double > TUserSettings::GetDoubleVector | ( | const std::string & | parameter, |
bool | quiet = false ) const |
Definition at line 197 of file TUserSettings.cxx.
References fDoubleVector, and Print().
Referenced by Get().
int TUserSettings::GetInt | ( | const std::string & | parameter, |
bool | quiet = false ) const |
Definition at line 132 of file TUserSettings.cxx.
Referenced by AngularCorrelationHelper::AngularCorrelationHelper(), ComptonPolarimetryHelper::ComptonPolarimetryHelper(), and Get().
|
inline |
Definition at line 107 of file TUserSettings.h.
References fInt.
std::vector< int > TUserSettings::GetIntVector | ( | const std::string & | parameter, |
bool | quiet = false ) const |
Definition at line 184 of file TUserSettings.cxx.
References fIntVector, and Print().
Referenced by AngularCorrelationHelper::AngularCorrelationHelper(), ComptonPolarimetryHelper::ComptonPolarimetryHelper(), and Get().
std::string TUserSettings::GetString | ( | const std::string & | parameter, |
bool | quiet = false ) const |
Definition at line 158 of file TUserSettings.cxx.
References fString, and Print().
Referenced by Get().
|
inline |
Definition at line 123 of file TUserSettings.h.
References fString.
std::vector< std::string > TUserSettings::GetStringVector | ( | const std::string & | parameter, |
bool | quiet = false ) const |
Definition at line 210 of file TUserSettings.cxx.
References fStringVector, and Print().
Referenced by Get().
|
default |
|
defaultnoexcept |
|
private |
Definition at line 61 of file TUserSettings.cxx.
References fBool, fBoolVector, fDouble, fDoubleVector, fInt, fIntVector, fString, and fStringVector.
Referenced by ReadSettings().
|
override |
Definition at line 223 of file TUserSettings.cxx.
References fBool, fBoolVector, fDouble, fDoubleVector, fInt, fIntVector, fSettingsFiles, fString, and fStringVector.
Referenced by GetBool(), GetBoolVector(), GetDouble(), GetDoubleVector(), GetInt(), GetIntVector(), GetString(), and GetStringVector().
bool TUserSettings::ReadSettings | ( | const std::string & | settingsFile | ) |
Read user settings from text file. The file is expected to have the format parameter name: value where parameter name is a string w/o whitespace and value is the value of the parameter the type of the value (bool, int, double, std::string, or vectors of these types) will be determined automatically vectors are comma separated values of one type the default type will be std::string any lines starting with '#' or '//' or without a colon will be ignored
Definition at line 12 of file TUserSettings.cxx.
References fSettingsFiles, ParseValue(), and trim().
Referenced by TUserSettings(), and TGRSIOptions::FileAutoDetect().
|
inline |
Definition at line 133 of file TUserSettings.h.
References fBool.
|
inline |
Definition at line 137 of file TUserSettings.h.
References fBoolVector.
|
inline |
Definition at line 135 of file TUserSettings.h.
References fDouble.
|
inline |
Definition at line 139 of file TUserSettings.h.
References fDoubleVector.
|
inline |
Definition at line 134 of file TUserSettings.h.
References fInt.
|
inline |
Definition at line 138 of file TUserSettings.h.
References fIntVector.
|
inline |
Definition at line 136 of file TUserSettings.h.
References fString.
|
inline |
Definition at line 140 of file TUserSettings.h.
References fStringVector.
|
private |
Definition at line 159 of file TUserSettings.h.
Referenced by Clear(), empty(), GetBool(), ParseValue(), Print(), and SetBool().
|
private |
Definition at line 163 of file TUserSettings.h.
Referenced by Clear(), empty(), GetBoolVector(), ParseValue(), Print(), and SetBoolVector().
|
private |
Definition at line 161 of file TUserSettings.h.
Referenced by Clear(), empty(), GetDouble(), GetDouble(), ParseValue(), Print(), and SetDouble().
|
private |
Definition at line 165 of file TUserSettings.h.
Referenced by Clear(), empty(), GetDoubleVector(), ParseValue(), Print(), and SetDoubleVector().
|
private |
Definition at line 160 of file TUserSettings.h.
Referenced by Clear(), empty(), GetInt(), GetInt(), ParseValue(), Print(), and SetInt().
|
private |
Definition at line 164 of file TUserSettings.h.
Referenced by Clear(), empty(), GetIntVector(), ParseValue(), Print(), and SetIntVector().
|
private |
Definition at line 168 of file TUserSettings.h.
Referenced by Print(), and ReadSettings().
|
private |
Definition at line 162 of file TUserSettings.h.
Referenced by Clear(), empty(), GetString(), GetString(), ParseValue(), Print(), and SetString().
|
private |
Definition at line 166 of file TUserSettings.h.
Referenced by Clear(), empty(), GetStringVector(), ParseValue(), Print(), and SetStringVector().