Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
27class RooCmdConfig : public TObject {
28public:
29
30 RooCmdConfig(const char* methodName);
31 RooCmdConfig(const RooCmdConfig& other) ;
33
34 void setVerbose(Bool_t flag) {
35 // If flag is true verbose messaging is activated
36 _verbose = flag ;
37 }
38
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
112protected:
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
const Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
const Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassDef(name, id)
Definition Rtypes.h:325
char name[80]
Definition TGX11.cxx:110
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:35
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Definition RooCmdArg.h:27
static const RooCmdArg & none()
Return reference to null argument.
Definition RooCmdArg.cxx:52
Class RooCmdConfig is a configurable parser for RooCmdArg named arguments.
TObject * getObject(const char *name, TObject *obj=0)
Return TObject property registered with name 'name'.
~RooCmdConfig()
Destructor.
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...
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...
TIterator * _rIter
void defineMutex(const char *argName1, const char *argName2)
Define arguments named argName1 and argName2 mutually exclusive.
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...
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...
TIterator * _iIter
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 ...
TIterator * _fIter
TIterator * _oIter
const char * getString(const char *name, const char *defaultValue="", Bool_t convEmptyToNull=kFALSE)
Return string property registered with name 'name'.
TIterator * _pIter
TIterator * _sIter
void setVerbose(Bool_t flag)
Int_t getInt(const char *name, Int_t defaultValue=0)
Return integer property registered with name 'name'.
const RooLinkedList & getObjectList(const char *name)
Return list of objects registered with name 'name'.
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...
TIterator * _mIter
void defineDependency(const char *refArgName, const char *neededArgName)
Define that processing argument name refArgName requires processing of argument named neededArgName t...
Double_t getDouble(const char *name, Double_t defaultValue=0)
Return Double_t property registered with name 'name'.
void allowUndefined(Bool_t flag=kTRUE)
void stripCmdList(RooLinkedList &cmdList, const char *cmdsToPurge)
Utility function that strips command names listed (comma separated) in cmdsToPurge from cmdList.
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 ...
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...
RooArgSet * getSet(const char *name, RooArgSet *set=0)
Return RooArgSet property registered with name 'name'.
bool process(It_t begin, It_t end)
Process several RooCmdArg using iterators.
Bool_t ok(Bool_t verbose) const
Return true of parsing was successful.
TIterator * _yIter
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.
RooLinkedList filterCmdList(RooLinkedList &cmdInList, const char *cmdNameList, Bool_t removeFromInList=kTRUE)
Utility function to filter commands listed in cmdNameList from cmdInList.
TIterator * _cIter
TIterator * _dIter
Bool_t _allowUndefined
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.
Bool_t process(const RooCmdArg &arg)
Process given RooCmdArg.
const char * missingArgs() const
Return string with names of arguments that were required, but not processed.
void print()
Print configuration of parser.
Bool_t hasProcessed(const char *cmdName) const
Return true if RooCmdArg with name 'cmdName' has been processed.
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
Iterator abstract base class.
Definition TIterator.h:30
A doubly linked list.
Definition TList.h:38
Mother of all ROOT objects.
Definition TObject.h:41
Basic string class.
Definition TString.h:136