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 "RooLinkedList.h"
22#include <string>
23
24class RooAbsData ;
25class RooArgSet ;
26
27class RooCmdArg : public TNamed {
28public:
29
30 RooCmdArg();
31 RooCmdArg(const char* name,
32 Int_t i1=0, Int_t i2=0,
33 Double_t d1=0, Double_t d2=0,
34 const char* s1=0, const char* s2=0,
35 const TObject* o1=0, const TObject* o2=0, const RooCmdArg* ca=0, const char* s3=0,
36 const RooArgSet* c1=0, const RooArgSet* c2=0) ;
37 RooCmdArg(const RooCmdArg& other) ;
38 RooCmdArg& operator=(const RooCmdArg& other) ;
39 void addArg(const RooCmdArg& arg) ;
40 void setProcessRecArgs(Bool_t flag, Bool_t prefix=kTRUE) {
41 // If true flag this object as containing recursive arguments
42 _procSubArgs = flag ;
43 _prefixSubArgs = prefix ;
44 }
45
47 // Return list of sub-arguments in this RooCmdArg
48 return _argList ;
49 }
50
51 virtual TObject* Clone(const char* newName=0) const {
52 RooCmdArg* newarg = new RooCmdArg(*this) ;
53 if (newName) { newarg->SetName(newName) ; }
54 return newarg ;
55 }
56
57 virtual ~RooCmdArg();
58
59 static const RooCmdArg& none() ;
60
61 const char* opcode() const {
62 // Return operator code
63 return strlen(GetName()) ? GetName() : 0 ;
64 }
65
66 void setInt(Int_t idx,Int_t value) {
67 _i[idx] = value ;
68 }
69 void setDouble(Int_t idx,Double_t value) {
70 _d[idx] = value ;
71 }
72 void setString(Int_t idx,const char* value) {
73 _s[idx] = value ;
74 }
75 void setObject(Int_t idx,TObject* value) {
76 _o[idx] = value ;
77 }
78 void setSet(Int_t idx,const RooArgSet& set) ;
79
80 Int_t getInt(Int_t idx) const {
81 // Return integer stored in slot idx
82 return _i[idx] ;
83 }
84 Double_t getDouble(Int_t idx) const {
85 // Return double stored in slot idx
86 return _d[idx] ;
87 }
88 const char* getString(Int_t idx) const {
89 // Return string stored in slot idx
90 return (_s[idx].size()>0) ? _s[idx].c_str() : 0 ;
91 }
92 const TObject* getObject(Int_t idx) const {
93 // Return TObject stored in slot idx
94 return _o[idx] ;
95 }
96
97 const RooArgSet* getSet(Int_t idx) const ;
98
99 void Print(const char* = "") const;
100
101 template<class T>
102 static T const& take(T && obj) {
103 getNextSharedData().emplace_back(new T{std::move(obj)});
104 return static_cast<T const&>(*getNextSharedData().back());
105 }
106
107protected:
108
109 static const RooCmdArg _none ; // Static instance of null object
110 friend class RooCmdConfig ;
111
112private:
113
114 friend class RooAbsCollection ;
115
116 // Payload
117 Double_t _d[2] ; // Payload doubles
118 Int_t _i[2] ; // Payload integers
119 std::string _s[3] ; // Payload strings
120 TObject* _o[2] ; // Payload objects
121 Bool_t _procSubArgs ; // If true argument requires recursive processing
122 RooArgSet* _c ; // Payload RooArgSets
123 RooLinkedList _argList ; // Payload sub-arguments
124 Bool_t _prefixSubArgs ; // Prefix subarguments with container name?
125
126 using DataCollection = std::vector<std::unique_ptr<TObject>>;
127 std::shared_ptr<DataCollection> _sharedData; //!
128
129 // the next RooCmdArg created will take ownership of this data
132
133 ClassDef(RooCmdArg,2) // Generic named argument container
134};
135
136#endif
137
138
#define s1(x)
Definition: RSha256.hxx:91
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Definition: RtypesCore.h:45
bool Bool_t
Definition: RtypesCore.h:63
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
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:79
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
Double_t getDouble(Int_t idx) const
Definition: RooCmdArg.h:84
const RooArgSet * getSet(Int_t idx) const
Return RooArgSet stored in slot idx.
Definition: RooCmdArg.cxx:206
RooArgSet * _c
Definition: RooCmdArg.h:122
RooLinkedList _argList
Definition: RooCmdArg.h:123
static T const & take(T &&obj)
Definition: RooCmdArg.h:102
void addArg(const RooCmdArg &arg)
Utility function to add nested RooCmdArg to payload of this RooCmdArg.
Definition: RooCmdArg.cxx:196
std::shared_ptr< DataCollection > _sharedData
Definition: RooCmdArg.h:127
Int_t _i[2]
Definition: RooCmdArg.h:118
void setObject(Int_t idx, TObject *value)
Definition: RooCmdArg.h:75
void setInt(Int_t idx, Int_t value)
Definition: RooCmdArg.h:66
void setDouble(Int_t idx, Double_t value)
Definition: RooCmdArg.h:69
RooCmdArg & operator=(const RooCmdArg &other)
Assignment operator.
Definition: RooCmdArg.cxx:146
static const RooCmdArg & none()
Return reference to null argument.
Definition: RooCmdArg.cxx:52
static DataCollection _nextSharedData
Definition: RooCmdArg.h:130
Bool_t _procSubArgs
Definition: RooCmdArg.h:121
Bool_t _prefixSubArgs
Definition: RooCmdArg.h:124
virtual ~RooCmdArg()
Destructor.
Definition: RooCmdArg.cxx:185
Int_t getInt(Int_t idx) const
Definition: RooCmdArg.h:80
void setSet(Int_t idx, const RooArgSet &set)
Definition: RooCmdArg.cxx:214
RooLinkedList & subArgs()
Definition: RooCmdArg.h:46
std::string _s[3]
Definition: RooCmdArg.h:119
Double_t _d[2]
Definition: RooCmdArg.h:117
RooCmdArg()
Default constructor.
Definition: RooCmdArg.cxx:61
TObject * _o[2]
Definition: RooCmdArg.h:120
void Print(const char *="") const
Print contents.
Definition: RooCmdArg.cxx:226
const char * opcode() const
Definition: RooCmdArg.h:61
static const RooCmdArg _none
Definition: RooCmdArg.h:109
std::vector< std::unique_ptr< TObject > > DataCollection
Definition: RooCmdArg.h:126
void setProcessRecArgs(Bool_t flag, Bool_t prefix=kTRUE)
Definition: RooCmdArg.h:40
const char * getString(Int_t idx) const
Definition: RooCmdArg.h:88
void setString(Int_t idx, const char *value)
Definition: RooCmdArg.h:72
const TObject * getObject(Int_t idx) const
Definition: RooCmdArg.h:92
static DataCollection & getNextSharedData()
Definition: RooCmdArg.cxx:236
virtual TObject * Clone(const char *newName=0) const
Make a clone of an object using the Streamer facility.
Definition: RooCmdArg.h:51
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:38
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
double T(double x)
Definition: ChebyshevPol.h:34