30#ifndef roofit_roofitcore_RooFit_RooCollectionProxy_h
31#define roofit_roofitcore_RooFit_RooCollectionProxy_h
39template <
class RooCollection_t>
56 template <
class Other_t>
68 template <
class Other_t>
76 RooCollection_t::setName(other.GetName());
83 RooCollection_t::add(other);
103 const char *
name()
const override {
return RooCollection_t::GetName(); }
107 bool add(
const RooAbsArg &var,
bool valueServer,
bool shapeServer,
bool silent);
122#ifdef ROOFIT_MEMORY_SAFE_INTERFACES
126#ifdef ROOFIT_MEMORY_SAFE_INTERFACES
134 bool remove(
const RooAbsArg &var,
bool silent =
false,
bool matchByNameOnly =
false)
override;
141 for (
auto const &arg : list) {
149 void print(std::ostream &os,
bool addContents =
false)
const override;
154 RooCollection_t::operator=(other);
169 bool changePointer(std::unordered_map<RooAbsArg *, RooAbsArg *>
const &replacements)
override;
174 throw std::runtime_error(
175 "Attempt to add elements to a RooSetProxy or RooListProxy without owner!"
176 " Please avoid using the RooListProxy default constructor, which should only be used by IO.");
188template <
class RooCollection_t>
192 bool ret = RooCollection_t::add(var, silent);
194 _owner->addServer((
RooAbsArg &)var, valueServer, shapeServer);
204template <
class RooCollection_t>
208 bool ret = RooCollection_t::addOwned(var, silent);
210 _owner->addServer((
RooAbsArg &)var, _defValueServer, _defShapeServer);
220template <
class RooCollection_t>
224 RooAbsArg *ret = RooCollection_t::addClone(var, silent);
226 _owner->addServer((
RooAbsArg &)var, _defValueServer, _defShapeServer);
236template <
class RooCollection_t>
239 bool ret = RooCollection_t::replace(var1, var2);
241 if (!RooCollection_t::isOwning())
251template <
class RooCollection_t>
254 bool ret = RooCollection_t::remove(var, silent, matchByNameOnly);
255 if (ret && !RooCollection_t::isOwning()) {
265template <
class RooCollection_t>
268 if (!RooCollection_t::isOwning()) {
269 for (
auto const &arg : *
this) {
270 if (!RooCollection_t::isOwning()) {
271 _owner->removeServer(*arg);
276 RooCollection_t::removeAll();
283template <
class RooCollection_t>
285 bool factoryInitMode)
287 if (RooCollection_t::empty()) {
288 if (factoryInitMode) {
289 for (
const auto arg : newServerList) {
300 for (
auto const &arg : *
this) {
302 if (newArg && newArg != _owner)
303 error |= !RooCollection_t::replace(*arg, *newArg);
308template <
class RooCollection_t>
310 std::unordered_map<RooAbsArg *, RooAbsArg *>
const &replacements)
313 for (
auto const &arg : *
this) {
314 auto newArgFound = replacements.find(arg);
315 if (newArgFound != replacements.end()) {
316 error |= !RooCollection_t::replace(*arg, *newArgFound->second);
326template <
class RooCollection_t>
333 os <<
name() <<
"=(";
335 for (
auto const &arg : *
this) {
#define ClassDefOverride(name, id)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
void registerProxy(RooArgProxy &proxy)
Register an RooArgProxy in the proxy list.
void unRegisterProxy(RooArgProxy &proxy)
Remove proxy from proxy list.
bool isValueServer(const RooAbsArg &arg) const
Check if this is serving values to arg.
RooAbsArg * findNewServer(const RooAbsCollection &newSet, bool nameChange) const
Find the new server in the specified set that matches the old server.
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
virtual bool addOwned(RooAbsArg &var, bool silent=false)
Add an argument and transfer the ownership to the collection.
virtual RooAbsArg * addClone(const RooAbsArg &var, bool silent=false)
Add a clone of the specified argument to list.
RooAbsProxy is the abstact interface for proxy classes.
RooCollectionProxy is the concrete proxy for RooArgSet or RooArgList objects.
RooCollectionProxy & operator=(RooCollectionProxy &&other)=delete
void removeAll() override
Remove all argument inset using remove(const RooAbsArg&).
bool changePointer(const RooAbsCollection &newServerSet, bool nameChange=false, bool factoryInitMode=false) override
Process server change operation on owner.
bool defShapeServer() const
void print(std::ostream &os, bool addContents=false) const override
Printing name of proxy on ostream.
RooCollectionProxy & operator=(const RooCollection_t &other)
Assign values of arguments on other set to arguments in this set.
bool changePointer(std::unordered_map< RooAbsArg *, RooAbsArg * > const &replacements) override
void initializeAfterIOConstructor(RooAbsArg *owner, const Other_t &other)
Initializes this RooCollection proxy from another proxy.
bool addOwned(RooAbsArg &var, bool silent=false) override
Overloaded RooCollection_t::addOwned() method insert object into owning set and registers object as s...
RooCollectionProxy & operator=(RooCollectionProxy const &other)=delete
bool remove(const RooAbsCollection &list, bool silent=false, bool matchByNameOnly=false)
Remove each argument in the input list from our list using remove(const RooAbsArg&).
~RooCollectionProxy() override
bool add(const RooAbsArg &var, bool silent=false) override
Overloaded RooCollection_t::add() method inserts 'var' into set and registers 'var' as server to owne...
RooAbsArg * addClone(const RooAbsArg &var, bool silent=false) override
Overloaded RooCollection_t::addClone() method insert clone of object into owning set and registers cl...
bool add(const RooAbsArg &var, bool valueServer, bool shapeServer, bool silent)
Overloaded RooCollection_t::add() method insert object into set and registers object as server to own...
RooCollectionProxy(const char *inName, RooAbsArg *owner, const Other_t &other)
Copy constructor.
const char * name() const override
bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false) override
Remove object 'var' from set and deregister 'var' as server to owner.
bool replace(const RooAbsArg &var1, const RooAbsArg &var2) override
Replace object 'var1' in set with 'var2'.
bool defValueServer() const
RooCollectionProxy(const char *inName, const char *, RooAbsArg *owner, bool defValueServer=true, bool defShapeServer=false)
Construct proxy with given name and description, with given owner The default value and shape dirty p...