Logo ROOT  
Reference Guide
RooCmdArg.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id: RooCmdArg.h,v 1.10 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_ARG
18#define ROO_CMD_ARG
19
20#include "TNamed.h"
21#include "TString.h"
22#include "RooLinkedList.h"
23
24#include <string>
25class RooAbsData ;
26class RooArgSet ;
27
28class RooCmdArg : public TNamed {
29public:
30
31 RooCmdArg();
32 RooCmdArg(const char* name,
33 Int_t i1=0, Int_t i2=0,
34 Double_t d1=0, Double_t d2=0,
35 const char* s1=0, const char* s2=0,
36 const TObject* o1=0, const TObject* o2=0, const RooCmdArg* ca=0, const char* s3=0,
37 const RooArgSet* c1=0, const RooArgSet* c2=0) ;
38 RooCmdArg(const RooCmdArg& other) ;
39 RooCmdArg& operator=(const RooCmdArg& other) ;
40 void addArg(const RooCmdArg& arg) ;
41 void setProcessRecArgs(Bool_t flag, Bool_t prefix=kTRUE) {
42 // If true flag this object as containing recursive arguments
43 _procSubArgs = flag ;
44 _prefixSubArgs = prefix ;
45 }
46
48 // Return list of sub-arguments in this RooCmdArg
49 return _argList ;
50 }
51
52 virtual TObject* Clone(const char* newName=0) const {
53 RooCmdArg* newarg = new RooCmdArg(*this) ;
54 if (newName) { newarg->SetName(newName) ; }
55 return newarg ;
56 }
57
58 virtual ~RooCmdArg();
59
60 static const RooCmdArg& none() ;
61
62 const char* opcode() const {
63 // Return operator code
64 return strlen(GetName()) ? GetName() : 0 ;
65 }
66
67 void setInt(Int_t idx,Int_t value) {
68 _i[idx] = value ;
69 }
70 void setDouble(Int_t idx,Double_t value) {
71 _d[idx] = value ;
72 }
73 void setString(Int_t idx,const char* value) {
74 _s[idx] = value ;
75 }
76 void setObject(Int_t idx,TObject* value) {
77 _o[idx] = value ;
78 }
79 void setSet(Int_t idx,const RooArgSet& set) ;
80
81 Int_t getInt(Int_t idx) const {
82 // Return integer stored in slot idx
83 return _i[idx] ;
84 }
85 Double_t getDouble(Int_t idx) const {
86 // Return double stored in slot idx
87 return _d[idx] ;
88 }
89 const char* getString(Int_t idx) const {
90 // Return string stored in slot idx
91 return (_s[idx].size()>0) ? _s[idx].c_str() : 0 ;
92 }
93 const TObject* getObject(Int_t idx) const {
94 // Return TObject stored in slot idx
95 return _o[idx] ;
96 }
97
98 const RooArgSet* getSet(Int_t idx) const ;
99
100 void Print(const char* = "") const;
101
102protected:
103
104 static const RooCmdArg _none ; // Static instance of null object
105 friend class RooCmdConfig ;
106
107private:
108
109 friend class RooAbsCollection ;
110
111 // Payload
112 Double_t _d[2] ; // Payload doubles
113 Int_t _i[2] ; // Payload integers
114 std::string _s[3] ; // Payload strings
115 TObject* _o[2] ; // Payload objects
116 Bool_t _procSubArgs ; // If true argument requires recursive processing
117 RooArgSet* _c ; // Payload RooArgSets
118 RooLinkedList _argList ; // Payload sub-arguments
119 Bool_t _prefixSubArgs ; // Prefix subarguments with container name?
120
121 ClassDef(RooCmdArg,2) // Generic named argument container
122};
123
124#endif
125
126
#define s1(x)
Definition: RSha256.hxx:91
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassDef(name, id)
Definition: Rtypes.h:326
char name[80]
Definition: TGX11.cxx:109
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects.
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:39
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Definition: RooCmdArg.h:28
Double_t getDouble(Int_t idx) const
Definition: RooCmdArg.h:85
const RooArgSet * getSet(Int_t idx) const
Return RooArgSet stored in slot idx.
Definition: RooCmdArg.cxx:200
RooArgSet * _c
Definition: RooCmdArg.h:117
RooLinkedList _argList
Definition: RooCmdArg.h:118
void addArg(const RooCmdArg &arg)
Utility function to add nested RooCmdArg to payload of this RooCmdArg.
Definition: RooCmdArg.cxx:190
Int_t _i[2]
Definition: RooCmdArg.h:113
void setObject(Int_t idx, TObject *value)
Definition: RooCmdArg.h:76
void setInt(Int_t idx, Int_t value)
Definition: RooCmdArg.h:67
void setDouble(Int_t idx, Double_t value)
Definition: RooCmdArg.h:70
RooCmdArg & operator=(const RooCmdArg &other)
Assignment operator.
Definition: RooCmdArg.cxx:142
static const RooCmdArg & none()
Return reference to null argument.
Definition: RooCmdArg.cxx:52
Bool_t _procSubArgs
Definition: RooCmdArg.h:116
Bool_t _prefixSubArgs
Definition: RooCmdArg.h:119
virtual ~RooCmdArg()
Destructor.
Definition: RooCmdArg.cxx:179
Int_t getInt(Int_t idx) const
Definition: RooCmdArg.h:81
void setSet(Int_t idx, const RooArgSet &set)
Definition: RooCmdArg.cxx:208
RooLinkedList & subArgs()
Definition: RooCmdArg.h:47
std::string _s[3]
Definition: RooCmdArg.h:114
Double_t _d[2]
Definition: RooCmdArg.h:112
RooCmdArg()
Default constructor.
Definition: RooCmdArg.cxx:61
TObject * _o[2]
Definition: RooCmdArg.h:115
void Print(const char *="") const
Print contents.
Definition: RooCmdArg.cxx:220
const char * opcode() const
Definition: RooCmdArg.h:62
static const RooCmdArg _none
Definition: RooCmdArg.h:104
void setProcessRecArgs(Bool_t flag, Bool_t prefix=kTRUE)
Definition: RooCmdArg.h:41
const char * getString(Int_t idx) const
Definition: RooCmdArg.h:89
void setString(Int_t idx, const char *value)
Definition: RooCmdArg.h:73
const TObject * getObject(Int_t idx) const
Definition: RooCmdArg.h:93
virtual TObject * Clone(const char *newName=0) const
Make a clone of an object using the Streamer facility.
Definition: RooCmdArg.h:52
Class RooCmdConfig is a configurable parser for RooCmdArg named arguments.
Definition: RooCmdConfig.h:27
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
Definition: RooLinkedList.h:36
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
Mother of all ROOT objects.
Definition: TObject.h:37
return c1
Definition: legend1.C:41
return c2
Definition: legend2.C:14