Logo ROOT  
Reference Guide
RooCmdConfig.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * File: $Id: RooCmdConfig.h,v 1.12 2007/05/11 09:11:30 verkerke Exp $
5  * Authors: *
6  * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7  * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8  * *
9  * Copyright (c) 2000-2005, Regents of the University of California *
10  * and Stanford University. All rights reserved. *
11  * *
12  * Redistribution and use in source and binary forms, *
13  * with or without modification, are permitted according to the terms *
14  * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15  *****************************************************************************/
16 
17 #ifndef ROO_CMD_CONFIG
18 #define ROO_CMD_CONFIG
19 
20 #include "TObject.h"
21 #include "TString.h"
22 #include "TList.h"
23 #include "RooCmdArg.h"
24 #include "RooArgSet.h"
25 #include <string>
26 
27 class RooCmdConfig : public TObject {
28 public:
29 
30  RooCmdConfig(const char* methodName);
31  RooCmdConfig(const RooCmdConfig& other) ;
32  ~RooCmdConfig();
33 
34  void setVerbose(Bool_t flag) {
35  // If flag is true verbose messaging is activated
36  _verbose = flag ;
37  }
38 
39  void allowUndefined(Bool_t flag=kTRUE) {
40  // If flag is true the processing of unrecognized RooCmdArgs
41  // is not considered an error
42  _allowUndefined = flag ;
43  }
44  void defineDependency(const char* refArgName, const char* neededArgName) ;
45  void defineMutex(const char* argName1, const char* argName2) ;
46  void defineMutex(const char* argName1, const char* argName2, const char* argName3) ;
47  void defineMutex(const char* argName1, const char* argName2, const char* argName3, const char* argName4) ;
48  void defineMutex(const char* argName1, const char* argName2, const char* argName3, const char* argName4, const char* argName5) ;
49  void defineRequiredArgs(const char* argName1, const char* argName2=0,
50  const char* argName3=0, const char* argName4=0,
51  const char* argName5=0, const char* argName6=0,
52  const char* argName7=0, const char* argName8=0) ;
53 
54  Bool_t defineInt(const char* name, const char* argName, Int_t intNum, Int_t defValue=0) ;
55  Bool_t defineDouble(const char* name, const char* argName, Int_t doubleNum, Double_t defValue=0.) ;
56  Bool_t defineString(const char* name, const char* argName, Int_t stringNum, const char* defValue="",Bool_t appendMode=kFALSE) ;
57  Bool_t defineObject(const char* name, const char* argName, Int_t setNum, const TObject* obj=0, Bool_t isArray=kFALSE) ;
58  Bool_t defineSet(const char* name, const char* argName, Int_t setNum, const RooArgSet* set=0) ;
59 
60  Bool_t process(const RooCmdArg& arg) ;
61  Bool_t process(const RooCmdArg& arg1, const RooCmdArg& arg2,
62  const RooCmdArg& arg3=RooCmdArg::none(), const RooCmdArg& arg4=RooCmdArg::none(),
63  const RooCmdArg& arg5=RooCmdArg::none(), const RooCmdArg& arg6=RooCmdArg::none(),
64  const RooCmdArg& arg7=RooCmdArg::none(), const RooCmdArg& arg8=RooCmdArg::none()) ;
65  Bool_t process(const RooLinkedList& argList) ;
66  /// Process several RooCmdArg using iterators.
67  template<typename It_t>
68  bool process(It_t begin, It_t end) {
69  bool result = false;
70  for (auto it = begin; it != end; ++it) {
71  result |= process(*it);
72  }
73  return result;
74  }
75 
76  Int_t getInt(const char* name, Int_t defaultValue=0) ;
77  Double_t getDouble(const char* name, Double_t defaultValue=0) ;
78  const char* getString(const char* name, const char* defaultValue="",Bool_t convEmptyToNull=kFALSE) ;
79  TObject* getObject(const char* name, TObject* obj=0) ;
80  RooArgSet* getSet(const char* name, RooArgSet* set=0) ;
81  const RooLinkedList& getObjectList(const char* name) ;
82 
83  Bool_t ok(Bool_t verbose) const ;
84 
85  const char* missingArgs() const ;
86 
87  RooLinkedList filterCmdList(RooLinkedList& cmdInList, const char* cmdNameList, Bool_t removeFromInList=kTRUE) ;
88  void stripCmdList(RooLinkedList& cmdList, const char* cmdsToPurge) ;
89  Bool_t hasProcessed(const char* cmdName) const ;
90 
91  void print() ;
92 
93 
94  static Int_t decodeIntOnTheFly(const char* callerID, const char* cmdArgName, Int_t intIdx, Int_t defVal, const RooCmdArg& arg1,
95  const RooCmdArg& arg2=RooCmdArg(), const RooCmdArg& arg3=RooCmdArg(), const RooCmdArg& arg4=RooCmdArg(),
96  const RooCmdArg& arg5=RooCmdArg(), const RooCmdArg& arg6=RooCmdArg(), const RooCmdArg& arg7=RooCmdArg(),
97  const RooCmdArg& arg8=RooCmdArg(), const RooCmdArg& arg9=RooCmdArg()) ;
98 
99  static std::string decodeStringOnTheFly(const char* callerID, const char* cmdArgName, Int_t intIdx, const char* defVal, const RooCmdArg& arg1,
100  const RooCmdArg& arg2=RooCmdArg(), const RooCmdArg& arg3=RooCmdArg(), const RooCmdArg& arg4=RooCmdArg(),
101  const RooCmdArg& arg5=RooCmdArg(), const RooCmdArg& arg6=RooCmdArg(), const RooCmdArg& arg7=RooCmdArg(),
102  const RooCmdArg& arg8=RooCmdArg(), const RooCmdArg& arg9=RooCmdArg()) ;
103 
104  static TObject* decodeObjOnTheFly(const char* callerID, const char* cmdArgName, Int_t objIdx, TObject* defVal, const RooCmdArg& arg1,
105  const RooCmdArg& arg2=RooCmdArg(), const RooCmdArg& arg3=RooCmdArg(), const RooCmdArg& arg4=RooCmdArg(),
106  const RooCmdArg& arg5=RooCmdArg(), const RooCmdArg& arg6=RooCmdArg(), const RooCmdArg& arg7=RooCmdArg(),
107  const RooCmdArg& arg8=RooCmdArg(), const RooCmdArg& arg9=RooCmdArg()) ;
108 
109  static double decodeDoubleOnTheFly(const char* callerID, const char* cmdArgName, int idx, double defVal,
110  std::initializer_list<std::reference_wrapper<const RooCmdArg>> args);
111 
112 protected:
113 
115 
119 
120  TList _iList ; // Integer list
121  TList _dList ; // Double list
122  TList _sList ; // String list
123  TList _oList ; // Object list
124  TList _cList ; // RooArgSet list
125 
126  TList _rList ; // Required cmd list
127  TList _fList ; // Forbidden cmd list
128  TList _mList ; // Mutex cmd list
129  TList _yList ; // Dependency cmd list
130  TList _pList ; // Processed cmd list
131 
132  TIterator* _iIter ; // Iterator over integer list
133  TIterator* _dIter ; // Iterator over double list
134  TIterator* _sIter ; // Iterator over string list
135  TIterator* _oIter ; // Iterator over object list
136  TIterator* _cIter ; // Iterator over RooArgSet list
137  TIterator* _rIter ; // Iterator over required cmd list
138  TIterator* _fIter ; // Iterator over forbidden cmd list
139  TIterator* _mIter ; // Iterator over mutex list
140  TIterator* _yIter ; // Iterator over dependency list
141  TIterator* _pIter ; // Iterator over processed cmd list
142 
143  ClassDef(RooCmdConfig,0) // Configurable parse of RooCmdArg objects
144 };
145 
146 #endif
147 
148 
RooCmdConfig::print
void print()
Print configuration of parser.
Definition: RooCmdConfig.cxx:434
RooCmdArg
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Definition: RooCmdArg.h:27
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
RooCmdConfig::_yIter
TIterator * _yIter
Definition: RooCmdConfig.h:140
RooCmdConfig::process
bool process(It_t begin, It_t end)
Process several RooCmdArg using iterators.
Definition: RooCmdConfig.h:68
RooCmdConfig::hasProcessed
Bool_t hasProcessed(const char *cmdName) const
Return true if RooCmdArg with name 'cmdName' has been processed.
Definition: RooCmdConfig.cxx:679
RooCmdConfig::allowUndefined
void allowUndefined(Bool_t flag=kTRUE)
Definition: RooCmdConfig.h:39
RooCmdConfig::_oIter
TIterator * _oIter
Definition: RooCmdConfig.h:135
RooArgSet.h
RooCmdConfig::defineObject
Bool_t defineObject(const char *name, const char *argName, Int_t setNum, const TObject *obj=0, Bool_t isArray=kFALSE)
Define TObject property name 'name' mapped to object in slot 'setNum' in RooCmdArg with name argName ...
Definition: RooCmdConfig.cxx:387
RooCmdConfig::_error
Bool_t _error
Definition: RooCmdConfig.h:117
RooCmdConfig::_verbose
Bool_t _verbose
Definition: RooCmdConfig.h:116
RooCmdConfig::process
Bool_t process(const RooCmdArg &arg)
Process given RooCmdArg.
Definition: RooCmdConfig.cxx:513
RooCmdConfig::_rList
TList _rList
Definition: RooCmdConfig.h:126
RooCmdConfig::_name
TString _name
Definition: RooCmdConfig.h:114
RooCmdConfig::_dIter
TIterator * _dIter
Definition: RooCmdConfig.h:133
RooCmdConfig::filterCmdList
RooLinkedList filterCmdList(RooLinkedList &cmdInList, const char *cmdNameList, Bool_t removeFromInList=kTRUE)
Utility function to filter commands listed in cmdNameList from cmdInList.
Definition: RooCmdConfig.cxx:805
RooCmdConfig::RooCmdConfig
RooCmdConfig(const char *methodName)
Constructor taking descriptive name of owner/user which is used as prefix for any warning or error me...
Definition: RooCmdConfig.cxx:57
RooCmdConfig::defineDouble
Bool_t defineDouble(const char *name, const char *argName, Int_t doubleNum, Double_t defValue=0.)
Define Double_t property name 'name' mapped to Double_t in slot 'doubleNum' in RooCmdArg with name ar...
Definition: RooCmdConfig.cxx:338
RooCmdConfig::setVerbose
void setVerbose(Bool_t flag)
Definition: RooCmdConfig.h:34
RooCmdConfig::defineRequiredArgs
void defineRequiredArgs(const char *argName1, const char *argName2=0, const char *argName3=0, const char *argName4=0, const char *argName5=0, const char *argName6=0, const char *argName7=0, const char *argName8=0)
Add condition that any of listed arguments must be processed for parsing to be declared successful.
Definition: RooCmdConfig.cxx:199
TList.h
RooCmdConfig::defineSet
Bool_t defineSet(const char *name, const char *argName, Int_t setNum, const RooArgSet *set=0)
Define TObject property name 'name' mapped to object in slot 'setNum' in RooCmdArg with name argName ...
Definition: RooCmdConfig.cxx:412
RooCmdConfig::_sList
TList _sList
Definition: RooCmdConfig.h:122
RooCmdConfig::_mList
TList _mList
Definition: RooCmdConfig.h:128
RooCmdConfig::_rIter
TIterator * _rIter
Definition: RooCmdConfig.h:137
TString
Basic string class.
Definition: TString.h:136
RooCmdConfig::getString
const char * getString(const char *name, const char *defaultValue="", Bool_t convEmptyToNull=kFALSE)
Return string property registered with name 'name'.
Definition: RooCmdConfig.cxx:715
RooCmdArg::none
static const RooCmdArg & none()
Return reference to null argument.
Definition: RooCmdArg.cxx:52
RooCmdConfig::_mIter
TIterator * _mIter
Definition: RooCmdConfig.h:139
TString.h
bool
TIterator
Iterator abstract base class.
Definition: TIterator.h:30
RooCmdConfig::defineMutex
void defineMutex(const char *argName1, const char *argName2)
Define arguments named argName1 and argName2 mutually exclusive.
Definition: RooCmdConfig.cxx:257
RooCmdConfig::getInt
Int_t getInt(const char *name, Int_t defaultValue=0)
Return integer property registered with name 'name'.
Definition: RooCmdConfig.cxx:690
RooCmdConfig::_pIter
TIterator * _pIter
Definition: RooCmdConfig.h:141
RooCmdConfig::~RooCmdConfig
~RooCmdConfig()
Destructor.
Definition: RooCmdConfig.cxx:168
RooCmdConfig
Class RooCmdConfig is a configurable parser for RooCmdArg named arguments.
Definition: RooCmdConfig.h:27
RooCmdConfig::_cList
TList _cList
Definition: RooCmdConfig.h:124
RooCmdConfig::_pList
TList _pList
Definition: RooCmdConfig.h:130
RooCmdConfig::decodeObjOnTheFly
static TObject * decodeObjOnTheFly(const char *callerID, const char *cmdArgName, Int_t objIdx, TObject *defVal, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg())
Static decoder function allows to retrieve object property from set of RooCmdArgs For use in base mem...
Definition: RooCmdConfig.cxx:879
RooCmdConfig::getSet
RooArgSet * getSet(const char *name, RooArgSet *set=0)
Return RooArgSet property registered with name 'name'.
Definition: RooCmdConfig.cxx:738
RooCmdConfig::_fIter
TIterator * _fIter
Definition: RooCmdConfig.h:138
RooCmdConfig::decodeDoubleOnTheFly
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.
Definition: RooCmdConfig.cxx:897
RooCmdConfig::getObject
TObject * getObject(const char *name, TObject *obj=0)
Return TObject property registered with name 'name'.
Definition: RooCmdConfig.cxx:727
RooCmdConfig::_oList
TList _oList
Definition: RooCmdConfig.h:123
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
RooLinkedList
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
Definition: RooLinkedList.h:35
RooCmdConfig::stripCmdList
void stripCmdList(RooLinkedList &cmdList, const char *cmdsToPurge)
Utility function that strips command names listed (comma separated) in cmdsToPurge from cmdList.
Definition: RooCmdConfig.cxx:781
RooCmdConfig::getObjectList
const RooLinkedList & getObjectList(const char *name)
Return list of objects registered with name 'name'.
Definition: RooCmdConfig.cxx:749
RooCmdConfig::_fList
TList _fList
Definition: RooCmdConfig.h:127
RooCmdConfig::defineString
Bool_t defineString(const char *name, const char *argName, Int_t stringNum, const char *defValue="", Bool_t appendMode=kFALSE)
Define Double_t property name 'name' mapped to Double_t in slot 'stringNum' in RooCmdArg with name ar...
Definition: RooCmdConfig.cxx:362
RooCmdConfig::_allowUndefined
Bool_t _allowUndefined
Definition: RooCmdConfig.h:118
RooCmdConfig::_yList
TList _yList
Definition: RooCmdConfig.h:129
RooCmdConfig::defineDependency
void defineDependency(const char *refArgName, const char *neededArgName)
Define that processing argument name refArgName requires processing of argument named neededArgName t...
Definition: RooCmdConfig.cxx:246
RooCmdArg.h
RooCmdConfig::_iList
TList _iList
Definition: RooCmdConfig.h:120
RooCmdConfig::defineInt
Bool_t defineInt(const char *name, const char *argName, Int_t intNum, Int_t defValue=0)
Define integer property name 'name' mapped to integer in slot 'intNum' in RooCmdArg with name argName...
Definition: RooCmdConfig.cxx:316
RooCmdConfig::_dList
TList _dList
Definition: RooCmdConfig.h:121
RooCmdConfig::decodeStringOnTheFly
static std::string decodeStringOnTheFly(const char *callerID, const char *cmdArgName, Int_t intIdx, const char *defVal, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg())
Static decoder function allows to retrieve string property from set of RooCmdArgs For use in base mem...
Definition: RooCmdConfig.cxx:854
Double_t
double Double_t
Definition: RtypesCore.h:59
TObject.h
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
RooCmdConfig::decodeIntOnTheFly
static Int_t decodeIntOnTheFly(const char *callerID, const char *cmdArgName, Int_t intIdx, Int_t defVal, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg())
Static decoder function allows to retrieve integer property from set of RooCmdArgs For use in base me...
Definition: RooCmdConfig.cxx:834
name
char name[80]
Definition: TGX11.cxx:110
RooCmdConfig::ok
Bool_t ok(Bool_t verbose) const
Return true of parsing was successful.
Definition: RooCmdConfig.cxx:761
genreflex::verbose
bool verbose
Definition: rootcling_impl.cxx:133
RooCmdConfig::getDouble
Double_t getDouble(const char *name, Double_t defaultValue=0)
Return Double_t property registered with name 'name'.
Definition: RooCmdConfig.cxx:702
RooCmdConfig::missingArgs
const char * missingArgs() const
Return string with names of arguments that were required, but not processed.
Definition: RooCmdConfig.cxx:220
TList
A doubly linked list.
Definition: TList.h:44
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:29
int
RooCmdConfig::_iIter
TIterator * _iIter
Definition: RooCmdConfig.h:132
RooCmdConfig::_sIter
TIterator * _sIter
Definition: RooCmdConfig.h:134
RooCmdConfig::_cIter
TIterator * _cIter
Definition: RooCmdConfig.h:136