16#ifndef ROOFIT_ROOFITCORE_INC_ROOSTLREFCOUNTLIST_H_
17#define ROOFIT_ROOFITCORE_INC_ROOSTLREFCOUNTLIST_H_
49 void Add(
T * obj, std::size_t initialCount = 1) {
63 std::size_t
refCount(
typename Container_t::const_iterator item)
const {
71 template<
typename Obj_t>
72 std::size_t
refCount(
const Obj_t * obj)
const {
77 typename Container_t::const_iterator
begin()
const {
82 typename Container_t::const_iterator
end()
const {
113 template<
typename Obj_t>
114 typename Container_t::const_iterator
findByPointer(
const Obj_t * item)
const {
115 auto byPointer = [item](
const T * listItem) {
116 return listItem == item;
127 const std::string theName(
name);
128 auto byName = [&theName](
const T * element) {
129 return element->GetName() == theName;
138 auto nptr = item->namePtr();
139 auto byNamePointer = [nptr](
const T * element) {
140 return element->namePtr() == nptr;
148 template<
typename Obj_t>
169 void Remove(
const T * obj,
bool force =
false) {
173 const std::size_t pos = item -
_storage.begin();
204namespace STLRefCountListHelpers {
#define ClassDef(name, id)
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
A RooRefCountList is a RooLinkedList that keeps a reference counter with each added node.
The RooSTLRefCountList is a simple collection of pointers to the template objects with reference coun...
std::size_t refCount(typename Container_t::const_iterator item) const
Return ref count of item that iterator points to.
virtual ~RooSTLRefCountList()
Container_t::const_iterator findByNamePointer(const T *item) const
Find an item by comparing RooAbsArg::namePtr() adresses.
bool containsSameName(const char *name) const
Check if list contains an item using findByName().
bool containsByPointer(const Obj_t *obj) const
Check if list contains an item using findByPointer().
std::size_t refCount(const Obj_t *obj) const
Return ref count of item with given address.
const Container_t & containedObjects() const
Direct reference to container of objects held by this list.
void Remove(const T *obj, bool force=false)
Decrease ref count of given object.
Container_t::const_iterator begin() const
Iterator over contained objects.
std::vector< T * > Container_t
void Add(T *obj, std::size_t initialCount=1)
Add an object or increase refCount if it is already present.
RooSTLRefCountList & operator=(RooSTLRefCountList &&)=default
RooSTLRefCountList & operator=(const RooSTLRefCountList &)=default
RooSTLRefCountList(const RooSTLRefCountList &)=default
Container_t::const_iterator end() const
End of contained objects.
bool empty() const
Check if empty.
std::vector< std::size_t > _refCount
Container_t::const_iterator findByName(const char *name) const
Find an item by comparing strings returned by RooAbsArg::GetName()
std::size_t size() const
Number of contained objects (neglecting the ref count).
Container_t::const_iterator findByPointer(const Obj_t *item) const
Find an item by comparing its adress.
void RemoveAll(const T *obj)
Remove from list irrespective of ref count.
void reserve(std::size_t amount)
bool containsByNamePtr(const T *obj) const
Check if list contains an item using findByNamePointer().
RooSTLRefCountList< RooAbsArg > convert(const RooRefCountList &old)
Converter from the old RooRefCountList to RooSTLRefCountList.
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...