16#ifndef ROOFIT_ROOFITCORE_INC_ROOSTLREFCOUNTLIST_H_
17#define ROOFIT_ROOFITCORE_INC_ROOSTLREFCOUNTLIST_H_
51 void Add(T * obj, std::size_t initialCount = 1) {
65 std::size_t
refCount(
typename Container_t::const_iterator item)
const {
73 template<
typename Obj_t>
74 std::size_t
refCount(
const Obj_t * obj)
const {
79 typename Container_t::const_iterator
begin()
const {
84 typename Container_t::const_iterator
end()
const {
89 typename Container_t::value_type
operator[](std::size_t index)
const {
120 template<
typename Obj_t>
121 typename Container_t::const_iterator
findByPointer(
const Obj_t * item)
const {
122 auto byPointer = [item](
const T * listItem) {
123 return listItem == item;
134 const std::string theName(
name);
135 auto byName = [&theName](
const T * element) {
136 return element->GetName() == theName;
145 auto nptr = item->namePtr();
146 auto byNamePointer = [nptr](
const T * element) {
147 return element->namePtr() == nptr;
155 template<
typename Obj_t>
176 void Remove(
const T * obj,
bool force =
false) {
180 const std::size_t pos = item -
_storage.begin();
211namespace STLRefCountListHelpers {
#define ClassDef(name, id)
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
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
Container_t::value_type operator[](std::size_t index) const
Retrieve an element from the list.
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...