Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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>
25 class RooAbsData ;
26 class RooArgSet ;
27 
28 class RooCmdArg : public TNamed {
29 public:
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 
47  RooLinkedList& subArgs() {
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 
102 protected:
103 
104  static const RooCmdArg _none ; // Static instance of null object
105  friend class RooCmdConfig ;
106 
107 private:
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