Logo ROOT  
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\file RooCategoryProxy.cxx
19\class RooCategoryProxy
20\ingroup Roofitcore
21
22RooCategoryProxy is the proxy implementation for RooAbsCategory objects
23A RooCategoryProxy is the general mechanism to store references
24to RooAbsCategoriess inside a RooAbsArg
25
26RooCategoryProxy provides a cast operator to Int_t and 'const char*', allowing
27the 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
36using namespace std;
37
39;
40
41
42////////////////////////////////////////////////////////////////////////////////
43/// Constructor with owner and proxied category object
44
45RooCategoryProxy::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
56RooCategoryProxy::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}
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassImp(name)
Definition: Rtypes.h:365
char * Form(const char *fmt,...)
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:71
void setAttribute(const Text_t *name, Bool_t value=kTRUE)
Set (default) or clear a named boolean attribute of this object.
Definition: RooAbsArg.cxx:261
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
RooAbsCategory is the common abstract base class for objects that represent a discrete value with a f...
RooArgProxy is the abstact interface for RooAbsArg proxy classes.
Definition: RooArgProxy.h:24
virtual const char * name() const
Definition: RooArgProxy.h:42
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.
RooAbsArg * absArg() const
Definition: RooArgProxy.h:37
RooAbsArg * _arg
Definition: RooArgProxy.h:52
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
RooCategoryProxy is the proxy implementation for RooAbsCategory objects A RooCategoryProxy is the gen...
virtual Bool_t setArg(RooAbsCategory &newRef)
Change object held in proxy into newRef.
const RooAbsCategory & arg() const
RooAbsCategoryLValue * lvptr() const
Return RooAbsCategoryLValye pointer of contained object if it is indeed an lvalue.
virtual ~RooCategoryProxy()
Destructor.
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
Basic string class.
Definition: TString.h:131
const char * Name
Definition: TXMLSetup.cxx:66