ROOT logo
/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 * @(#)root/roofitcore:$Id: RooCmdArg.cxx 37128 2010-11-30 22:24:50Z wouter $
 * Authors:                                                                  *
 *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
 *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
 *                                                                           *
 * Copyright (c) 2000-2005, Regents of the University of California          *
 *                          and Stanford University. All rights reserved.    *
 *                                                                           *
 * Redistribution and use in source and binary forms,                        *
 * with or without modification, are permitted according to the terms        *
 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
 *****************************************************************************/


//////////////////////////////////////////////////////////////////////////////
// 
// BEGIN_HTML
// RooCmdArg is a named container for two doubles, two integers
// two object points and three string pointers that can be passed
// as generic named arguments to a variety of RooFit end user
// methods. To achieved the named syntax, RooCmdArg objects are
// created using global helper functions defined in RooGlobalFunc.h
// that create and fill these generic containers
// END_HTML
//

#include "RooFit.h"

#include "RooCmdArg.h"
#include "RooCmdArg.h"
#include "Riostream.h"
#include "RooArgSet.h"
#include <string>

ClassImp(RooCmdArg)
  ;

const RooCmdArg RooCmdArg::_none ;


//_____________________________________________________________________________
const RooCmdArg& RooCmdArg::none() 
{
  // Return reference to null argument
  return _none ;
}


//_____________________________________________________________________________
RooCmdArg::RooCmdArg() : TNamed("","")
{
  // Default constructor
  _procSubArgs = kFALSE ;
  _prefixSubArgs = kTRUE ;
  _c = 0 ;
  _o[0] = 0 ;
  _o[1] = 0 ; 
  _i[0] = 0 ;
  _i[1] = 0 ;
  _d[0] = 0 ;
  _d[1] = 0 ;
}


//_____________________________________________________________________________
RooCmdArg::RooCmdArg(const char* name, Int_t i1, Int_t i2, Double_t d1, Double_t d2, 
		     const char* s1, const char* s2, const TObject* o1, const TObject* o2, 
		     const RooCmdArg* ca, const char* s3, const RooArgSet* c1, const RooArgSet* c2) :
  TNamed(name,name)
{
  // Constructor with full specification of payload: two integers, two doubles,
  // three string poiners, two object pointers and one RooCmdArg pointer

  _i[0] = i1 ;
  _i[1] = i2 ;
  _d[0] = d1 ;
  _d[1] = d2 ;
  if (s1) _s[0] = s1 ;
  if (s2) _s[1] = s2 ;
  if (s3) _s[2] = s3 ;
  _o[0] = (TObject*) o1 ;
  _o[1] = (TObject*) o2 ;
  _c = 0 ;

  if (c1||c2) _c = new RooArgSet[2] ;
  if (c1) _c[0].add(*c1) ;
  if (c2) _c[1].add(*c2) ;

  _procSubArgs = kTRUE ;
  _prefixSubArgs = kTRUE ;
  if (ca) {
    _argList.Add(new RooCmdArg(*ca)) ;
  }
}



//_____________________________________________________________________________
RooCmdArg::RooCmdArg(const RooCmdArg& other) :
  TNamed(other)
{
  // Copy constructor

  _i[0] = other._i[0] ;
  _i[1] = other._i[1] ;
  _d[0] = other._d[0] ;
  _d[1] = other._d[1] ;
  _s[0] = other._s[0] ;
  _s[1] = other._s[1] ;
  _s[2] = other._s[2] ;
  _o[0] = other._o[0] ;
  _o[1] = other._o[1] ;
  if (other._c) {
    _c = new RooArgSet[2] ;
    _c[0].add(other._c[0]) ;
    _c[1].add(other._c[1]) ;
  } else {
    _c = 0 ;
  }
  
  _procSubArgs = other._procSubArgs ;
  _prefixSubArgs = other._prefixSubArgs ;
  for (Int_t i=0 ; i<other._argList.GetSize() ; i++) {
    _argList.Add(new RooCmdArg((RooCmdArg&)*other._argList.At(i))) ;
  }
}


//_____________________________________________________________________________
RooCmdArg& RooCmdArg::operator=(const RooCmdArg& other) 
{
  // Assignment operator

  if (&other==this) return *this ;

  SetName(other.GetName()) ;
  SetTitle(other.GetTitle()) ;

  _i[0] = other._i[0] ;
  _i[1] = other._i[1] ;
  _d[0] = other._d[0] ;
  _d[1] = other._d[1] ;
  _s[0] = other._s[0] ;
  _s[1] = other._s[1] ;
  _s[2] = other._s[2] ;
  _o[0] = other._o[0] ;
  _o[1] = other._o[1] ;
  if (!_c) _c = new RooArgSet[2] ;
  if (other._c) {
    _c[0].removeAll() ; _c[0].add(other._c[0]) ;
    _c[1].removeAll() ; _c[1].add(other._c[1]) ;
  }
  
  _procSubArgs = other._procSubArgs ;
  _prefixSubArgs = other._prefixSubArgs ;

  for (Int_t i=0 ; i<other._argList.GetSize() ; i++) {
    _argList.Add(new RooCmdArg((RooCmdArg&)*other._argList.At(i))) ;
  }

  return *this ;
}



//_____________________________________________________________________________
RooCmdArg::~RooCmdArg()
{
  // Destructor
  _argList.Delete() ;
  if (_c) delete[] _c ;
}



//_____________________________________________________________________________
void RooCmdArg::addArg(const RooCmdArg& arg) 
{
  // Utility function to add nested RooCmdArg to payload of this RooCmdArg

  _argList.Add(new RooCmdArg(arg)) ;
}



//_____________________________________________________________________________
const RooArgSet* RooCmdArg::getSet(Int_t idx) const {
  // Return RooArgSet stored in slot idx
    return _c ? &_c[idx] : 0 ;
  }



//_____________________________________________________________________________
void RooCmdArg::setSet(Int_t idx,const RooArgSet& set) 
{
  if (!_c) {
    _c = new RooArgSet[2] ;
  }
    _c[idx].removeAll() ;
    _c[idx].add(set) ;
}
 RooCmdArg.cxx:1
 RooCmdArg.cxx:2
 RooCmdArg.cxx:3
 RooCmdArg.cxx:4
 RooCmdArg.cxx:5
 RooCmdArg.cxx:6
 RooCmdArg.cxx:7
 RooCmdArg.cxx:8
 RooCmdArg.cxx:9
 RooCmdArg.cxx:10
 RooCmdArg.cxx:11
 RooCmdArg.cxx:12
 RooCmdArg.cxx:13
 RooCmdArg.cxx:14
 RooCmdArg.cxx:15
 RooCmdArg.cxx:16
 RooCmdArg.cxx:17
 RooCmdArg.cxx:18
 RooCmdArg.cxx:19
 RooCmdArg.cxx:20
 RooCmdArg.cxx:21
 RooCmdArg.cxx:22
 RooCmdArg.cxx:23
 RooCmdArg.cxx:24
 RooCmdArg.cxx:25
 RooCmdArg.cxx:26
 RooCmdArg.cxx:27
 RooCmdArg.cxx:28
 RooCmdArg.cxx:29
 RooCmdArg.cxx:30
 RooCmdArg.cxx:31
 RooCmdArg.cxx:32
 RooCmdArg.cxx:33
 RooCmdArg.cxx:34
 RooCmdArg.cxx:35
 RooCmdArg.cxx:36
 RooCmdArg.cxx:37
 RooCmdArg.cxx:38
 RooCmdArg.cxx:39
 RooCmdArg.cxx:40
 RooCmdArg.cxx:41
 RooCmdArg.cxx:42
 RooCmdArg.cxx:43
 RooCmdArg.cxx:44
 RooCmdArg.cxx:45
 RooCmdArg.cxx:46
 RooCmdArg.cxx:47
 RooCmdArg.cxx:48
 RooCmdArg.cxx:49
 RooCmdArg.cxx:50
 RooCmdArg.cxx:51
 RooCmdArg.cxx:52
 RooCmdArg.cxx:53
 RooCmdArg.cxx:54
 RooCmdArg.cxx:55
 RooCmdArg.cxx:56
 RooCmdArg.cxx:57
 RooCmdArg.cxx:58
 RooCmdArg.cxx:59
 RooCmdArg.cxx:60
 RooCmdArg.cxx:61
 RooCmdArg.cxx:62
 RooCmdArg.cxx:63
 RooCmdArg.cxx:64
 RooCmdArg.cxx:65
 RooCmdArg.cxx:66
 RooCmdArg.cxx:67
 RooCmdArg.cxx:68
 RooCmdArg.cxx:69
 RooCmdArg.cxx:70
 RooCmdArg.cxx:71
 RooCmdArg.cxx:72
 RooCmdArg.cxx:73
 RooCmdArg.cxx:74
 RooCmdArg.cxx:75
 RooCmdArg.cxx:76
 RooCmdArg.cxx:77
 RooCmdArg.cxx:78
 RooCmdArg.cxx:79
 RooCmdArg.cxx:80
 RooCmdArg.cxx:81
 RooCmdArg.cxx:82
 RooCmdArg.cxx:83
 RooCmdArg.cxx:84
 RooCmdArg.cxx:85
 RooCmdArg.cxx:86
 RooCmdArg.cxx:87
 RooCmdArg.cxx:88
 RooCmdArg.cxx:89
 RooCmdArg.cxx:90
 RooCmdArg.cxx:91
 RooCmdArg.cxx:92
 RooCmdArg.cxx:93
 RooCmdArg.cxx:94
 RooCmdArg.cxx:95
 RooCmdArg.cxx:96
 RooCmdArg.cxx:97
 RooCmdArg.cxx:98
 RooCmdArg.cxx:99
 RooCmdArg.cxx:100
 RooCmdArg.cxx:101
 RooCmdArg.cxx:102
 RooCmdArg.cxx:103
 RooCmdArg.cxx:104
 RooCmdArg.cxx:105
 RooCmdArg.cxx:106
 RooCmdArg.cxx:107
 RooCmdArg.cxx:108
 RooCmdArg.cxx:109
 RooCmdArg.cxx:110
 RooCmdArg.cxx:111
 RooCmdArg.cxx:112
 RooCmdArg.cxx:113
 RooCmdArg.cxx:114
 RooCmdArg.cxx:115
 RooCmdArg.cxx:116
 RooCmdArg.cxx:117
 RooCmdArg.cxx:118
 RooCmdArg.cxx:119
 RooCmdArg.cxx:120
 RooCmdArg.cxx:121
 RooCmdArg.cxx:122
 RooCmdArg.cxx:123
 RooCmdArg.cxx:124
 RooCmdArg.cxx:125
 RooCmdArg.cxx:126
 RooCmdArg.cxx:127
 RooCmdArg.cxx:128
 RooCmdArg.cxx:129
 RooCmdArg.cxx:130
 RooCmdArg.cxx:131
 RooCmdArg.cxx:132
 RooCmdArg.cxx:133
 RooCmdArg.cxx:134
 RooCmdArg.cxx:135
 RooCmdArg.cxx:136
 RooCmdArg.cxx:137
 RooCmdArg.cxx:138
 RooCmdArg.cxx:139
 RooCmdArg.cxx:140
 RooCmdArg.cxx:141
 RooCmdArg.cxx:142
 RooCmdArg.cxx:143
 RooCmdArg.cxx:144
 RooCmdArg.cxx:145
 RooCmdArg.cxx:146
 RooCmdArg.cxx:147
 RooCmdArg.cxx:148
 RooCmdArg.cxx:149
 RooCmdArg.cxx:150
 RooCmdArg.cxx:151
 RooCmdArg.cxx:152
 RooCmdArg.cxx:153
 RooCmdArg.cxx:154
 RooCmdArg.cxx:155
 RooCmdArg.cxx:156
 RooCmdArg.cxx:157
 RooCmdArg.cxx:158
 RooCmdArg.cxx:159
 RooCmdArg.cxx:160
 RooCmdArg.cxx:161
 RooCmdArg.cxx:162
 RooCmdArg.cxx:163
 RooCmdArg.cxx:164
 RooCmdArg.cxx:165
 RooCmdArg.cxx:166
 RooCmdArg.cxx:167
 RooCmdArg.cxx:168
 RooCmdArg.cxx:169
 RooCmdArg.cxx:170
 RooCmdArg.cxx:171
 RooCmdArg.cxx:172
 RooCmdArg.cxx:173
 RooCmdArg.cxx:174
 RooCmdArg.cxx:175
 RooCmdArg.cxx:176
 RooCmdArg.cxx:177
 RooCmdArg.cxx:178
 RooCmdArg.cxx:179
 RooCmdArg.cxx:180
 RooCmdArg.cxx:181
 RooCmdArg.cxx:182
 RooCmdArg.cxx:183
 RooCmdArg.cxx:184
 RooCmdArg.cxx:185
 RooCmdArg.cxx:186
 RooCmdArg.cxx:187
 RooCmdArg.cxx:188
 RooCmdArg.cxx:189
 RooCmdArg.cxx:190
 RooCmdArg.cxx:191
 RooCmdArg.cxx:192
 RooCmdArg.cxx:193
 RooCmdArg.cxx:194
 RooCmdArg.cxx:195
 RooCmdArg.cxx:196
 RooCmdArg.cxx:197
 RooCmdArg.cxx:198
 RooCmdArg.cxx:199
 RooCmdArg.cxx:200
 RooCmdArg.cxx:201
 RooCmdArg.cxx:202
 RooCmdArg.cxx:203
 RooCmdArg.cxx:204
 RooCmdArg.cxx:205