ROOT  6.06/09
Reference Guide
RooCategoryProxy.cxx
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * @(#)root/roofitcore:$Id$
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 //////////////////////////////////////////////////////////////////////////////
18 //
19 // BEGIN_HTML
20 // RooCategoryProxy is the proxy implementation for RooAbsCategory objects
21 // A RooCategoryProxy is the general mechanism to store references
22 // to RooAbsCategoriess inside a RooAbsArg
23 //
24 // RooCategoryProxy provides a cast operator to Int_t and 'const char*', allowing
25 // the proxy to functions a Int_t/'const char*' on the right hand side of expressions.
26 // END_HTML
27 //
28 
29 
30 #include "RooFit.h"
31 #include "Riostream.h"
32 #include "RooArgSet.h"
33 #include "RooCategoryProxy.h"
34 
35 using namespace std;
36 
38 ;
39 
40 
41 ////////////////////////////////////////////////////////////////////////////////
42 /// Constructor with owner and proxied category object
43 
44 RooCategoryProxy::RooCategoryProxy(const char* Name, const char* desc, RooAbsArg* owner,
45  Bool_t valueServer, Bool_t shapeServer, Bool_t ownArg) :
46  RooArgProxy(Name, desc, owner, valueServer, shapeServer, ownArg)
47 {
48 }
49 
50 
51 
52 ////////////////////////////////////////////////////////////////////////////////
53 /// Constructor with owner and proxied category object
54 
55 RooCategoryProxy::RooCategoryProxy(const char* Name, const char* desc, RooAbsArg* owner, RooAbsCategory& ref,
56  Bool_t valueServer, Bool_t shapeServer, Bool_t ownArg) :
57  RooArgProxy(Name, desc, owner, ref, valueServer, shapeServer, ownArg)
58 {
59 }
60 
61 
62 
63 ////////////////////////////////////////////////////////////////////////////////
64 /// Copy constructor
65 
67  RooArgProxy(Name, owner, other)
68 {
69 }
70 
71 
72 
73 ////////////////////////////////////////////////////////////////////////////////
74 /// Destructor
75 
77 {
78 }
79 
80 
81 
82 ////////////////////////////////////////////////////////////////////////////////
83 /// Return RooAbsCategoryLValye pointer of contained object if
84 /// it is indeed an lvalue
85 
87 {
88  // Assert that the held arg is an LValue
89  RooAbsCategoryLValue* Lvptr = dynamic_cast<RooAbsCategoryLValue*>(_arg) ;
90  if (!Lvptr) {
91  cout << "RooCategoryProxy(" << name() << ")::INTERNAL error, expected " << _arg->GetName() << " to be an lvalue" << endl ;
92  assert(0) ;
93  }
94  return Lvptr ;
95 }
96 
97 
98 
99 ////////////////////////////////////////////////////////////////////////////////
100 /// Change object held in proxy into newRef
101 
103 {
104  if (absArg()) {
105  if (TString(arg().GetName()!=newRef.GetName())) {
106  newRef.setAttribute(Form("ORIGNAME:%s",arg().GetName())) ;
107  }
108  return changePointer(RooArgSet(newRef),kTRUE) ;
109  } else {
110  return changePointer(RooArgSet(newRef),kFALSE,kTRUE);
111  }
112 }
void setAttribute(const Text_t *name, Bool_t value=kTRUE)
Set (default) or clear a named boolean attribute of this object.
Definition: RooAbsArg.cxx:265
virtual Bool_t changePointer(const RooAbsCollection &newServerSet, Bool_t nameChange=kFALSE, Bool_t factoryInitMode=kFALSE)
Change proxied object to object of same name in given list.
#define assert(cond)
Definition: unittest.h:542
virtual const char * name() const
Definition: RooArgProxy.h:42
Basic string class.
Definition: TString.h:137
RooAbsArg * _arg
Definition: RooArgProxy.h:52
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
STL namespace.
virtual ~RooCategoryProxy()
Destructor.
const char * Name
Definition: TXMLSetup.cxx:67
virtual Bool_t setArg(RooAbsCategory &newRef)
Change object held in proxy into newRef.
RooAbsCategoryLValue * lvptr() const
Return RooAbsCategoryLValye pointer of contained object if it is indeed an lvalue.
char * Form(const char *fmt,...)
RooAbsArg * absArg() const
Definition: RooArgProxy.h:37
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
const RooAbsCategory & arg() const
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66
const Bool_t kTRUE
Definition: Rtypes.h:91
ClassImp(RooCategoryProxy)