ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 \file RooCategoryProxy.cxx
19 \class RooCategoryProxy
20 \ingroup Roofitcore
21 
22 RooCategoryProxy is the proxy implementation for RooAbsCategory objects
23 A RooCategoryProxy is the general mechanism to store references
24 to RooAbsCategoriess inside a RooAbsArg
25 
26 RooCategoryProxy provides a cast operator to Int_t and 'const char*', allowing
27 the proxy to functions a Int_t/'const char*' on the right hand side of expressions.
28 **/
29 
30 
31 #include "RooFit.h"
32 #include "Riostream.h"
33 #include "RooArgSet.h"
34 #include "RooCategoryProxy.h"
35 
36 using namespace std;
37 
39 ;
40 
41 
42 ////////////////////////////////////////////////////////////////////////////////
43 /// Constructor with owner and proxied category object
44 
45 RooCategoryProxy::RooCategoryProxy(const char* Name, const char* desc, RooAbsArg* owner,
46  Bool_t valueServer, Bool_t shapeServer, Bool_t ownArg) :
47  RooArgProxy(Name, desc, owner, valueServer, shapeServer, ownArg)
48 {
49 }
50 
51 
52 
53 ////////////////////////////////////////////////////////////////////////////////
54 /// Constructor with owner and proxied category object
55 
56 RooCategoryProxy::RooCategoryProxy(const char* Name, const char* desc, RooAbsArg* owner, RooAbsCategory& ref,
57  Bool_t valueServer, Bool_t shapeServer, Bool_t ownArg) :
58  RooArgProxy(Name, desc, owner, ref, valueServer, shapeServer, ownArg)
59 {
60 }
61 
62 
63 
64 ////////////////////////////////////////////////////////////////////////////////
65 /// Copy constructor
66 
68  RooArgProxy(Name, owner, other)
69 {
70 }
71 
72 
73 
74 ////////////////////////////////////////////////////////////////////////////////
75 /// Destructor
76 
78 {
79 }
80 
81 
82 
83 ////////////////////////////////////////////////////////////////////////////////
84 /// Return RooAbsCategoryLValye pointer of contained object if
85 /// it is indeed an lvalue
86 
88 {
89  // Assert that the held arg is an LValue
90  RooAbsCategoryLValue* Lvptr = dynamic_cast<RooAbsCategoryLValue*>(_arg) ;
91  if (!Lvptr) {
92  cout << "RooCategoryProxy(" << name() << ")::INTERNAL error, expected " << _arg->GetName() << " to be an lvalue" << endl ;
93  assert(0) ;
94  }
95  return Lvptr ;
96 }
97 
98 
99 
100 ////////////////////////////////////////////////////////////////////////////////
101 /// Change object held in proxy into newRef
102 
104 {
105  if (absArg()) {
106  if (TString(arg().GetName()!=newRef.GetName())) {
107  newRef.setAttribute(Form("ORIGNAME:%s",arg().GetName())) ;
108  }
109  return changePointer(RooArgSet(newRef),kTRUE) ;
110  } else {
111  return changePointer(RooArgSet(newRef),kFALSE,kTRUE);
112  }
113 }
void setAttribute(const Text_t *name, Bool_t value=kTRUE)
Set (default) or clear a named boolean attribute of this object.
Definition: RooAbsArg.cxx:266
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
virtual ~RooCategoryProxy()
Destructor.
const char * Name
Definition: TXMLSetup.cxx:67
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
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
RooCategoryProxy is the proxy implementation for RooAbsCategory objects A RooCategoryProxy is the gen...
RooArgProxy is the abstact interface for RooAbsArg proxy classes.
Definition: RooArgProxy.h:24
RooAbsCategory is the common abstract base class for objects that represent a discrete value with a f...
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)