#include <TAPGeneratorOptions.h>
Public Types | |
typedef std::map< std::string, std::string > | OptionsList_t |
Helper typedef, intended for the list of key-value pairs for each option. | |
typedef std::vector < OptionsList_t::iterator > | OptionsOrder_t |
Helper typedef, intended to keep the order of option declaration. | |
Public Member Functions | |
TAPGeneratorOptions (const std::string &name) | |
~TAPGeneratorOptions () | |
void | AddArgument (const int &number, const std::string &option) |
Set the value of an argument. | |
std::string | GetChannel () const |
void | SetChannel (const std::string &ch) |
bool | Debug () const |
void | Debug (bool v) |
std::string | StringDescription () const |
Flatten all options into a string. | |
void | SetOption (const std::string &key, const std::string &value) |
Set the value of an option. | |
bool | AppendToOption (const std::string &key, const std::string &value) |
Append a new value to a list. | |
int | GetInt (const std::string &name, int defVal, const std::string &range="") const |
Get the named option as an int. | |
int | GetInt (const std::string &name, const std::string &range="") const |
Get the named option as an int, which MUST exist. | |
double | GetDouble (const std::string &name, double defVal, const std::string &range="") const |
Get the named option as a double. | |
double | GetDouble (const std::string &name, const std::string &range="") const |
Get the named option as a double, which MUST exist. | |
std::string | GetString (const std::string &name, const std::string &defVal) const |
Get the named option as a string. | |
std::string | GetString (const std::string &name) const |
Get the named option as a string. | |
bool | GetBool (const std::string &name, bool defVal) const |
Get the named option as a bool. | |
bool | GetBool (const std::string &name) const |
Get the named option as a bool. | |
int | GetVectorStringsByWhiteSpace (const std::string &name, std::vector< std::string > &vect) const |
Fill a vector of strings with whitespace delimited tokens found in the named option. | |
int | GetVectorStringsByDelimiter (const std::string &name, std::vector< std::string > &vect, const char *delim=":") const |
Fill a vector of strings with tokens found in the named option @ Uses strtok so not suitable for multi-threading (if we ever do something like that). | |
bool | HasOption (const std::string &name) const |
Check if a named option has been set. | |
bool | GetFlag (const std::string &name) const |
Check if a flag option has been set. | |
bool | GetNumOptions () const |
Get the number of options managed by this options list. | |
std::string | GetOption (const std::string &name, bool complain=false) const |
Returns the unprocessed value assigned to name. | |
OptionsList_t::const_iterator | begin () const |
Get a const iterator to the first key-value pair (sorted alphabetically by. | |
OptionsList_t::const_iterator | end () const |
Get a const iterator to the last key-value pair (sorted alphabetically by key). | |
void | DumpOptions (const std::string &prefix=" ") const |
Print all options managed by this list to cout. | |
void | SetAlias (const std::string &alias) |
Set the alias option for this module. | |
std::string | GetAlias (const std::string &defVal="") const |
Get the alias option for this module. | |
Protected Attributes | |
std::string | fModuleName |
Private Attributes | |
std::string | fChannel |
bool | fDebug |
Class to handle options for a TAP generator Inherite from the options class for modules to share the implementation and interface.
Definition at line 11 of file TAPGeneratorOptions.h.
typedef std::map<std::string,std::string> modules::options::OptionsList_t [inherited] |
Helper typedef, intended for the list of key-value pairs for each option.
Definition at line 29 of file ModulesOptions.h.
typedef std::vector<OptionsList_t::iterator> modules::options::OptionsOrder_t [inherited] |
Helper typedef, intended to keep the order of option declaration.
Definition at line 31 of file ModulesOptions.h.
TAPGeneratorOptions::TAPGeneratorOptions | ( | const std::string & | name | ) | [inline] |
Definition at line 13 of file TAPGeneratorOptions.h.
00013 : 00014 modules::options(name),fDebug(false){}; ~TAPGeneratorOptions(){};
TAPGeneratorOptions::~TAPGeneratorOptions | ( | ) | [inline] |
Definition at line 15 of file TAPGeneratorOptions.h.
void TAPGeneratorOptions::AddArgument | ( | const int & | number, | |
const std::string & | value | |||
) |
Set the value of an argument.
If the module has not specified a name for this argument, the key for this option is set to number ALCAP_REGISTER_MODULE
number | The number of the argument to set | |
value | The new value of the argument |
Reimplemented from modules::options.
Definition at line 4 of file TAPGeneratorOptions.cpp.
References modules::options::fModuleName, TemplateFactory< BaseModule, OptionsType >::GetArgumentName(), TAPGeneratorFactory::Instance(), and modules::options::SetOption().
Referenced by MakeAnalysedPulses::ParseGeneratorList().
00004 { 00005 // Get the name of this argument 00006 std::string name = TAPGeneratorFactory::Instance()->GetArgumentName(fModuleName,number); 00007 // Set the value of the corresponding option 00008 SetOption(name,option); 00009 }
bool modules::options::AppendToOption | ( | const std::string & | key, | |
const std::string & | value | |||
) | [inherited] |
Append a new value to a list.
The new value is separated from the previous one with: " : "
key | The name of the option to add to | |
value | The value to append |
Definition at line 124 of file ModulesOptions.cpp.
References modules::options::fOptions.
Referenced by modules::reader::AddOption().
00124 { 00125 // Get the option 00126 OptionsList_t::iterator it= fOptions.find(name); 00127 00128 // If no option exists return false 00129 if(it==fOptions.end()) return false; 00130 00131 // Add the value to it 00132 it->second+=" : "+option; 00133 return true; 00134 }
OptionsList_t::const_iterator modules::options::begin | ( | ) | const [inline, inherited] |
Get a const iterator to the first key-value pair (sorted alphabetically by.
Definition at line 184 of file ModulesOptions.h.
References modules::options::fOptions.
Referenced by ExportPulse::BeforeFirstEntry().
00184 {return fOptions.begin();};
void TAPGeneratorOptions::Debug | ( | bool | v | ) | [inline] |
bool TAPGeneratorOptions::Debug | ( | ) | const [inline] |
Definition at line 26 of file TAPGeneratorOptions.h.
References fDebug.
Referenced by MakeAnalysedPulses::AddGenerator(), FirstCompleteAPGenerator::FirstCompleteAPGenerator(), and TVAnalysedPulseGenerator::TVAnalysedPulseGenerator().
00026 {return fDebug;}
void modules::options::DumpOptions | ( | const std::string & | prefix = " " |
) | const [inherited] |
Print all options managed by this list to cout.
prefix | Appended before each line is printed |
Definition at line 105 of file ModulesOptions.cpp.
References modules::options::fOrder.
Referenced by load_config_file(), and modules::navigator::MakeModules().
00105 { 00106 //std::cout<<"key "<<" = "<<" value "<<std::endl; 00107 OptionsOrder_t::const_iterator it; 00108 for(it=fOrder.begin();it!=fOrder.end();it++){ 00109 std::cout<<prefix<<(*it)->first; 00110 if((*it)->second!=""){ 00111 std::cout<<" = "<<(*it)->second; 00112 } 00113 std::cout<<std::endl; 00114 } 00115 }
OptionsList_t::const_iterator modules::options::end | ( | ) | const [inline, inherited] |
Get a const iterator to the last key-value pair (sorted alphabetically by key).
Definition at line 186 of file ModulesOptions.h.
References modules::options::fOptions.
Referenced by ExportPulse::BeforeFirstEntry().
00186 {return fOptions.end();};
std::string modules::options::GetAlias | ( | const std::string & | defVal = "" |
) | const [inline, inherited] |
Get the alias option for this module.
Definition at line 198 of file ModulesOptions.h.
References modules::options::GetString().
Referenced by BaseModule::BaseModule().
00198 {return GetString("alias",defVal);};
bool modules::options::GetBool | ( | const std::string & | name | ) | const [inherited] |
Get the named option as a bool.
name | Name of the option to get |
Definition at line 74 of file ModulesOptions.cpp.
References modules::options::GetString(), and modules::parser::IsTrue().
00074 { 00075 return modules::parser::IsTrue(GetString(name)); 00076 }
bool modules::options::GetBool | ( | const std::string & | name, | |
bool | defVal | |||
) | const [inherited] |
Get the named option as a bool.
name | Name of the option to get | |
defVal | Value to use if not found |
Definition at line 78 of file ModulesOptions.cpp.
References modules::options::GetString(), and modules::parser::IsTrue().
Referenced by BaseModule::BaseModule(), FirstCompleteAPGenerator::FirstCompleteAPGenerator(), modules::options::GetFlag(), PulseViewer::PulseViewer(), TemplateCreator::TemplateCreator(), and TME_Al50_EvdE::TME_Al50_EvdE().
00078 { 00079 return modules::parser::IsTrue(GetString(name,Form("%d",defVal))); 00080 }
std::string TAPGeneratorOptions::GetChannel | ( | ) | const [inline] |
Definition at line 19 of file TAPGeneratorOptions.h.
References fChannel.
Referenced by TVAnalysedPulseGenerator::TVAnalysedPulseGenerator().
00019 { 00020 return fChannel; 00021 }
double modules::options::GetDouble | ( | const std::string & | name, | |
const std::string & | range = "" | |||
) | const [inherited] |
Get the named option as a double, which MUST exist.
Throws module::missing_option if the named option doesn't exist.
Use the range string to specify a validity range. Behind the scenes this uses ROOTs TFormula so any boolean operation is valid. Within the expression, either use the option's name as specified by the first argument to this method, or use "x". If the value fails the validity check, the modules::bad_value exception is thrown
name | Name of the option to get | |
range | Optional range for acceptable values |
Definition at line 54 of file ModulesOptions.cpp.
double modules::options::GetDouble | ( | const std::string & | name, | |
double | defVal, | |||
const std::string & | range = "" | |||
) | const [inherited] |
Get the named option as a double.
Use the range string to specify a validity range. Behind the scenes this uses ROOTs TFormula so any boolean operation is valid. Within the expression, either use the option's name as specified by the first argument to this method, or use "x". If the value fails the validity check, the modules::bad_value exception is thrown
name | Name of the option to get | |
defVal | Value to use if not found | |
range | Optional range for acceptable values |
Definition at line 57 of file ModulesOptions.cpp.
Referenced by FixedWindowMEGenerator::FixedWindowMEGenerator(), GaussFitAPGenerator::GaussFitAPGenerator(), MaxTimeDiffDPGenerator::MaxTimeDiffDPGenerator(), PlotIntegralRatios::PlotIntegralRatios(), PlotTDPs::PlotTDPs(), PulseCandidateFinder::PulseCandidateFinder(), TemplateConvolveAPGenerator::TemplateConvolveAPGenerator(), TemplateCreator::TemplateCreator(), TemplateFitAPGenerator::TemplateFitAPGenerator(), and GeSpectrum::ThrowIfInputsInsane().
bool modules::options::GetFlag | ( | const std::string & | name | ) | const [inline, inherited] |
Check if a flag option has been set.
If the option is present with no value return true, else return true if the value gives boolean true
name | Name of option to use |
Definition at line 243 of file ModulesOptions.h.
References modules::options::GetBool(), modules::options::GetOption(), and modules::options::HasOption().
Referenced by TemplateCreator::ChannelSet::ChannelSet(), ExportPulse::ExportPulse(), PlotTDPs::PlotTDPs(), PulseCandidateFinder::PulseCandidateFinder(), PulseViewer::PulseViewer(), TemplateConvolveAPGenerator::TemplateConvolveAPGenerator(), TemplateFitAPGenerator::TemplateFitAPGenerator(), and TVMuonEventGenerator::TVMuonEventGenerator().
int modules::options::GetInt | ( | const std::string & | name, | |
const std::string & | range = "" | |||
) | const [inherited] |
Get the named option as an int, which MUST exist.
Throws module::missing_option if the named option doesn't exist.
Use the range string to specify a validity range. Behind the scenes this uses ROOTs TFormula so any boolean operation is valid. Within the expression, either use the option's name as specified by the first argument to this method, or use "x". If the value fails the validity check, the modules::bad_value exception is thrown
name | Name of the option to get | |
range | Optional range for acceptable values |
Definition at line 47 of file ModulesOptions.cpp.
int modules::options::GetInt | ( | const std::string & | name, | |
int | defVal, | |||
const std::string & | range = "" | |||
) | const [inherited] |
Get the named option as an int.
Use the range string to specify a validity range. Behind the scenes this uses ROOTs TFormula so any boolean operation is valid. Within the expression, either use the option's name as specified by the first argument to this method, or use "x". If the value fails the validity check, the modules::bad_value exception is thrown
name | Name of the option to get | |
defVal | Value to use if not found | |
range | Optional range for acceptable values |
Definition at line 50 of file ModulesOptions.cpp.
Referenced by PulseCandidateFinder::PulseCandidateFinder(), PulseViewer::PulseViewer(), TemplateConvolveAPGenerator::TemplateConvolveAPGenerator(), TemplateCreator::TemplateCreator(), and TemplateFitAPGenerator::TemplateFitAPGenerator().
bool modules::options::GetNumOptions | ( | ) | const [inline, inherited] |
Get the number of options managed by this options list.
Definition at line 177 of file ModulesOptions.h.
References modules::options::fOptions.
Referenced by MakeAnalysedPulses::AddGenerator().
00177 {return fOptions.size();};
std::string modules::options::GetOption | ( | const std::string & | name, | |
bool | complain = false | |||
) | const [inherited] |
Returns the unprocessed value assigned to name.
name | Name of the option to get |
Definition at line 15 of file ModulesOptions.cpp.
References modules::options::fModuleName, and modules::options::fOptions.
Referenced by BaseModule::BaseModule(), modules::options::GetFlag(), modules::options::GetOption(), modules::options::GetString(), modules::options::GetVectorStringsByDelimiter(), and modules::options::GetVectorStringsByWhiteSpace().
00015 { 00016 OptionsList_t::const_iterator it = fOptions.find(key); 00017 if(it==fOptions.end()){ 00018 if(complain){ 00019 throw missing_option(fModuleName,key); 00020 } 00021 return ""; 00022 } 00023 return it->second; 00024 }
std::string modules::options::GetString | ( | const std::string & | name | ) | const [inherited] |
Get the named option as a string.
Trims whitespace from the front and back of the option
name | Name of the option to get |
Definition at line 61 of file ModulesOptions.cpp.
References modules::options::GetOption(), and modules::parser::TrimWhiteSpaceBeforeAfter().
00061 { 00062 std::string ret_val=GetOption(name,true); 00063 modules::parser::TrimWhiteSpaceBeforeAfter(ret_val); 00064 return ret_val; 00065 }
std::string modules::options::GetString | ( | const std::string & | name, | |
const std::string & | defVal | |||
) | const [inherited] |
Get the named option as a string.
Trims whitespace from the front and back of the option (but not for the default value if the modules file didn't specify anything)
name | Name of the option to get | |
defVal | Value to use if not found |
Definition at line 67 of file ModulesOptions.cpp.
References modules::options::GetOption(), and modules::parser::TrimWhiteSpaceBeforeAfter().
Referenced by MakeDetectorPulses::BeforeFirstEntry(), CalcCoarseTimeOffset::CalcCoarseTimeOffset(), modules::options::GetAlias(), modules::options::GetBool(), LoadPulses::LoadPulses(), MakeDetectorPulses::MakeDetectorPulses(), MakeMuonEvents::MakeMuonEvents(), PlotAmpVsTDiff::PlotAmpVsTDiff(), PlotTDP_TDiff::PlotTDP_TDiff(), PulseViewer::PulseViewer(), TemplateConvolveAPGenerator::TemplateConvolveAPGenerator(), TemplateCreator::TemplateCreator(), TemplateFitAPGenerator::TemplateFitAPGenerator(), and GeSpectrum::ThrowIfInputsInsane().
00067 { 00068 std::string ret_val=GetOption(name,false); 00069 modules::parser::TrimWhiteSpaceBeforeAfter(ret_val); 00070 if(ret_val=="") ret_val=defVal; 00071 return ret_val; 00072 }
int modules::options::GetVectorStringsByDelimiter | ( | const std::string & | name, | |
std::vector< std::string > & | vect, | |||
const char * | delim = ":" | |||
) | const [inherited] |
Fill a vector of strings with tokens found in the named option @ Uses strtok so not suitable for multi-threading (if we ever do something like that).
name | Name of option to use | |
vect | vector to fill with tokens | |
delim | c-string of chars to use as delimiter |
Definition at line 92 of file ModulesOptions.cpp.
References modules::options::GetOption().
Referenced by MakeAnalysedPulses::BeforeFirstEntry(), ExportPulse::BeforeFirstEntry(), and TemplateCreator::TemplateCreator().
00092 { 00093 char line[2048]; 00094 strcpy(line,GetOption(name).c_str()); 00095 char* word = strtok(line,delim); 00096 int num_tokens=0; 00097 for(;word != NULL; num_tokens++) { 00098 //std::cout<<"ModulesOptions:GetVectorStringsByDelimiter() "<<word<<std::endl; 00099 vect.push_back(word); 00100 word = strtok(NULL,delim); 00101 } 00102 return num_tokens; 00103 }
int modules::options::GetVectorStringsByWhiteSpace | ( | const std::string & | name, | |
std::vector< std::string > & | vect | |||
) | const [inherited] |
Fill a vector of strings with whitespace delimited tokens found in the named option.
name | Name of option to use | |
vect | vector to fill with tokens |
Definition at line 82 of file ModulesOptions.cpp.
References modules::options::GetOption().
Referenced by MakeAnalysedPulses::MakeAnalysedPulses(), and MakeDetectorPulses::MakeDetectorPulses().
00082 { 00083 std::stringstream ss(GetOption(name)); 00084 std::string val; 00085 int num_tokens=0; 00086 for(;ss>>val; num_tokens++) { 00087 vect.push_back(val); 00088 } 00089 return num_tokens; 00090 }
bool modules::options::HasOption | ( | const std::string & | name | ) | const [inline, inherited] |
Check if a named option has been set.
name | Name of option to use |
Definition at line 239 of file ModulesOptions.h.
References modules::options::fOptions.
Referenced by BaseModule::BaseModule(), MakeDetectorPulses::BeforeFirstEntry(), MakeAnalysedPulses::BeforeFirstEntry(), modules::options::GetFlag(), PulseCandidateFinder::PulseCandidateFinder(), TemplateFitAPGenerator::TemplateFitAPGenerator(), and TVAnalysedPulseGenerator::TVAnalysedPulseGenerator().
void modules::options::SetAlias | ( | const std::string & | alias | ) | [inline, inherited] |
Set the alias option for this module.
Definition at line 196 of file ModulesOptions.h.
References modules::options::SetOption().
Referenced by modules::reader::AddModule().
00196 {SetOption("alias",alias);};
void TAPGeneratorOptions::SetChannel | ( | const std::string & | ch | ) | [inline] |
Definition at line 22 of file TAPGeneratorOptions.h.
References fChannel.
Referenced by MakeAnalysedPulses::AddGenerator().
00022 { 00023 fChannel = ch; 00024 }
void modules::options::SetOption | ( | const std::string & | key, | |
const std::string & | value | |||
) | [inline, inherited] |
Set the value of an option.
If a previous value was set, it is replaced by this one
key | The name of the option to set | |
value | The new value |
Definition at line 232 of file ModulesOptions.h.
References modules::options::fOptions, and modules::options::fOrder.
Referenced by TDPGeneratorOptions::AddArgument(), AddArgument(), modules::options::AddArgument(), modules::reader::AddOption(), FirstCompleteAPGenerator::FirstCompleteAPGenerator(), MakeAnalysedPulses::MakeAnalysedPulses(), and modules::options::SetAlias().
std::string modules::options::StringDescription | ( | ) | const [inherited] |
Flatten all options into a string.
Used to provide unique identifiers of a module or generator, based on it's configuration
Definition at line 141 of file ModulesOptions.cpp.
References modules::options::fOrder.
Referenced by BaseModule::BaseModule(), TVAnalysedPulseGenerator::TVAnalysedPulseGenerator(), and TVDetectorPulseGenerator::TVDetectorPulseGenerator().
00141 { 00142 const char* key_val_sep="="; 00143 const char* start_key_val="{"; 00144 const char* stop_key_val="}"; 00145 OptionsOrder_t::const_iterator it; 00146 std::string description; 00147 for(it=fOrder.begin();it!=fOrder.end();it++){ 00148 description+=start_key_val; 00149 description+=(*it)->first; 00150 if((*it)->second!=""){ 00151 description+=key_val_sep; 00152 description+=(*it)->second; 00153 } 00154 description+=stop_key_val; 00155 } 00156 return description; 00157 }
std::string TAPGeneratorOptions::fChannel [private] |
Definition at line 30 of file TAPGeneratorOptions.h.
Referenced by GetChannel(), and SetChannel().
bool TAPGeneratorOptions::fDebug [private] |
Definition at line 31 of file TAPGeneratorOptions.h.
Referenced by Debug().
std::string modules::options::fModuleName [protected, inherited] |
Definition at line 228 of file ModulesOptions.h.
Referenced by TDPGeneratorOptions::AddArgument(), AddArgument(), modules::options::AddArgument(), modules::options::CheckValid(), and modules::options::GetOption().