Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 "RooLinkedList.h"
22#include <string>
23
24class RooArgSet ;
25
26class RooCmdArg : public TNamed {
27public:
28
29 RooCmdArg();
30 /// Constructor from payload parameters. Note that the first payload
31 /// parameter has no default value, because otherwise the implicit creation
32 /// of a RooCmdArg from `const char*` would be possible. This would cause
33 /// ambiguity problems in RooFit code. It is not a problem that the first
34 /// parameter always has to be given, because creating a RooCmdArg with only
35 /// a name and no payload doesn't make sense anyway.
36 RooCmdArg(const char* name,
37 Int_t i1, Int_t i2=0,
38 double d1=0.0, double d2=0.0,
39 const char* s1=nullptr, const char* s2=nullptr,
40 const TObject* o1=nullptr, const TObject* o2=nullptr, const RooCmdArg* ca=nullptr, const char* s3=nullptr,
41 const RooArgSet* c1=nullptr, const RooArgSet* c2=nullptr) ;
42 RooCmdArg(const RooCmdArg& other) ;
43 RooCmdArg& operator=(const RooCmdArg& other) ;
44 void addArg(const RooCmdArg& arg) ;
45 void setProcessRecArgs(bool flag, bool prefix=true) {
46 // If true flag this object as containing recursive arguments
47 _procSubArgs = flag ;
48 _prefixSubArgs = prefix ;
49 }
50
51 /// Return list of sub-arguments in this RooCmdArg
52 RooLinkedList const& subArgs() const { return _argList ; }
53
54 /// Return list of sub-arguments in this RooCmdArg
56
57 TObject* Clone(const char* newName=nullptr) const override {
58 RooCmdArg* newarg = new RooCmdArg(*this) ;
59 if (newName) { newarg->SetName(newName) ; }
60 return newarg ;
61 }
62
63 ~RooCmdArg() override;
64
65 static const RooCmdArg& none() ;
66
67 const char* opcode() const {
68 // Return operator code
69 return strlen(GetName()) ? GetName() : nullptr ;
70 }
71
72 void setInt(Int_t idx,Int_t value) {
73 _i[idx] = value ;
74 }
75 void setDouble(Int_t idx,double value) {
76 _d[idx] = value ;
77 }
78 void setString(Int_t idx,const char* value) {
79 _s[idx] = value ;
80 }
82 _o[idx] = value ;
83 }
84 void setSet(Int_t idx,const RooArgSet& set) ;
85
86 Int_t getInt(Int_t idx) const {
87 // Return integer stored in slot idx
88 return _i[idx] ;
89 }
90 /// Return double stored in slot idx
91 double getDouble(Int_t idx) const {
92 return _d[idx] ;
93 }
94 /// Return string stored in slot idx
95 const char* getString(Int_t idx) const {
96 return (!_s[idx].empty()) ? _s[idx].c_str() : nullptr ;
97 }
98 /// Return TObject stored in slot idx
99 const TObject* getObject(Int_t idx) const {
100 return _o[idx] ;
101 }
102
103 const RooArgSet* getSet(Int_t idx) const ;
104
105 void Print(const char* = "") const override;
106
107 bool procSubArgs() const { return _procSubArgs; }
108 bool prefixSubArgs() const { return _prefixSubArgs; }
109
110private:
111
112 static const RooCmdArg _none ; ///< Static instance of null object
113
114 // Payload
115 double _d[2] ; ///< Payload doubles
116 Int_t _i[2] ; ///< Payload integers
117 std::string _s[3] ; ///< Payload strings
118 TObject* _o[2] ; ///< Payload objects
119 bool _procSubArgs ; ///< If true argument requires recursive processing
120 RooArgSet* _c ; ///< Payload RooArgSets
121 RooLinkedList _argList ; ///< Payload sub-arguments
122 bool _prefixSubArgs ; ///< Prefix sub-arguments with container name?
123
124 ClassDefOverride(RooCmdArg,0) // Generic named argument container
125};
126
127#endif
#define s1(x)
Definition RSha256.hxx:91
int Int_t
Definition RtypesCore.h:45
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
Definition TGX11.cxx:110
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
Named container for two doubles, two integers two object points and three string pointers that can be...
Definition RooCmdArg.h:26
const RooArgSet * getSet(Int_t idx) const
Return RooArgSet stored in slot idx.
RooArgSet * _c
Payload RooArgSets.
Definition RooCmdArg.h:120
double getDouble(Int_t idx) const
Return double stored in slot idx.
Definition RooCmdArg.h:91
void Print(const char *="") const override
Print contents.
RooLinkedList _argList
Payload sub-arguments.
Definition RooCmdArg.h:121
void addArg(const RooCmdArg &arg)
Utility function to add nested RooCmdArg to payload of this RooCmdArg.
Int_t _i[2]
Payload integers.
Definition RooCmdArg.h:116
RooLinkedList const & subArgs() const
Return list of sub-arguments in this RooCmdArg.
Definition RooCmdArg.h:52
void setObject(Int_t idx, TObject *value)
Definition RooCmdArg.h:81
void setInt(Int_t idx, Int_t value)
Definition RooCmdArg.h:72
RooCmdArg & operator=(const RooCmdArg &other)
Assignment operator.
static const RooCmdArg & none()
Return reference to null argument.
Definition RooCmdArg.cxx:51
Int_t getInt(Int_t idx) const
Definition RooCmdArg.h:86
void setSet(Int_t idx, const RooArgSet &set)
bool procSubArgs() const
Definition RooCmdArg.h:107
RooLinkedList & subArgs()
Return list of sub-arguments in this RooCmdArg.
Definition RooCmdArg.h:55
std::string _s[3]
Payload strings.
Definition RooCmdArg.h:117
bool prefixSubArgs() const
Definition RooCmdArg.h:108
bool _procSubArgs
If true argument requires recursive processing.
Definition RooCmdArg.h:119
RooCmdArg()
Default constructor.
Definition RooCmdArg.cxx:60
TObject * _o[2]
Payload objects.
Definition RooCmdArg.h:118
const char * opcode() const
Definition RooCmdArg.h:67
static const RooCmdArg _none
Static instance of null object.
Definition RooCmdArg.h:112
double _d[2]
Payload doubles.
Definition RooCmdArg.h:115
TObject * Clone(const char *newName=nullptr) const override
Make a clone of an object using the Streamer facility.
Definition RooCmdArg.h:57
bool _prefixSubArgs
Prefix sub-arguments with container name?
Definition RooCmdArg.h:122
void setProcessRecArgs(bool flag, bool prefix=true)
Definition RooCmdArg.h:45
~RooCmdArg() override
Destructor.
const char * getString(Int_t idx) const
Return string stored in slot idx.
Definition RooCmdArg.h:95
void setDouble(Int_t idx, double value)
Definition RooCmdArg.h:75
void setString(Int_t idx, const char *value)
Definition RooCmdArg.h:78
const TObject * getObject(Int_t idx) const
Return TObject stored in slot idx.
Definition RooCmdArg.h:99
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:140
Mother of all ROOT objects.
Definition TObject.h:41
return c1
Definition legend1.C:41
return c2
Definition legend2.C:14