/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 * @(#)root/roofitcore:$Id$
 * 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
// RooRealProxy is the concrete proxy for RooAbsReal objects
// A RooRealProxy is the general mechanism to store references
// to RooAbsReals inside a RooAbsArg
//
// RooRealProxy provides a cast operator to Double_t, allowing
// the proxy to functions a Double_t on the right hand side of expressions.
// END_HTML
//

#include "RooFit.h"
#include "Riostream.h"

#include "TClass.h"
#include "RooRealProxy.h"
#include "RooRealVar.h"

using namespace std;

ClassImp(RooRealProxy)
;


//_____________________________________________________________________________
RooRealProxy::RooRealProxy(const char* inName, const char* desc, RooAbsArg* owner, 
			   Bool_t valueServer, Bool_t shapeServer, Bool_t ownArg) : 
  RooArgProxy(inName, desc, owner, valueServer, shapeServer, ownArg)
{
  // Constructor with owner. 
}



//_____________________________________________________________________________
RooRealProxy::RooRealProxy(const char* inName, const char* desc, RooAbsArg* owner, RooAbsReal& ref,
			   Bool_t valueServer, Bool_t shapeServer, Bool_t ownArg) : 
  RooArgProxy(inName, desc, owner,ref, valueServer, shapeServer, ownArg)
{
  // Constructor with owner and proxied real-valued object. The propagation
  // of value and shape dirty flags of the contained arg to the owner is
  // controlled by the valueServer and shapeServer flags. If ownArg is true
  // the proxy will take ownership of the contained arg
}



//_____________________________________________________________________________
RooRealProxy::RooRealProxy(const char* inName, RooAbsArg* owner, const RooRealProxy& other) : 
  RooArgProxy(inName, owner, other) 
{
  // Copy constructor 
}



//_____________________________________________________________________________
RooRealProxy::~RooRealProxy() 
{
  // Destructor
}



//_____________________________________________________________________________
RooAbsRealLValue* RooRealProxy::lvptr() const 
{
  // Return l-value pointer to contents, if contents is in fact an l-value

  // WVE remove check here -- need to put it back in setArg and ctor
  return (RooAbsRealLValue*) _arg ;

  // Assert that the held arg is an LValue
  RooAbsRealLValue* Lvptr = (RooAbsRealLValue*)dynamic_cast<const RooAbsRealLValue*>(_arg) ;
  if (!Lvptr) {
    cout << "RooRealProxy(" << name() << ")::INTERNAL error, expected " << _arg->GetName() << " to be an lvalue" << endl ;
    assert(0) ;
  }
  return Lvptr ;
}


//_____________________________________________________________________________
Bool_t RooRealProxy::setArg(RooAbsReal& newRef) 
{
  // Change object held in proxy into newRef
  if (absArg()) {
    if (TString(arg().GetName()!=newRef.GetName())) {
      newRef.setAttribute(Form("ORIGNAME:%s",arg().GetName())) ;
    }
    return changePointer(RooArgSet(newRef),kTRUE) ;
  } else {
    return changePointer(RooArgSet(newRef),kFALSE,kTRUE);
  }
}
 RooRealProxy.cxx:1
 RooRealProxy.cxx:2
 RooRealProxy.cxx:3
 RooRealProxy.cxx:4
 RooRealProxy.cxx:5
 RooRealProxy.cxx:6
 RooRealProxy.cxx:7
 RooRealProxy.cxx:8
 RooRealProxy.cxx:9
 RooRealProxy.cxx:10
 RooRealProxy.cxx:11
 RooRealProxy.cxx:12
 RooRealProxy.cxx:13
 RooRealProxy.cxx:14
 RooRealProxy.cxx:15
 RooRealProxy.cxx:16
 RooRealProxy.cxx:17
 RooRealProxy.cxx:18
 RooRealProxy.cxx:19
 RooRealProxy.cxx:20
 RooRealProxy.cxx:21
 RooRealProxy.cxx:22
 RooRealProxy.cxx:23
 RooRealProxy.cxx:24
 RooRealProxy.cxx:25
 RooRealProxy.cxx:26
 RooRealProxy.cxx:27
 RooRealProxy.cxx:28
 RooRealProxy.cxx:29
 RooRealProxy.cxx:30
 RooRealProxy.cxx:31
 RooRealProxy.cxx:32
 RooRealProxy.cxx:33
 RooRealProxy.cxx:34
 RooRealProxy.cxx:35
 RooRealProxy.cxx:36
 RooRealProxy.cxx:37
 RooRealProxy.cxx:38
 RooRealProxy.cxx:39
 RooRealProxy.cxx:40
 RooRealProxy.cxx:41
 RooRealProxy.cxx:42
 RooRealProxy.cxx:43
 RooRealProxy.cxx:44
 RooRealProxy.cxx:45
 RooRealProxy.cxx:46
 RooRealProxy.cxx:47
 RooRealProxy.cxx:48
 RooRealProxy.cxx:49
 RooRealProxy.cxx:50
 RooRealProxy.cxx:51
 RooRealProxy.cxx:52
 RooRealProxy.cxx:53
 RooRealProxy.cxx:54
 RooRealProxy.cxx:55
 RooRealProxy.cxx:56
 RooRealProxy.cxx:57
 RooRealProxy.cxx:58
 RooRealProxy.cxx:59
 RooRealProxy.cxx:60
 RooRealProxy.cxx:61
 RooRealProxy.cxx:62
 RooRealProxy.cxx:63
 RooRealProxy.cxx:64
 RooRealProxy.cxx:65
 RooRealProxy.cxx:66
 RooRealProxy.cxx:67
 RooRealProxy.cxx:68
 RooRealProxy.cxx:69
 RooRealProxy.cxx:70
 RooRealProxy.cxx:71
 RooRealProxy.cxx:72
 RooRealProxy.cxx:73
 RooRealProxy.cxx:74
 RooRealProxy.cxx:75
 RooRealProxy.cxx:76
 RooRealProxy.cxx:77
 RooRealProxy.cxx:78
 RooRealProxy.cxx:79
 RooRealProxy.cxx:80
 RooRealProxy.cxx:81
 RooRealProxy.cxx:82
 RooRealProxy.cxx:83
 RooRealProxy.cxx:84
 RooRealProxy.cxx:85
 RooRealProxy.cxx:86
 RooRealProxy.cxx:87
 RooRealProxy.cxx:88
 RooRealProxy.cxx:89
 RooRealProxy.cxx:90
 RooRealProxy.cxx:91
 RooRealProxy.cxx:92
 RooRealProxy.cxx:93
 RooRealProxy.cxx:94
 RooRealProxy.cxx:95
 RooRealProxy.cxx:96
 RooRealProxy.cxx:97
 RooRealProxy.cxx:98
 RooRealProxy.cxx:99
 RooRealProxy.cxx:100
 RooRealProxy.cxx:101
 RooRealProxy.cxx:102
 RooRealProxy.cxx:103
 RooRealProxy.cxx:104
 RooRealProxy.cxx:105
 RooRealProxy.cxx:106
 RooRealProxy.cxx:107
 RooRealProxy.cxx:108
 RooRealProxy.cxx:109
 RooRealProxy.cxx:110
 RooRealProxy.cxx:111
 RooRealProxy.cxx:112