Hammer  1.0.0
Helicity Amplitude Module for Matrix Element Reweighting
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Hammer::SettingsHandler Class Reference

Hammer settings manager class. More...

#include <SettingsHandler.hh>

+ Collaboration diagram for Hammer::SettingsHandler:

Public Member Functions

void reset ()
 reset all the contents of SettingsHandler More...
 
void write (flatbuffers::FlatBufferBuilder *msgwriter, std::vector< flatbuffers::Offset< Serial::FBSetting >> *msgs) const
 
bool read (const Serial::FBHeader *msgreader, bool merge)
 
Constructors
 SettingsHandler ()
 default constructor More...
 
 SettingsHandler (const SettingsHandler &other)=delete
 
SettingsHandleroperator= (const SettingsHandler &other)=delete
 
 SettingsHandler (SettingsHandler &&other)=delete
 
SettingsHandleroperator= (SettingsHandler &&other)=delete
 
 ~SettingsHandler () noexcept=default
 
Hammer options
std::set< std::string > getSettings (const std::string &path="", WTerm group=WTerm::COMMON) const
 access the list of registered settings More...
 
template<typename T >
T * getNamedSettingValue (const std::string &path, const std::string &name, WTerm group=WTerm::COMMON)
 access a specific setting value More...
 
template<typename T >
T * getNamedSettingValue (const std::string &fullName, WTerm group=WTerm::COMMON)
 access a specific setting value More...
 
template<typename T >
SettingaddSetting (const std::string &path, const std::string &name, const T &value, WTerm group=WTerm::COMMON)
 add a setting to the store More...
 
template<typename T >
SettingaddSetting (const std::string &fullName, const T &value, WTerm group=WTerm::COMMON)
 add a setting to the store More...
 
SettingcloneSetting (const std::string &path, const std::string &name, const Setting &value, WTerm group=WTerm::COMMON)
 
SettingcloneSetting (const std::string &fullName, const Setting &value, WTerm group=WTerm::COMMON)
 
SettingresetSetting (const std::string &path, const std::string &name, WTerm group=WTerm::COMMON)
 
SettingresetSetting (const std::string &fullName, WTerm group=WTerm::COMMON)
 
SettinggetEntry (const std::string &path, const std::string &name, WTerm group)
 
void removeSetting (const std::string &path, const std::string &name, WTerm group=WTerm::COMMON)
 
void removeSetting (const std::string &fullName, WTerm group=WTerm::COMMON)
 
template<typename T >
SettingchangeSetting (const std::string &path, const std::string &name, const T &value, WTerm group=WTerm::COMMON)
 change a setting value More...
 
template<typename T >
SettingchangeSetting (const std::string &fullName, const T &value, WTerm group=WTerm::COMMON)
 change a setting value More...
 
void readSettings (const std::string &fileName)
 read Hammer settings from a file More...
 
void parseSettings (const std::string &data)
 read Hammer settings from a string More...
 
void saveSettings (const std::string &name, bool useDefault=true) const
 write current Hammer settings to a file More...
 
Bibliography
void saveReferences (const std::string &filename) const
 writes a BibTeX file containing the bibliography associated to current run More...
 
bool checkReference (const std::string &bibkey)
 check a bibliographic reference to the current run More...
 
void addReference (const std::string &bibkey, const std::string &bibtex)
 add a bibliographic reference to the current run More...
 
void clearReferences ()
 empties current run bibliography More...
 

Protected Member Functions

LoggetLog () const
 logging facility More...
 

Private Types

template<typename T >
using NamedDict = std::map< std::string, T >
 

Private Member Functions

void processSetting (const YAML::Node &setting, const std::string &path, const std::string &name, WTerm group=WTerm::COMMON)
 
void processSettings (const YAML::Node &input, WTerm group=WTerm::COMMON)
 
std::string groupToPrefix (WTerm option) const
 
WTerm prefixToGroup (const std::string &option) const
 
void writeSetting (YAML::Emitter &emitter, const Setting &val, bool useDefault) const
 
bool isMassWidth (const std::string &name) const
 
void processMassWidth (const std::string &path, const std::string &name, double value) const
 
std::map< std::string,
std::map< std::string, const
Setting * > > 
getEntriesByGroup (WTerm group) const
 
std::string buildName (const std::string &path, const std::string &name, WTerm group) const
 
std::tuple< std::string,
std::string, WTerm
parseName (const std::string &fullName) const
 

Private Attributes

std::map< WTerm, NamedDict
< NamedDict< Setting > > > 
_settings
 the Hammer options dictionary More...
 
std::map< std::string,
std::string > 
_references
 

Detailed Description

Hammer settings manager class.

Stores Hammer options, provides facilities for saving and reading option files, provides option query interface. It also provide a repository of other run-wide information, such as the bibliography associated to the specific run, the list of files being processed

Definition at line 49 of file SettingsHandler.hh.

Member Typedef Documentation

template<typename T >
using Hammer::SettingsHandler::NamedDict = std::map<std::string, T>
private

Definition at line 230 of file SettingsHandler.hh.

Constructor & Destructor Documentation

Hammer::SettingsHandler::SettingsHandler ( )
inline

default constructor

Definition at line 56 of file SettingsHandler.hh.

Hammer::SettingsHandler::SettingsHandler ( const SettingsHandler other)
delete
Hammer::SettingsHandler::SettingsHandler ( SettingsHandler &&  other)
delete
Hammer::SettingsHandler::~SettingsHandler ( )
defaultnoexcept

Member Function Documentation

void Hammer::SettingsHandler::addReference ( const std::string &  bibkey,
const std::string &  bibtex 
)

add a bibliographic reference to the current run

Parameters
[in]bibkeythe BibTeX key
[in]bibtexthe body of the citation in BibTeX format

Definition at line 342 of file SettingsHandler.cc.

template<typename T >
Setting * Hammer::SettingsHandler::addSetting ( const std::string &  path,
const std::string &  name,
const T &  value,
WTerm  group = WTerm::COMMON 
)

add a setting to the store

Parameters
[in]paththe class owning the settings
[in]namethe name of the setting
[in]valuethe value (and default value) of the setting. If setting is already present only
[in]groupwhether it applies to the numerator, denominator or both default value is changed
Returns
the added setting

Definition at line 42 of file SettingsHandlerDefs.hh.

template<typename T >
Setting * Hammer::SettingsHandler::addSetting ( const std::string &  fullName,
const T &  value,
WTerm  group = WTerm::COMMON 
)

add a setting to the store

Parameters
[in]fullNamethe full name of the setting in the "<path>:<name>" format
[in]valuethe value (and default value) of the setting
[in]groupwhether it applies to the numerator, denominator or both
Returns
the added setting

Definition at line 58 of file SettingsHandlerDefs.hh.

string Hammer::SettingsHandler::buildName ( const std::string &  path,
const std::string &  name,
WTerm  group 
) const
private

Definition at line 236 of file SettingsHandler.cc.

template<typename T >
Setting * Hammer::SettingsHandler::changeSetting ( const std::string &  path,
const std::string &  name,
const T &  value,
WTerm  group = WTerm::COMMON 
)

change a setting value

Parameters
[in]paththe class owning the settings
[in]namethe name of the setting
[in]valuethe new value of the setting
[in]groupwhether it applies to the numerator, denominator or both
Returns
the changed setting, nullptr if the setting was not found

Definition at line 66 of file SettingsHandlerDefs.hh.

template<typename T >
Setting * Hammer::SettingsHandler::changeSetting ( const std::string &  fullName,
const T &  value,
WTerm  group = WTerm::COMMON 
)

change a setting value

Parameters
[in]fullNamethe full name of the setting in the "<path>:<name>" format
[in]valuethe new value of the setting
[in]groupwhether it applies to the numerator, denominator or both
Returns
the changed setting, nullptr if the setting was not found

Definition at line 90 of file SettingsHandlerDefs.hh.

bool Hammer::SettingsHandler::checkReference ( const std::string &  bibkey)

check a bibliographic reference to the current run

Parameters
[in]bibkeythe BibTeX key

Definition at line 338 of file SettingsHandler.cc.

void Hammer::SettingsHandler::clearReferences ( )

empties current run bibliography

Definition at line 350 of file SettingsHandler.cc.

Setting * Hammer::SettingsHandler::cloneSetting ( const std::string &  path,
const std::string &  name,
const Setting value,
WTerm  group = WTerm::COMMON 
)

Definition at line 48 of file SettingsHandler.cc.

Setting * Hammer::SettingsHandler::cloneSetting ( const std::string &  fullName,
const Setting value,
WTerm  group = WTerm::COMMON 
)

Definition at line 52 of file SettingsHandler.cc.

map< string, map< string, const Setting * > > Hammer::SettingsHandler::getEntriesByGroup ( WTerm  group) const
private

Definition at line 192 of file SettingsHandler.cc.

Setting * Hammer::SettingsHandler::getEntry ( const std::string &  path,
const std::string &  name,
WTerm  group 
)

Definition at line 59 of file SettingsHandler.cc.

Log & Hammer::SettingsHandler::getLog ( ) const
protected

logging facility

Returns
stream to be used for logging

Definition at line 44 of file SettingsHandler.cc.

template<typename T >
T * Hammer::SettingsHandler::getNamedSettingValue ( const std::string &  path,
const std::string &  name,
WTerm  group = WTerm::COMMON 
)

access a specific setting value

Parameters
[in]paththe class owning the settings
[in]namethe name of the setting
[in]groupwhether it applies to the numerator, denominator or both
Returns
a pointer to the value, nullptr if the setting is not found or the type does not match

Definition at line 22 of file SettingsHandlerDefs.hh.

template<typename T >
T * Hammer::SettingsHandler::getNamedSettingValue ( const std::string &  fullName,
WTerm  group = WTerm::COMMON 
)

access a specific setting value

Parameters
[in]fullNamethe full name of the setting in the "<path>:<name>" format
[in]groupwhether it applies to the numerator, denominator or both
Returns
a pointer to the value, nullptr if the setting is not found or the type does not match

Definition at line 34 of file SettingsHandlerDefs.hh.

set< string > Hammer::SettingsHandler::getSettings ( const std::string &  path = "",
WTerm  group = WTerm::COMMON 
) const

access the list of registered settings

Parameters
[in]paththe class owning the settings. An empty string returns all the registered settings
[in]groupwhether it applies to the numerator, denominator or both
Returns
a list of setting names

Definition at line 108 of file SettingsHandler.cc.

string Hammer::SettingsHandler::groupToPrefix ( WTerm  option) const
private

Definition at line 303 of file SettingsHandler.cc.

bool Hammer::SettingsHandler::isMassWidth ( const std::string &  name) const
private

Definition at line 132 of file SettingsHandler.cc.

SettingsHandler& Hammer::SettingsHandler::operator= ( const SettingsHandler other)
delete
SettingsHandler& Hammer::SettingsHandler::operator= ( SettingsHandler &&  other)
delete
tuple< string, string, WTerm > Hammer::SettingsHandler::parseName ( const std::string &  fullName) const
private

Definition at line 240 of file SettingsHandler.cc.

void Hammer::SettingsHandler::parseSettings ( const std::string &  data)

read Hammer settings from a string

Parameters
[in]datathe settings

Definition at line 122 of file SettingsHandler.cc.

WTerm Hammer::SettingsHandler::prefixToGroup ( const std::string &  option) const
private

Definition at line 315 of file SettingsHandler.cc.

void Hammer::SettingsHandler::processMassWidth ( const std::string &  path,
const std::string &  name,
double  value 
) const
private

Definition at line 136 of file SettingsHandler.cc.

void Hammer::SettingsHandler::processSetting ( const YAML::Node &  setting,
const std::string &  path,
const std::string &  name,
WTerm  group = WTerm::COMMON 
)
private
Parameters
[in]setting
[in]path
[in]name
[in]groupwhether it applies to the numerator, denominator or both

Definition at line 145 of file SettingsHandler.cc.

void Hammer::SettingsHandler::processSettings ( const YAML::Node &  input,
WTerm  group = WTerm::COMMON 
)
private
Parameters
[in]input
[in]groupwhether it applies to the numerator, denominator or both

Definition at line 168 of file SettingsHandler.cc.

bool Hammer::SettingsHandler::read ( const Serial::FBHeader *  msgreader,
bool  merge 
)

Definition at line 280 of file SettingsHandler.cc.

void Hammer::SettingsHandler::readSettings ( const std::string &  fileName)

read Hammer settings from a file

Parameters
[in]fileNamethe file name

Definition at line 127 of file SettingsHandler.cc.

void Hammer::SettingsHandler::removeSetting ( const std::string &  path,
const std::string &  name,
WTerm  group = WTerm::COMMON 
)
Parameters
[in]path
[in]name
[in]groupwhether it applies to the numerator, denominator or both

Definition at line 88 of file SettingsHandler.cc.

void Hammer::SettingsHandler::removeSetting ( const std::string &  fullName,
WTerm  group = WTerm::COMMON 
)
Parameters
[in]fullName
[in]groupwhether it applies to the numerator, denominator or both

Definition at line 101 of file SettingsHandler.cc.

void Hammer::SettingsHandler::reset ( )

reset all the contents of SettingsHandler

Definition at line 34 of file SettingsHandler.cc.

Setting * Hammer::SettingsHandler::resetSetting ( const std::string &  path,
const std::string &  name,
WTerm  group = WTerm::COMMON 
)

Definition at line 73 of file SettingsHandler.cc.

Setting * Hammer::SettingsHandler::resetSetting ( const std::string &  fullName,
WTerm  group = WTerm::COMMON 
)

Definition at line 81 of file SettingsHandler.cc.

void Hammer::SettingsHandler::saveReferences ( const std::string &  filename) const

writes a BibTeX file containing the bibliography associated to current run

Parameters
[in]filenamethe name of the file

Definition at line 328 of file SettingsHandler.cc.

void Hammer::SettingsHandler::saveSettings ( const std::string &  name,
bool  useDefault = true 
) const

write current Hammer settings to a file

Parameters
[in]namethe file name
[in]useDefaultthe file name

Definition at line 207 of file SettingsHandler.cc.

void Hammer::SettingsHandler::write ( flatbuffers::FlatBufferBuilder *  msgwriter,
std::vector< flatbuffers::Offset< Serial::FBSetting >> *  msgs 
) const

Definition at line 254 of file SettingsHandler.cc.

void Hammer::SettingsHandler::writeSetting ( YAML::Emitter &  emitter,
const Setting val,
bool  useDefault 
) const
private

Member Data Documentation

std::map<std::string, std::string> Hammer::SettingsHandler::_references
private

Definition at line 235 of file SettingsHandler.hh.

std::map<WTerm, NamedDict<NamedDict<Setting> > > Hammer::SettingsHandler::_settings
private

the Hammer options dictionary

Definition at line 233 of file SettingsHandler.hh.


The documentation for this class was generated from the following files: