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
43 RooCmdArg(const RooCmdArg& other) ;
44 RooCmdArg& operator=(const RooCmdArg& other) ;
45 void addArg(const RooCmdArg& arg) ;
46 void setProcessRecArgs(bool flag, bool prefix=true) {
47 // If true flag this object as containing recursive arguments
48 _procSubArgs = flag ;
49 _prefixSubArgs = prefix ;
50 }
51
52 /// Return list of sub-arguments in this RooCmdArg
53 RooLinkedList const& subArgs() const { return _argList ; }
54
55 /// Return list of sub-arguments in this RooCmdArg
57
58 TObject* Clone(const char* newName=nullptr) const override {
59 RooCmdArg* newarg = new RooCmdArg(*this) ;
60 if (newName) { newarg->SetName(newName) ; }
61 return newarg ;
62 }
63
64 ~RooCmdArg() override;
65
66 static const RooCmdArg& none() ;
67
68 const char* opcode() const {
69 // Return operator code
70 return strlen(GetName()) ? GetName() : nullptr ;
71 }
72
73 void setInt(Int_t idx,Int_t value) {
74 _i[idx] = value ;
75 }
76 void setDouble(Int_t idx,double value) {
77 _d[idx] = value ;
78 }
79 void setString(Int_t idx,const char* value) {
80 _s[idx] = value ;
81 }
83 _o[idx] = value ;
84 }
85 void setSet(Int_t idx,const RooArgSet& set) ;
86
87 Int_t getInt(Int_t idx) const {
88 // Return integer stored in slot idx
89 return _i[idx] ;
90 }
91 /// Return double stored in slot idx
92 double getDouble(Int_t idx) const {
93 return _d[idx] ;
94 }
95 /// Return string stored in slot idx
96 const char* getString(Int_t idx) const {
97 return (!_s[idx].empty()) ? _s[idx].c_str() : nullptr ;
98 }
99 /// Return TObject stored in slot idx
100 const TObject* getObject(Int_t idx) const {
101 return _o[idx] ;
102 }
103
104 const RooArgSet* getSet(Int_t idx) const ;
105
106 void Print(const char* = "") const override;
107
108 bool procSubArgs() const { return _procSubArgs; }
109 bool prefixSubArgs() const { return _prefixSubArgs; }
110
111 std::string constructorCode() const;
112
113private:
114
115 static const RooCmdArg _none ; ///< Static instance of null object
116
117 // Payload
118 double _d[2] ; ///< Payload doubles
119 Int_t _i[2] ; ///< Payload integers
120 std::string _s[3] ; ///< Payload strings
121 TObject* _o[2] ; ///< Payload objects
122 bool _procSubArgs = false; ///< If true argument requires recursive processing
123 RooArgSet *_c = nullptr; ///< Payload RooArgSets
124 RooLinkedList _argList ; ///< Payload sub-arguments
125 bool _prefixSubArgs = true; ///< Prefix sub-arguments with container name?
126
127 ClassDefOverride(RooCmdArg,0) // Generic named argument container
128};
129
130#endif
#define s1(x)
Definition RSha256.hxx:91
int Int_t
Definition RtypesCore.h:45
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
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:24
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:123
double getDouble(Int_t idx) const
Return double stored in slot idx.
Definition RooCmdArg.h:92
void Print(const char *="") const override
This method must be overridden when a class wants to print itself.
RooLinkedList _argList
Payload sub-arguments.
Definition RooCmdArg.h:124
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:119
RooLinkedList const & subArgs() const
Return list of sub-arguments in this RooCmdArg.
Definition RooCmdArg.h:53
void setObject(Int_t idx, TObject *value)
Definition RooCmdArg.h:82
void setInt(Int_t idx, Int_t value)
Definition RooCmdArg.h:73
RooCmdArg & operator=(const RooCmdArg &other)
Assignment operator.
static const RooCmdArg & none()
Return reference to null argument.
Definition RooCmdArg.cxx:52
std::string constructorCode() const
Int_t getInt(Int_t idx) const
Definition RooCmdArg.h:87
void setSet(Int_t idx, const RooArgSet &set)
bool procSubArgs() const
Definition RooCmdArg.h:108
RooLinkedList & subArgs()
Return list of sub-arguments in this RooCmdArg.
Definition RooCmdArg.h:56
std::string _s[3]
Payload strings.
Definition RooCmdArg.h:120
bool prefixSubArgs() const
Definition RooCmdArg.h:109
bool _procSubArgs
If true argument requires recursive processing.
Definition RooCmdArg.h:122
RooCmdArg()
Default constructor.
Definition RooCmdArg.cxx:61
TObject * _o[2]
Payload objects.
Definition RooCmdArg.h:121
const char * opcode() const
Definition RooCmdArg.h:68
static const RooCmdArg _none
Static instance of null object.
Definition RooCmdArg.h:115
double _d[2]
Payload doubles.
Definition RooCmdArg.h:118
TObject * Clone(const char *newName=nullptr) const override
Make a clone of an object using the Streamer facility.
Definition RooCmdArg.h:58
bool _prefixSubArgs
Prefix sub-arguments with container name?
Definition RooCmdArg.h:125
void setProcessRecArgs(bool flag, bool prefix=true)
Definition RooCmdArg.h:46
~RooCmdArg() override
Destructor.
const char * getString(Int_t idx) const
Return string stored in slot idx.
Definition RooCmdArg.h:96
void setDouble(Int_t idx, double value)
Definition RooCmdArg.h:76
void setString(Int_t idx, const char *value)
Definition RooCmdArg.h:79
const TObject * getObject(Int_t idx) const
Return TObject stored in slot idx.
Definition RooCmdArg.h:100
Collection class for internal use, storing a collection of RooAbsArg pointers in a doubly linked list...
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