ROOT logo
/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 * @(#)root/roofitcore:$Id: RooArgProxy.cxx 28259 2009-04-16 16:21:16Z 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)             *
 *****************************************************************************/

#include "RooFit.h"

#include "RooArgProxy.h"
#include "RooArgProxy.h"
#include "RooArgSet.h"
#include "RooAbsArg.h"
#include <iostream>
using namespace std ;

//////////////////////////////////////////////////////////////////////////////
// 
// BEGIN_HTML
// RooArgProxy is the abstact interface for RooAbsArg proxy classes.
// A RooArgProxy is the general mechanism to store references
// to other RooAbsArgs inside a RooAbsArg
//
// Creating a RooArgProxy adds the proxied object to the proxy owners
// server list (thus receiving value/shape dirty flags from it) and
// registers itself with the owning class. The latter allows the
// owning class to change the proxied pointer when the server it
// points to gets redirected (e.g. in a copy or clone operation)
// END_HTML
//


ClassImp(RooArgProxy)
;


//_____________________________________________________________________________
RooArgProxy::RooArgProxy(const char* inName, const char* desc, RooAbsArg* owner,
			 Bool_t valueServer, Bool_t shapeServer, Bool_t proxyOwnsArg) : 
  TNamed(inName,desc), _owner(owner), _arg(0),
  _valueServer(valueServer), _shapeServer(shapeServer), _ownArg(proxyOwnsArg)
{
  // Constructor with owner and proxied variable. 
  _owner->registerProxy(*this) ;
}



//_____________________________________________________________________________
RooArgProxy::RooArgProxy(const char* inName, const char* desc, RooAbsArg* owner, RooAbsArg& arg,
			 Bool_t valueServer, Bool_t shapeServer, Bool_t proxyOwnsArg) : 
  TNamed(inName,desc), _owner(owner), _arg(&arg),
  _valueServer(valueServer), _shapeServer(shapeServer), _ownArg(proxyOwnsArg)
{
  // Constructor with owner and proxied variable. The valueServer and shapeServer booleans
  // control if the inserted client-server link in the owner propagates value and/or 
  // shape dirty flags. If proxyOwnsArg is true, the proxy takes ownership of its component

  _owner->registerProxy(*this) ;
  _isFund = _arg->isFundamental() ;
}



//_____________________________________________________________________________
RooArgProxy::RooArgProxy(const char* inName, RooAbsArg* owner, const RooArgProxy& other) : 
  TNamed(inName,inName), RooAbsProxy(other), _owner(owner), _arg(other._arg), 
  _valueServer(other._valueServer), _shapeServer(other._shapeServer),
  _isFund(other._isFund), _ownArg(other._ownArg) 
{
  // Copy constructor

  if (_ownArg) {
    _arg = _arg ? (RooAbsArg*) _arg->Clone() : 0 ;
  }

  _owner->registerProxy(*this) ;
}



//_____________________________________________________________________________
RooArgProxy::~RooArgProxy()
{
  // Destructor

  if (_owner) _owner->unRegisterProxy(*this) ;
  if (_ownArg) delete _arg ;
}



//_____________________________________________________________________________
Bool_t RooArgProxy::changePointer(const RooAbsCollection& newServerList, Bool_t nameChange, Bool_t factoryInitMode) 
{
  // Change proxied object to object of same name in given list. If nameChange is true
  // the replacement object can have a different name and is identified as the replacement object by
  // the existence of a boolean attribute "origName:MyName" where MyName is the name of this instance
  
  RooAbsArg* newArg ;
  Bool_t initEmpty = _arg ? kFALSE : kTRUE ;
  if (_arg) {
    newArg= _arg->findNewServer(newServerList, nameChange);
  } else if (factoryInitMode) {
    newArg = newServerList.first() ;
    _owner->addServer(*newArg,_valueServer,_shapeServer) ;
  } else {
    newArg = 0 ;
  }
  if (newArg) {
    _arg = newArg ;
    _isFund = _arg->isFundamental() ;
  }  
  if (initEmpty && !factoryInitMode) return kTRUE ;
  return newArg?kTRUE:kFALSE ;
}



//_____________________________________________________________________________
void RooArgProxy::changeDataSet(const RooArgSet* newNormSet) 
{
  // Change the normalization set that should be offered to the
  // content objects getVal() when evaluated.

  RooAbsProxy::changeNormSet(newNormSet) ;
  _arg->setProxyNormSet(newNormSet) ;
}



//_____________________________________________________________________________
void RooArgProxy::print(ostream& os, Bool_t addContents) const 
{ 
  // Print the name of the proxy on ostream. If addContents is
  // true also the value of the contained RooAbsArg is also printed

  os << name() << "=" << (_arg?_arg->GetName():"NULL")  ;
  if (_arg && addContents) {
    os << "=" ;
    _arg->printStream(os,RooPrintable::kValue,RooPrintable::kInline) ;
  }
}
 RooArgProxy.cxx:1
 RooArgProxy.cxx:2
 RooArgProxy.cxx:3
 RooArgProxy.cxx:4
 RooArgProxy.cxx:5
 RooArgProxy.cxx:6
 RooArgProxy.cxx:7
 RooArgProxy.cxx:8
 RooArgProxy.cxx:9
 RooArgProxy.cxx:10
 RooArgProxy.cxx:11
 RooArgProxy.cxx:12
 RooArgProxy.cxx:13
 RooArgProxy.cxx:14
 RooArgProxy.cxx:15
 RooArgProxy.cxx:16
 RooArgProxy.cxx:17
 RooArgProxy.cxx:18
 RooArgProxy.cxx:19
 RooArgProxy.cxx:20
 RooArgProxy.cxx:21
 RooArgProxy.cxx:22
 RooArgProxy.cxx:23
 RooArgProxy.cxx:24
 RooArgProxy.cxx:25
 RooArgProxy.cxx:26
 RooArgProxy.cxx:27
 RooArgProxy.cxx:28
 RooArgProxy.cxx:29
 RooArgProxy.cxx:30
 RooArgProxy.cxx:31
 RooArgProxy.cxx:32
 RooArgProxy.cxx:33
 RooArgProxy.cxx:34
 RooArgProxy.cxx:35
 RooArgProxy.cxx:36
 RooArgProxy.cxx:37
 RooArgProxy.cxx:38
 RooArgProxy.cxx:39
 RooArgProxy.cxx:40
 RooArgProxy.cxx:41
 RooArgProxy.cxx:42
 RooArgProxy.cxx:43
 RooArgProxy.cxx:44
 RooArgProxy.cxx:45
 RooArgProxy.cxx:46
 RooArgProxy.cxx:47
 RooArgProxy.cxx:48
 RooArgProxy.cxx:49
 RooArgProxy.cxx:50
 RooArgProxy.cxx:51
 RooArgProxy.cxx:52
 RooArgProxy.cxx:53
 RooArgProxy.cxx:54
 RooArgProxy.cxx:55
 RooArgProxy.cxx:56
 RooArgProxy.cxx:57
 RooArgProxy.cxx:58
 RooArgProxy.cxx:59
 RooArgProxy.cxx:60
 RooArgProxy.cxx:61
 RooArgProxy.cxx:62
 RooArgProxy.cxx:63
 RooArgProxy.cxx:64
 RooArgProxy.cxx:65
 RooArgProxy.cxx:66
 RooArgProxy.cxx:67
 RooArgProxy.cxx:68
 RooArgProxy.cxx:69
 RooArgProxy.cxx:70
 RooArgProxy.cxx:71
 RooArgProxy.cxx:72
 RooArgProxy.cxx:73
 RooArgProxy.cxx:74
 RooArgProxy.cxx:75
 RooArgProxy.cxx:76
 RooArgProxy.cxx:77
 RooArgProxy.cxx:78
 RooArgProxy.cxx:79
 RooArgProxy.cxx:80
 RooArgProxy.cxx:81
 RooArgProxy.cxx:82
 RooArgProxy.cxx:83
 RooArgProxy.cxx:84
 RooArgProxy.cxx:85
 RooArgProxy.cxx:86
 RooArgProxy.cxx:87
 RooArgProxy.cxx:88
 RooArgProxy.cxx:89
 RooArgProxy.cxx:90
 RooArgProxy.cxx:91
 RooArgProxy.cxx:92
 RooArgProxy.cxx:93
 RooArgProxy.cxx:94
 RooArgProxy.cxx:95
 RooArgProxy.cxx:96
 RooArgProxy.cxx:97
 RooArgProxy.cxx:98
 RooArgProxy.cxx:99
 RooArgProxy.cxx:100
 RooArgProxy.cxx:101
 RooArgProxy.cxx:102
 RooArgProxy.cxx:103
 RooArgProxy.cxx:104
 RooArgProxy.cxx:105
 RooArgProxy.cxx:106
 RooArgProxy.cxx:107
 RooArgProxy.cxx:108
 RooArgProxy.cxx:109
 RooArgProxy.cxx:110
 RooArgProxy.cxx:111
 RooArgProxy.cxx:112
 RooArgProxy.cxx:113
 RooArgProxy.cxx:114
 RooArgProxy.cxx:115
 RooArgProxy.cxx:116
 RooArgProxy.cxx:117
 RooArgProxy.cxx:118
 RooArgProxy.cxx:119
 RooArgProxy.cxx:120
 RooArgProxy.cxx:121
 RooArgProxy.cxx:122
 RooArgProxy.cxx:123
 RooArgProxy.cxx:124
 RooArgProxy.cxx:125
 RooArgProxy.cxx:126
 RooArgProxy.cxx:127
 RooArgProxy.cxx:128
 RooArgProxy.cxx:129
 RooArgProxy.cxx:130
 RooArgProxy.cxx:131
 RooArgProxy.cxx:132
 RooArgProxy.cxx:133
 RooArgProxy.cxx:134
 RooArgProxy.cxx:135
 RooArgProxy.cxx:136
 RooArgProxy.cxx:137
 RooArgProxy.cxx:138
 RooArgProxy.cxx:139
 RooArgProxy.cxx:140
 RooArgProxy.cxx:141
 RooArgProxy.cxx:142
 RooArgProxy.cxx:143
 RooArgProxy.cxx:144
 RooArgProxy.cxx:145
 RooArgProxy.cxx:146
 RooArgProxy.cxx:147
 RooArgProxy.cxx:148
 RooArgProxy.cxx:149
 RooArgProxy.cxx:150
 RooArgProxy.cxx:151
 RooArgProxy.cxx:152