12 #ifndef HAMMER_SettingsHandler_HH
13 #define HAMMER_SettingsHandler_HH
21 #include <type_traits>
23 #include <boost/variant.hpp>
108 template <typename T>
116 template <typename T>
146 template <typename T>
154 template <typename T>
168 void saveSettings(const std::
string& name,
bool useDefault = true) const;
172 void write(flatbuffers::FlatBufferBuilder* msgwriter, std::vector<flatbuffers::Offset<Serial::FBSetting>>* msgs) const;
174 bool read(const Serial::FBHeader* msgreader,
bool merge);
192 void addReference(const std::
string& bibkey, const std::
string& bibtex);
205 void processSetting(const YAML::Node& setting, const std::
string& path, const std::
string& name,
WTerm group =
WTerm::COMMON);
219 void processMassWidth(const std::
string& path, const std::
string& name,
double value) const;
223 std::
string buildName(const std::
string& path, const std::
string& name,
WTerm group) const;
225 std::tuple<std::
string, std::
string,
WTerm>
parseName(const std::
string& fullName) const;
241 #include "Hammer/SettingsHandlerDefs.hh"
std::map< std::string, std::string > _references
std::map< std::string, std::map< std::string, const Setting * > > getEntriesByGroup(WTerm group) const
Forward declaration of serialization related typedefs and includes.
void saveSettings(const std::string &name, bool useDefault=true) const
write current Hammer settings to a file
Setting * changeSetting(const std::string &path, const std::string &name, const T &value, WTerm group=WTerm::COMMON)
change a setting value
Hammer data types declarations.
void parseSettings(const std::string &data)
read Hammer settings from a string
Log & getLog() const
logging facility
T * getNamedSettingValue(const std::string &path, const std::string &name, WTerm group=WTerm::COMMON)
access a specific setting value
Setting * cloneSetting(const std::string &path, const std::string &name, const Setting &value, WTerm group=WTerm::COMMON)
void processSetting(const YAML::Node &setting, const std::string &path, const std::string &name, WTerm group=WTerm::COMMON)
Setting * resetSetting(const std::string &path, const std::string &name, WTerm group=WTerm::COMMON)
void write(flatbuffers::FlatBufferBuilder *msgwriter, std::vector< flatbuffers::Offset< Serial::FBSetting >> *msgs) const
SettingsHandler & operator=(const SettingsHandler &other)=delete
Message logging routines.
SettingsHandler()
default constructor
void writeSetting(YAML::Emitter &emitter, const Setting &val, bool useDefault) const
void reset()
reset all the contents of SettingsHandler
bool checkReference(const std::string &bibkey)
check a bibliographic reference to the current run
void processSettings(const YAML::Node &input, WTerm group=WTerm::COMMON)
void addReference(const std::string &bibkey, const std::string &bibtex)
add a bibliographic reference to the current run
bool read(const Serial::FBHeader *msgreader, bool merge)
Setting * getEntry(const std::string &path, const std::string &name, WTerm group)
std::map< WTerm, NamedDict< NamedDict< Setting > > > _settings
the Hammer options dictionary
void clearReferences()
empties current run bibliography
~SettingsHandler() noexcept=default
container for an Hammer run option
std::tuple< std::string, std::string, WTerm > parseName(const std::string &fullName) const
void processMassWidth(const std::string &path, const std::string &name, double value) const
bool isMassWidth(const std::string &name) const
std::map< std::string, T > NamedDict
void readSettings(const std::string &fileName)
read Hammer settings from a file
void removeSetting(const std::string &path, const std::string &name, WTerm group=WTerm::COMMON)
Hammer settings manager class.
void saveReferences(const std::string &filename) const
writes a BibTeX file containing the bibliography associated to current run
Setting * addSetting(const std::string &path, const std::string &name, const T &value, WTerm group=WTerm::COMMON)
add a setting to the store
WTerm prefixToGroup(const std::string &option) const
std::string groupToPrefix(WTerm option) const
std::set< std::string > getSettings(const std::string &path="", WTerm group=WTerm::COMMON) const
access the list of registered settings
std::string buildName(const std::string &path, const std::string &name, WTerm group) const