Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooSTLRefCountList< T > Class Template Reference

template<class T>
class RooSTLRefCountList< T >

The RooSTLRefCountList is a simple collection of pointers to the template objects with reference counters.

The pointees are not owned, hence not deleted when removed from the collection. Objects can be searched for either by pointer or by name (confusion possible when objects with same name are present). This replicates the behaviour of the RooRefCountList.

Definition at line 39 of file RooSTLRefCountList.h.

Public Types

using Container_t = std::vector< T * >
 

Public Member Functions

 RooSTLRefCountList ()
 
 RooSTLRefCountList (const RooSTLRefCountList &)=default
 
virtual ~RooSTLRefCountList ()
 
void Add (T *obj, std::size_t initialCount=1)
 Add an object or increase refCount if it is already present.
 
Container_t::const_iterator begin () const
 Iterator over contained objects.
 
const Container_tcontainedObjects () const
 Direct reference to container of objects held by this list.
 
bool containsByNamePtr (const T *obj) const
 Check if list contains an item using findByNamePointer().
 
template<typename Obj_t >
bool containsByPointer (const Obj_t *obj) const
 Check if list contains an item using findByPointer().
 
bool containsSameName (const char *name) const
 Check if list contains an item using findByName().
 
bool empty () const
 Check if empty.
 
Container_t::const_iterator end () const
 End of contained objects.
 
Container_t::const_iterator findByName (const char *name) const
 Find an item by comparing strings returned by RooAbsArg::GetName()
 
T * findByNamePointer (const T *item) const
 Find an item by comparing RooAbsArg::namePtr() adresses.
 
T * findByNamePointer (TNamed const *namePtr) const
 
template<typename Obj_t >
Container_t::const_iterator findByPointer (const Obj_t *item) const
 Find an item by comparing its adress.
 
virtual TClassIsA () const
 
RooSTLRefCountListoperator= (const RooSTLRefCountList &)=default
 
RooSTLRefCountListoperator= (RooSTLRefCountList &&)=default
 
Container_t::value_type operator[] (std::size_t index) const
 Retrieve an element from the list.
 
template<typename Obj_t >
std::size_t refCount (const Obj_t *obj) const
 Return ref count of item with given address.
 
std::size_t refCount (typename Container_t::const_iterator item) const
 Return ref count of item that iterator points to.
 
int Remove (const T *obj, bool force=false)
 Decrease ref count of given object.
 
void RemoveAll (const T *obj)
 Remove from list irrespective of ref count.
 
int Replace (const T *oldObj, T *newObj)
 Replace an element with a new value, keeping the same refCount.
 
void reserve (std::size_t amount)
 
std::size_t size () const
 Number of contained objects (neglecting the ref count).
 
virtual void Streamer (TBuffer &)
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 

Static Public Member Functions

static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 

Static Public Attributes

static constexpr std::size_t minSizeForNamePointerOrdering = 7
 

Private Member Functions

void initializeOrderedStorage () const
 
std::vector< T * >::const_iterator lowerBoundByNamePointer (const T *item) const
 
std::vector< T * >::const_iterator lowerBoundByNamePointer (TNamed const *namePtr) const
 
bool orderedStorageNeedsSorting () const
 

Private Attributes

std::vector< T * > _orderedStorage
 
std::vector< UInt_t_refCount
 
unsigned long _renameCounterForLastSorting = 0
 !
 
Container_t _storage
 

Static Private Attributes

static std::size_t const * _renameCounter = nullptr
 

#include <RooSTLRefCountList.h>

Member Typedef Documentation

◆ Container_t

template<class T >
using RooSTLRefCountList< T >::Container_t = std::vector<T*>

Definition at line 41 of file RooSTLRefCountList.h.

Constructor & Destructor Documentation

◆ RooSTLRefCountList() [1/2]

template<class T >
RooSTLRefCountList< T >::RooSTLRefCountList ( )
inline

Definition at line 45 of file RooSTLRefCountList.h.

◆ RooSTLRefCountList() [2/2]

template<class T >
RooSTLRefCountList< T >::RooSTLRefCountList ( const RooSTLRefCountList< T > &  )
default

◆ ~RooSTLRefCountList()

template<class T >
virtual RooSTLRefCountList< T >::~RooSTLRefCountList ( )
inlinevirtual

Definition at line 55 of file RooSTLRefCountList.h.

Member Function Documentation

◆ Add()

template<class T >
void RooSTLRefCountList< T >::Add ( T *  obj,
std::size_t  initialCount = 1 
)
inline

Add an object or increase refCount if it is already present.

Only compares pointers to check for existing objects

Definition at line 59 of file RooSTLRefCountList.h.

◆ begin()

template<class T >
Container_t::const_iterator RooSTLRefCountList< T >::begin ( ) const
inline

Iterator over contained objects.

Definition at line 93 of file RooSTLRefCountList.h.

◆ Class()

template<class T >
static TClass * RooSTLRefCountList< T >::Class ( )
static
Returns
TClass describing this class

◆ Class_Name()

template<class T >
static const char * RooSTLRefCountList< T >::Class_Name ( )
static
Returns
Name of this class

◆ Class_Version()

template<class T >
static constexpr Version_t RooSTLRefCountList< T >::Class_Version ( )
inlinestaticconstexpr
Returns
Version of this class

Definition at line 312 of file RooSTLRefCountList.h.

◆ containedObjects()

template<class T >
const Container_t & RooSTLRefCountList< T >::containedObjects ( ) const
inline

Direct reference to container of objects held by this list.

Definition at line 109 of file RooSTLRefCountList.h.

◆ containsByNamePtr()

template<class T >
bool RooSTLRefCountList< T >::containsByNamePtr ( const T *  obj) const
inline

Check if list contains an item using findByNamePointer().

Definition at line 186 of file RooSTLRefCountList.h.

◆ containsByPointer()

template<class T >
template<typename Obj_t >
bool RooSTLRefCountList< T >::containsByPointer ( const Obj_t *  obj) const
inline

Check if list contains an item using findByPointer().

Definition at line 180 of file RooSTLRefCountList.h.

◆ containsSameName()

template<class T >
bool RooSTLRefCountList< T >::containsSameName ( const char *  name) const
inline

Check if list contains an item using findByName().

Definition at line 192 of file RooSTLRefCountList.h.

◆ DeclFileName()

template<class T >
static const char * RooSTLRefCountList< T >::DeclFileName ( )
inlinestatic
Returns
Name of the file containing the class declaration

Definition at line 312 of file RooSTLRefCountList.h.

◆ empty()

template<class T >
bool RooSTLRefCountList< T >::empty ( ) const
inline

Check if empty.

Definition at line 129 of file RooSTLRefCountList.h.

◆ end()

template<class T >
Container_t::const_iterator RooSTLRefCountList< T >::end ( ) const
inline

End of contained objects.

Definition at line 98 of file RooSTLRefCountList.h.

◆ findByName()

template<class T >
Container_t::const_iterator RooSTLRefCountList< T >::findByName ( const char *  name) const
inline

Find an item by comparing strings returned by RooAbsArg::GetName()

Definition at line 142 of file RooSTLRefCountList.h.

◆ findByNamePointer() [1/2]

template<class T >
T * RooSTLRefCountList< T >::findByNamePointer ( const T *  item) const
inline

Find an item by comparing RooAbsArg::namePtr() adresses.

Definition at line 155 of file RooSTLRefCountList.h.

◆ findByNamePointer() [2/2]

template<class T >
T * RooSTLRefCountList< T >::findByNamePointer ( TNamed const *  namePtr) const
inline

Definition at line 159 of file RooSTLRefCountList.h.

◆ findByPointer()

template<class T >
template<typename Obj_t >
Container_t::const_iterator RooSTLRefCountList< T >::findByPointer ( const Obj_t *  item) const
inline

Find an item by comparing its adress.

Definition at line 136 of file RooSTLRefCountList.h.

◆ initializeOrderedStorage()

template<class T >
void RooSTLRefCountList< T >::initializeOrderedStorage ( ) const
inlineprivate

Definition at line 289 of file RooSTLRefCountList.h.

◆ IsA()

template<class T >
virtual TClass * RooSTLRefCountList< T >::IsA ( ) const
inlinevirtual
Returns
TClass describing current object

Definition at line 312 of file RooSTLRefCountList.h.

◆ lowerBoundByNamePointer() [1/2]

template<class T >
std::vector< T * >::const_iterator RooSTLRefCountList< T >::lowerBoundByNamePointer ( const T *  item) const
inlineprivate

Definition at line 263 of file RooSTLRefCountList.h.

◆ lowerBoundByNamePointer() [2/2]

template<class T >
std::vector< T * >::const_iterator RooSTLRefCountList< T >::lowerBoundByNamePointer ( TNamed const *  namePtr) const
inlineprivate

Definition at line 267 of file RooSTLRefCountList.h.

◆ operator=() [1/2]

template<class T >
RooSTLRefCountList & RooSTLRefCountList< T >::operator= ( const RooSTLRefCountList< T > &  )
default

◆ operator=() [2/2]

template<class T >
RooSTLRefCountList & RooSTLRefCountList< T >::operator= ( RooSTLRefCountList< T > &&  )
default

◆ operator[]()

template<class T >
Container_t::value_type RooSTLRefCountList< T >::operator[] ( std::size_t  index) const
inline

Retrieve an element from the list.

Definition at line 103 of file RooSTLRefCountList.h.

◆ orderedStorageNeedsSorting()

template<class T >
bool RooSTLRefCountList< T >::orderedStorageNeedsSorting ( ) const
inlineprivate

Definition at line 279 of file RooSTLRefCountList.h.

◆ refCount() [1/2]

template<class T >
template<typename Obj_t >
std::size_t RooSTLRefCountList< T >::refCount ( const Obj_t *  obj) const
inline

Return ref count of item with given address.

Definition at line 88 of file RooSTLRefCountList.h.

◆ refCount() [2/2]

template<class T >
std::size_t RooSTLRefCountList< T >::refCount ( typename Container_t::const_iterator  item) const
inline

Return ref count of item that iterator points to.

Definition at line 79 of file RooSTLRefCountList.h.

◆ Remove()

template<class T >
int RooSTLRefCountList< T >::Remove ( const T *  obj,
bool  force = false 
)
inline

Decrease ref count of given object.

Shrink list if ref count reaches 0.

Parameters
objDecrease ref count of given object. Compare by pointer.
forceIf true, remove irrespective of ref count. Returns by how much the refCount for the element to be removed was decreased (zero if nothing was removed). If force == false, it can only be zero or one, if force == true, it can be the full refCount for that element.

Definition at line 204 of file RooSTLRefCountList.h.

◆ RemoveAll()

template<class T >
void RooSTLRefCountList< T >::RemoveAll ( const T *  obj)
inline

Remove from list irrespective of ref count.

Definition at line 255 of file RooSTLRefCountList.h.

◆ Replace()

template<class T >
int RooSTLRefCountList< T >::Replace ( const T *  oldObj,
T *  newObj 
)
inline

Replace an element with a new value, keeping the same refCount.

Will return the refCount for that element if the replacement succeeded, otherwise returns zero in case the oldObj could not be found in the collection.

Definition at line 239 of file RooSTLRefCountList.h.

◆ reserve()

template<class T >
void RooSTLRefCountList< T >::reserve ( std::size_t  amount)
inline

Definition at line 121 of file RooSTLRefCountList.h.

◆ size()

template<class T >
std::size_t RooSTLRefCountList< T >::size ( ) const
inline

Number of contained objects (neglecting the ref count).

Definition at line 115 of file RooSTLRefCountList.h.

◆ Streamer()

template<class T >
virtual void RooSTLRefCountList< T >::Streamer ( TBuffer )
virtual

◆ StreamerNVirtual()

template<class T >
void RooSTLRefCountList< T >::StreamerNVirtual ( TBuffer ClassDef_StreamerNVirtual_b)
inline

Definition at line 312 of file RooSTLRefCountList.h.

Member Data Documentation

◆ _orderedStorage

template<class T >
std::vector<T*> RooSTLRefCountList< T >::_orderedStorage
mutableprivate

Definition at line 304 of file RooSTLRefCountList.h.

◆ _refCount

template<class T >
std::vector<UInt_t> RooSTLRefCountList< T >::_refCount
private

Definition at line 303 of file RooSTLRefCountList.h.

◆ _renameCounter

template<class T >
std::size_t const * RooSTLRefCountList< T >::_renameCounter = nullptr
staticprivate

Definition at line 310 of file RooSTLRefCountList.h.

◆ _renameCounterForLastSorting

template<class T >
unsigned long RooSTLRefCountList< T >::_renameCounterForLastSorting = 0
mutableprivate

!

Definition at line 305 of file RooSTLRefCountList.h.

◆ _storage

template<class T >
Container_t RooSTLRefCountList< T >::_storage
private

Definition at line 302 of file RooSTLRefCountList.h.

◆ minSizeForNamePointerOrdering

template<class T >
constexpr std::size_t RooSTLRefCountList< T >::minSizeForNamePointerOrdering = 7
staticconstexpr

Definition at line 43 of file RooSTLRefCountList.h.

  • roofit/roofitcore/inc/RooSTLRefCountList.h