41template<
class Collection>
42typename Collection::const_iterator
findVar(Collection
const&
coll,
const char *
name) {
84 _verbose(
other._verbose),
86 _allowUndefined(
other._allowUndefined),
143 coutE(InputArguments) <<
"RooCmdConfig::defineInt: name '" <<
name <<
"' already defined" << std::endl ;
150 ri.argName = argName;
165 coutE(InputArguments) <<
"RooCmdConfig::defineDouble: name '" <<
name <<
"' already defined" << std::endl ;
172 rd.argName = argName;
189 coutE(InputArguments) <<
"RooCmdConfig::defineString: name '" <<
name <<
"' already defined" << std::endl ;
196 rs.argName = argName;
198 rs.appendMode = appendMode;
215 coutE(InputArguments) <<
"RooCmdConfig::defineObject: name '" <<
name <<
"' already defined" << std::endl ;
222 os.argName = argName;
241 coutE(InputArguments) <<
"RooCmdConfig::defineObject: name '" <<
name <<
"' already defined" << std::endl ;
248 cs.argName = argName;
262 for(
auto const& ri :
_iList) {
263 std::cout << ri.name <<
"[int] = " << ri.val << std::endl ;
268 std::cout <<
rd.name <<
"[double] = " <<
rd.val << std::endl ;
273 std::cout <<
rs.name <<
"[string] = \"" <<
rs.val <<
"\"" << std::endl ;
278 std::cout <<
ro.name <<
"[TObject] = " ;
279 auto const * obj =
ro.val.At(0);
281 std::cout << obj->GetName() << std::endl ;
284 std::cout <<
"(null)" << std::endl ;
318 coutE(InputArguments) <<
_name <<
" ERROR: argument " <<
opc <<
" not allowed in this context" << std::endl ;
330 std::cout <<
"RooCmdConfig::process: " <<
opc <<
" has unprocessed dependent " <<
dep->GetTitle()
331 <<
", adding to required list" << std::endl ;
335 std::cout <<
"RooCmdConfig::process: " <<
opc <<
" dependent " <<
dep->GetTitle() <<
" is already processed" << std::endl ;
344 std::cout <<
"RooCmdConfig::process: " <<
opc <<
" excludes " << mutex->
GetTitle()
345 <<
", adding to forbidden list" << std::endl ;
356 ri.val = arg.
getInt(ri.num) ;
359 std::cout <<
"RooCmdConfig::process " << ri.name <<
"[int]" <<
" set to " << ri.val << std::endl ;
370 std::cout <<
"RooCmdConfig::process " <<
rd.name <<
"[double]" <<
" set to " <<
rd.val << std::endl ;
377 if (
rs.argName ==
opc) {
382 if (!
rs.val.empty() &&
rs.appendMode) {
390 std::cout <<
"RooCmdConfig::process " <<
rs.name <<
"[string]" <<
" set to " <<
rs.val << std::endl ;
398 if(!os.appendMode) os.val.Clear();
402 std::cout <<
"RooCmdConfig::process " << os.name <<
"[TObject]" <<
" set to " ;
404 std::cout << os.val.At(0)->GetName() << std::endl ;
406 std::cout <<
"(null)" << std::endl ;
418 std::cout <<
"RooCmdConfig::process " <<
cs.name <<
"[RooArgSet]" <<
" set to " ;
420 std::cout <<
cs.val->GetName() << std::endl ;
422 std::cout <<
"(null)" << std::endl ;
431 coutE(InputArguments) <<
_name <<
" ERROR: unrecognized command: " <<
opc << std::endl ;
507 return (
convEmptyToNull && found->val.empty()) ? nullptr : found->val.c_str();
519 return found !=
_oList.end() ? found->val.At(0) :
defVal ;
556 if (!
margs.empty()) {
557 coutE(InputArguments) <<
_name <<
" ERROR: missing arguments: " <<
margs << std::endl ;
559 coutE(InputArguments) <<
_name <<
" ERROR: illegal combination of arguments and/or missing arguments" << std::endl ;
613 std::initializer_list<std::reference_wrapper<const RooCmdArg>> args) {
617 pc.
process(args.begin(), args.end());
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
const_iterator begin() const
const_iterator end() const
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Named container for two doubles, two integers two object points and three string pointers that can be...
const RooArgSet * getSet(Int_t idx) const
Return RooArgSet stored in slot idx.
double getDouble(Int_t idx) const
Return double stored in slot idx.
RooLinkedList const & subArgs() const
Return list of sub-arguments in this RooCmdArg.
Int_t getInt(Int_t idx) const
bool prefixSubArgs() const
const char * opcode() const
const char * getString(Int_t idx) const
Return string stored in slot idx.
const TObject * getObject(Int_t idx) const
Return TObject stored in slot idx.
Configurable parser for RooCmdArg named arguments.
std::vector< Var< RooArgSet * > > _cList
RooArgSet list.
bool process(const RooCmdArg &arg)
Process given RooCmdArg.
TList _pList
Processed cmd list.
bool hasProcessed(const char *cmdName) const
Return true if RooCmdArg with name 'cmdName' has been processed.
std::vector< Var< RooLinkedList > > _oList
Object list.
std::vector< Var< int > > _iList
Integer list.
std::vector< Var< double > > _dList
Double list.
double getDouble(const char *name, double defaultValue=0.0) const
Return double property registered with name 'name'.
void print() const
Print configuration of parser.
void defineDependency(const char *refArgName, const char *neededArgName)
Define that processing argument name refArgName requires processing of argument named neededArgName t...
bool defineDouble(const char *name, const char *argName, int doubleNum, double defValue=0.0)
Define double property name 'name' mapped to double in slot 'doubleNum' in RooCmdArg with name argNam...
static void stripCmdList(RooLinkedList &cmdList, const char *cmdsToPurge)
Utility function that strips command names listed (comma separated) in cmdsToPurge from cmdList.
RooArgSet * getSet(const char *name, RooArgSet *set=nullptr) const
Return RooArgSet property registered with name 'name'.
bool defineSet(const char *name, const char *argName, int setNum, const RooArgSet *set=nullptr)
Define TObject property name 'name' mapped to object in slot 'setNum' in RooCmdArg with name argName ...
std::vector< Var< std::string > > _sList
String list.
TList _yList
Dependency cmd list.
TList _fList
Forbidden cmd list.
bool ok(bool verbose) const
Return true of parsing was successful.
bool defineObject(const char *name, const char *argName, int setNum, const TObject *obj=nullptr, bool isArray=false)
Define TObject property name 'name' mapped to object in slot 'setNum' in RooCmdArg with name argName ...
const char * getString(const char *name, const char *defaultValue="", bool convEmptyToNull=false) const
Return string property registered with name 'name'.
bool defineString(const char *name, const char *argName, int stringNum, const char *defValue="", bool appendMode=false)
Define double property name 'name' mapped to double in slot 'stringNum' in RooCmdArg with name argNam...
static double decodeDoubleOnTheFly(const char *callerID, const char *cmdArgName, int idx, double defVal, std::initializer_list< std::reference_wrapper< const RooCmdArg > > args)
Find a given double in a list of RooCmdArg.
const RooLinkedList & getObjectList(const char *name) const
Return list of objects registered with name 'name'.
TList _mList
Mutex cmd list.
bool defineInt(const char *name, const char *argName, int intNum, int defValue=0)
Define integer property name 'name' mapped to integer in slot 'intNum' in RooCmdArg with name argName...
void allowUndefined(bool flag=true)
If flag is true the processing of unrecognized RooCmdArgs is not considered an error.
int getInt(const char *name, int defaultValue=0) const
Return integer property registered with name 'name'.
RooCmdConfig(RooStringView methodName)
Constructor taking descriptive name of owner/user which is used as prefix for any warning or error me...
RooLinkedList filterCmdList(RooLinkedList &cmdInList, const char *cmdNameList, bool removeFromInList=true) const
Utility function to filter commands listed in cmdNameList from cmdInList.
std::string missingArgs() const
Return string with names of arguments that were required, but not processed.
TObject * getObject(const char *name, TObject *obj=nullptr) const
Return TObject property registered with name 'name'.
TList _rList
Required cmd list.
Collection class for internal use, storing a collection of RooAbsArg pointers in a doubly linked list...
TObject * At(int index) const
Return object stored in sequential position given by index.
The RooStringView is a wrapper around a C-style string that can also be constructed from a std::strin...
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
void Add(TObject *obj) override
TObject * Remove(TObject *obj) override
Remove object from the list.
The TNamed class is the base class for all named ROOT classes.
const char * GetName() const override
Returns name of object.
Collectable string class.
Mother of all ROOT objects.
virtual const char * GetTitle() const
Returns title of object.
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
std::vector< std::string > Split(std::string_view str, std::string_view delims, bool skipEmpty=false)
Splits a string at each character in delims.