// RooListProxy is the concrete proxy for RooArgList objects.
// A RooListProxy is the only safe mechanism to store a RooArgList
// with RooAbsArg contents in another RooAbsArg.
// <p>
// The list proxy has the semantic of a RooArgList but also
// takes care of all bookkeeping required when composite objects
// are clone and client-server links need to be redirected.
// END_HTML
#include "RooFit.h"
#include "Riostream.h"
#include "RooListProxy.h"
#include "RooArgList.h"
#include "RooAbsArg.h"
ClassImp(RooListProxy)
;
RooListProxy::RooListProxy(const char* inName, const char* , RooAbsArg* owner,
Bool_t defValueServer, Bool_t defShapeServer) :
RooArgList(inName), _owner(owner),
_defValueServer(defValueServer),
_defShapeServer(defShapeServer)
{
_owner->registerProxy(*this) ;
_iter = createIterator() ;
}
RooListProxy::RooListProxy(const char* inName, RooAbsArg* owner, const RooListProxy& other) :
RooArgList(other,inName), _owner(owner),
_defValueServer(other._defValueServer),
_defShapeServer(other._defShapeServer)
{
_owner->registerProxy(*this) ;
_iter = createIterator() ;
}
RooListProxy::~RooListProxy()
{
if (_owner) _owner->unRegisterProxy(*this) ;
delete _iter ;
}
Bool_t RooListProxy::add(const RooAbsArg& var, Bool_t valueServer, Bool_t shapeServer, Bool_t silent)
{
Bool_t ret=RooArgList::add(var,silent) ;
if (ret) {
_owner->addServer((RooAbsArg&)var,valueServer,shapeServer) ;
}
return ret ;
}
Bool_t RooListProxy::add(const RooAbsArg& var, Bool_t silent)
{
return add(var,_defValueServer,_defShapeServer,silent) ;
}
Bool_t RooListProxy::addOwned(RooAbsArg& var, Bool_t silent)
{
Bool_t ret=RooArgList::addOwned(var,silent) ;
if (ret) {
_owner->addServer((RooAbsArg&)var,_defValueServer,_defShapeServer) ;
}
return ret ;
}
Bool_t RooListProxy::replace(const RooAbsArg& var1, const RooAbsArg& var2)
{
Bool_t ret=RooArgList::replace(var1,var2) ;
if (ret) {
_owner->removeServer((RooAbsArg&)var1) ;
_owner->addServer((RooAbsArg&)var2,_owner->isValueServer(var1),
_owner->isShapeServer(var2)) ;
}
return ret ;
}
Bool_t RooListProxy::remove(const RooAbsArg& var, Bool_t silent, Bool_t matchByNameOnly)
{
Bool_t ret=RooArgList::remove(var,silent,matchByNameOnly) ;
if (ret) {
_owner->removeServer((RooAbsArg&)var) ;
}
return ret ;
}
void RooListProxy::removeAll()
{
TIterator* iter = createIterator() ;
RooAbsArg* arg ;
while ((arg=(RooAbsArg*)iter->Next())) {
_owner->removeServer(*arg) ;
}
delete iter ;
RooArgList::removeAll() ;
}
RooListProxy& RooListProxy::operator=(const RooArgList& other)
{
RooArgList::operator=(other) ;
return *this ;
}
Bool_t RooListProxy::changePointer(const RooAbsCollection& newServerList, Bool_t nameChange)
{
if (getSize()==0) return kTRUE ;
_iter->Reset() ;
RooAbsArg* arg ;
Bool_t error(kFALSE) ;
while ((arg=(RooAbsArg*)_iter->Next())) {
RooAbsArg* newArg= arg->findNewServer(newServerList, nameChange);
if (newArg) error |= !RooArgList::replace(*arg,*newArg) ;
}
return !error ;
}
void RooListProxy::print(ostream& os, Bool_t addContents) const
{
if (!addContents) {
os << name() << "=" ; printStream(os,kValue,kInline) ;
} else {
os << name() << "=(" ;
TIterator* iter = createIterator() ;
RooAbsArg* arg ;
Bool_t first2(kTRUE) ;
while ((arg=(RooAbsArg*)iter->Next())) {
if (first2) {
first2 = kFALSE ;
} else {
os << "," ;
}
arg->printStream(os,kValue|kName,kInline) ;
}
os << ")" ;
delete iter ;
}
}
Last change: Wed Jun 25 08:33:23 2008
Last generated: 2008-06-25 08:33
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.