Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TVirtualCollectionProxy Class Referenceabstract

Defines a common interface to inspect/change the contents of an object that represents a collection.

Specifically, an object of a class that derives from TVirtualCollectionProxy relays accesses to any object that matches the proxied collection type. The interface provides two families of functions: (i) for direct manipulation, e.g. Insert() or At(); and (ii) iterator-based, e.g. GetFunctionCreateIterators() or GetFunctionNext(). TVirtualCollectionProxy objects are stateful; in particular, many functions require to set the object to operate on via PushProxy() / PopProxy(). The TPushPop RAII class is provided for convenience. A collection proxy for a given class can be permanently set using TClass::CopyCollectionProxy(). The Generate() function should be overridden in derived classes to return a clean object of the most-derived class.

Definition at line 52 of file TVirtualCollectionProxy.h.

Classes

class  TPushPop
 RAII helper class that ensures that PushProxy() / PopProxy() are called when entering / leaving a C++ context. More...
 

Public Types

typedef void *(* CopyIterator_t) (void *dest, const void *source)
 Copy the iterator source into dest.
 
typedef void(* CreateIterators_t) (void *collection, void **begin_arena, void **end_arena, TVirtualCollectionProxy *proxy)
 *begin_arena and *end_arena should contain the location of a memory arena of size fgIteratorArenaSize.
 
typedef void(* DeleteIterator_t) (void *iter)
 If the size of the iterator is greater than fgIteratorArenaSize, call delete on the addresses; otherwise, just call the iterator's destructor.
 
typedef void(* DeleteTwoIterators_t) (void *begin, void *end)
 
enum  EProperty { kIsAssociative = (1ULL << ( 2 )) , kIsEmulated = (1ULL << ( 3 )) , kNeedDelete = (1ULL << ( 4 )) , kCustomAlloc = (1ULL << ( 5 )) }
 
typedef void *(* Next_t) (void *iter, const void *end)
 iter and end should be pointers to an iterator to be incremented and an iterator that points to the end of the collection, respectively.
 

Public Member Functions

 TVirtualCollectionProxy ()
 
 TVirtualCollectionProxy (TClass *cl)
 
virtual ~TVirtualCollectionProxy ()
 
virtual void * Allocate (UInt_t n, Bool_t forceDelete)=0
 Allocates space for storing at least n elements.
 
virtual void * At (UInt_t idx)=0
 Return the address of the value at index idx
 
virtual void Clear (const char *opt="")=0
 Clear the container.
 
virtual void Commit (void *)=0
 Commits pending elements in a staging area (see Allocate() for more information).
 
virtual void DeleteArray (void *p, Bool_t dtorOnly=kFALSE) const
 Execute the container array destructor.
 
virtual void Destructor (void *p, Bool_t dtorOnly=kFALSE) const
 Execute the container destructor.
 
virtual TVirtualCollectionProxyGenerate () const =0
 Returns a clean object of the actual class that derives from TVirtualCollectionProxy.
 
virtual TClassGetCollectionClass () const
 Return a pointer to the TClass representing the proxied container class.
 
virtual Int_t GetCollectionType () const =0
 Return the type of the proxied collection (see enumeration TClassEdit::ESTLType)
 
virtual TStreamerInfoActions::TActionSequenceGetConversionReadMemberWiseActions (TClass *oldClass, Int_t version)=0
 
virtual CopyIterator_t GetFunctionCopyIterator (Bool_t read=kTRUE)=0
 Return a pointer to a function that can copy an iterator (see CopyIterator_t).
 
virtual CreateIterators_t GetFunctionCreateIterators (Bool_t read=kTRUE)=0
 Return a pointer to a function that can create an iterator pair, where each iterator points to the begin and end of the collection, respectively (see CreateIterators_t).
 
virtual DeleteIterator_t GetFunctionDeleteIterator (Bool_t read=kTRUE)=0
 Return a pointer to a function that can delete an iterator (pair) (see DeleteIterator_t).
 
virtual DeleteTwoIterators_t GetFunctionDeleteTwoIterators (Bool_t read=kTRUE)=0
 
virtual Next_t GetFunctionNext (Bool_t read=kTRUE)=0
 Return a pointer to a function that can advance an iterator (see Next_t).
 
virtual ULong_t GetIncrement () const =0
 Return the offset between two consecutive in-memory values (which depends on the sizeof() and alignment of the value type).
 
virtual Int_t GetProperties () const
 Return miscallenous properties of the proxy (see TVirtualCollectionProxy::EProperty)
 
virtual TStreamerInfoActions::TActionSequenceGetReadMemberWiseActions (Int_t version)=0
 
virtual EDataType GetType () const =0
 If the value type is a fundamental data type, return its type (see enumeration EDataType).
 
virtual TClassGetValueClass () const =0
 If the value type is a user-defined class, return a pointer to the TClass representing the value type of the container.
 
virtual TStreamerInfoActions::TActionSequenceGetWriteMemberWiseActions ()=0
 
virtual Bool_t HasPointers () const =0
 Return true if the content is of type 'pointer to'.
 
virtual void Insert (const void *data, void *container, size_t size)=0
 Insert elements into the proxied container.
 
virtual void * New () const
 Construct a new container object and return its address.
 
virtual void * New (void *arena) const
 Construct a new container object at the address given by arena
 
virtual void * NewArray (Int_t nElements) const
 Construct an array of nElements container objects and return the base address of the array.
 
virtual void * NewArray (Int_t nElements, void *arena) const
 Construct an array of nElements container objects at the address given by arena
 
virtual TClass::ObjectPtr NewObject () const
 Construct a new container object and return its address.
 
virtual TClass::ObjectPtr NewObject (void *arena) const
 Construct a new container object at the address given by arena
 
virtual TClass::ObjectPtr NewObjectArray (Int_t nElements) const
 Construct an array of nElements container objects and return the base address of the array.
 
virtual TClass::ObjectPtr NewObjectArray (Int_t nElements, void *arena) const
 Construct an array of nElements container objects at the address given by arena
 
char * operator[] (UInt_t idx) const
 Return the address of the value at index idx
 
virtual void PopProxy ()=0
 Reset the address of the container being proxied to the previous container.
 
virtual void PushProxy (void *objectstart)=0
 Set the address of the container being proxied and keep track of the previous one.
 
virtual Bool_t Reset ()
 Reset the information gathered from StreamerInfos and value's TClass.
 
virtual UInt_t Size () const =0
 Return the current number of elements in the container.
 
virtual UInt_t Sizeof () const =0
 Return the sizeof() of the collection object.
 

Static Public Attributes

static const Int_t fgIteratorArenaSize = 16
 The size of a small buffer that can be allocated on the stack to store iterator-specific information.
 

Protected Attributes

TClassRef fClass
 
UInt_t fProperties
 

Private Member Functions

 TVirtualCollectionProxy (const TVirtualCollectionProxy &)=delete
 
TVirtualCollectionProxyoperator= (const TVirtualCollectionProxy &)=delete
 

Friends

class TClass
 

#include <TVirtualCollectionProxy.h>

Inheritance diagram for TVirtualCollectionProxy:
[legend]

Member Typedef Documentation

◆ CopyIterator_t

typedef void *(* TVirtualCollectionProxy::CopyIterator_t) (void *dest, const void *source)

Copy the iterator source into dest.

dest should contain the location of a memory arena of size fgIteratorArenaSize. If iterator-specific information is of that size or less, the iterators will be constructed in place in the given locations. Otherwise, iterators will be allocated via new and their address returned by modifying the value of *begin_arena and *end_arena. The actual address of the iterator is returned in any case.

Definition at line 227 of file TVirtualCollectionProxy.h.

◆ CreateIterators_t

typedef void(* TVirtualCollectionProxy::CreateIterators_t) (void *collection, void **begin_arena, void **end_arena, TVirtualCollectionProxy *proxy)

*begin_arena and *end_arena should contain the location of a memory arena of size fgIteratorArenaSize.

If iterator-specific information is of that size or less, the iterators will be constructed in place in the given locations. Otherwise, iterators will be allocated via new and their address returned by modifying the value of *begin_arena and *end_arena. As a special case, given that iterators for array-backed containers are just pointers, the required information will be directly stored in *(begin|end)_arena.

Definition at line 215 of file TVirtualCollectionProxy.h.

◆ DeleteIterator_t

typedef void(* TVirtualCollectionProxy::DeleteIterator_t) (void *iter)

If the size of the iterator is greater than fgIteratorArenaSize, call delete on the addresses; otherwise, just call the iterator's destructor.

Definition at line 244 of file TVirtualCollectionProxy.h.

◆ DeleteTwoIterators_t

typedef void(* TVirtualCollectionProxy::DeleteTwoIterators_t) (void *begin, void *end)

Definition at line 245 of file TVirtualCollectionProxy.h.

◆ Next_t

typedef void *(* TVirtualCollectionProxy::Next_t) (void *iter, const void *end)

iter and end should be pointers to an iterator to be incremented and an iterator that points to the end of the collection, respectively.

If iter has not reached the end of the collection, this function increments the iterator and returns a pointer to the element before the increment. Otherwise, nullptr is returned.

Definition at line 236 of file TVirtualCollectionProxy.h.

Member Enumeration Documentation

◆ EProperty

Enumerator
kIsAssociative 
kIsEmulated 
kNeedDelete 

The collection contains directly or indirectly (via other collection) some pointers that need explicit deletion.

kCustomAlloc 

The collection has a custom allocator.

Definition at line 63 of file TVirtualCollectionProxy.h.

Constructor & Destructor Documentation

◆ TVirtualCollectionProxy() [1/3]

TVirtualCollectionProxy::TVirtualCollectionProxy ( const TVirtualCollectionProxy )
privatedelete

◆ TVirtualCollectionProxy() [2/3]

TVirtualCollectionProxy::TVirtualCollectionProxy ( )
inline

Definition at line 86 of file TVirtualCollectionProxy.h.

◆ TVirtualCollectionProxy() [3/3]

TVirtualCollectionProxy::TVirtualCollectionProxy ( TClass cl)
inline

Definition at line 87 of file TVirtualCollectionProxy.h.

◆ ~TVirtualCollectionProxy()

virtual TVirtualCollectionProxy::~TVirtualCollectionProxy ( )
inlinevirtual

Definition at line 88 of file TVirtualCollectionProxy.h.

Member Function Documentation

◆ Allocate()

virtual void * TVirtualCollectionProxy::Allocate ( UInt_t  n,
Bool_t  forceDelete 
)
pure virtual

Allocates space for storing at least n elements.

This function returns a pointer to the actual object on which insertions should take place. For associative collections, this function returns a pointer to a temporary buffer known as the staging area. If the insertion happened in a staging area (i.e. the returned pointer != proxied object), Commit() should be called on the value returned by this function.

Implemented in TEmulatedCollectionProxy, and TGenCollectionProxy.

◆ At()

virtual void * TVirtualCollectionProxy::At ( UInt_t  idx)
pure virtual

◆ Clear()

virtual void TVirtualCollectionProxy::Clear ( const char *  opt = "")
pure virtual

Clear the container.

Implemented in TEmulatedCollectionProxy, and TGenCollectionProxy.

◆ Commit()

virtual void TVirtualCollectionProxy::Commit ( void *  )
pure virtual

Commits pending elements in a staging area (see Allocate() for more information).

Implemented in TEmulatedCollectionProxy, and TGenCollectionProxy.

◆ DeleteArray()

virtual void TVirtualCollectionProxy::DeleteArray ( void *  p,
Bool_t  dtorOnly = kFALSE 
) const
inlinevirtual

Execute the container array destructor.

Reimplemented in TEmulatedCollectionProxy.

Definition at line 151 of file TVirtualCollectionProxy.h.

◆ Destructor()

virtual void TVirtualCollectionProxy::Destructor ( void *  p,
Bool_t  dtorOnly = kFALSE 
) const
inlinevirtual

Execute the container destructor.

Reimplemented in TEmulatedCollectionProxy.

Definition at line 144 of file TVirtualCollectionProxy.h.

◆ Generate()

virtual TVirtualCollectionProxy * TVirtualCollectionProxy::Generate ( ) const
pure virtual

Returns a clean object of the actual class that derives from TVirtualCollectionProxy.

The caller is responsible for deleting the returned object.

Implemented in TEmulatedCollectionProxy, TEmulatedMapProxy, TGenCollectionProxy, and TGenCollectionStreamer.

◆ GetCollectionClass()

virtual TClass * TVirtualCollectionProxy::GetCollectionClass ( ) const
inlinevirtual

Return a pointer to the TClass representing the proxied container class.

Reimplemented in TGenCollectionProxy.

Definition at line 98 of file TVirtualCollectionProxy.h.

◆ GetCollectionType()

virtual Int_t TVirtualCollectionProxy::GetCollectionType ( ) const
pure virtual

Return the type of the proxied collection (see enumeration TClassEdit::ESTLType)

Implemented in TGenCollectionProxy.

◆ GetConversionReadMemberWiseActions()

virtual TStreamerInfoActions::TActionSequence * TVirtualCollectionProxy::GetConversionReadMemberWiseActions ( TClass oldClass,
Int_t  version 
)
pure virtual

Implemented in TGenCollectionProxy.

◆ GetFunctionCopyIterator()

virtual CopyIterator_t TVirtualCollectionProxy::GetFunctionCopyIterator ( Bool_t  read = kTRUE)
pure virtual

Return a pointer to a function that can copy an iterator (see CopyIterator_t).

If read == kTRUE, data is to be read from disk, i.e. written to the in-memory collection.

Implemented in TGenCollectionProxy.

◆ GetFunctionCreateIterators()

virtual CreateIterators_t TVirtualCollectionProxy::GetFunctionCreateIterators ( Bool_t  read = kTRUE)
pure virtual

Return a pointer to a function that can create an iterator pair, where each iterator points to the begin and end of the collection, respectively (see CreateIterators_t).

If read == kTRUE, data is to be read from disk, i.e. written to the in-memory collection.

Implemented in TGenCollectionProxy.

◆ GetFunctionDeleteIterator()

virtual DeleteIterator_t TVirtualCollectionProxy::GetFunctionDeleteIterator ( Bool_t  read = kTRUE)
pure virtual

Return a pointer to a function that can delete an iterator (pair) (see DeleteIterator_t).

If read == kTRUE, data is to be read from disk, i.e. written to the in-memory collection.

Implemented in TGenCollectionProxy.

◆ GetFunctionDeleteTwoIterators()

virtual DeleteTwoIterators_t TVirtualCollectionProxy::GetFunctionDeleteTwoIterators ( Bool_t  read = kTRUE)
pure virtual

Implemented in TGenCollectionProxy.

◆ GetFunctionNext()

virtual Next_t TVirtualCollectionProxy::GetFunctionNext ( Bool_t  read = kTRUE)
pure virtual

Return a pointer to a function that can advance an iterator (see Next_t).

If read == kTRUE, data is to be read from disk, i.e. written to the in-memory collection.

Implemented in TGenCollectionProxy.

◆ GetIncrement()

virtual ULong_t TVirtualCollectionProxy::GetIncrement ( ) const
pure virtual

Return the offset between two consecutive in-memory values (which depends on the sizeof() and alignment of the value type).

Implemented in TGenCollectionProxy.

◆ GetProperties()

virtual Int_t TVirtualCollectionProxy::GetProperties ( ) const
inlinevirtual

Return miscallenous properties of the proxy (see TVirtualCollectionProxy::EProperty)

Definition at line 108 of file TVirtualCollectionProxy.h.

◆ GetReadMemberWiseActions()

virtual TStreamerInfoActions::TActionSequence * TVirtualCollectionProxy::GetReadMemberWiseActions ( Int_t  version)
pure virtual

Implemented in TGenCollectionProxy.

◆ GetType()

virtual EDataType TVirtualCollectionProxy::GetType ( ) const
pure virtual

If the value type is a fundamental data type, return its type (see enumeration EDataType).

Implemented in TGenCollectionProxy.

◆ GetValueClass()

virtual TClass * TVirtualCollectionProxy::GetValueClass ( ) const
pure virtual

If the value type is a user-defined class, return a pointer to the TClass representing the value type of the container.

Implemented in TGenCollectionProxy.

◆ GetWriteMemberWiseActions()

virtual TStreamerInfoActions::TActionSequence * TVirtualCollectionProxy::GetWriteMemberWiseActions ( )
pure virtual

Implemented in TGenCollectionProxy.

◆ HasPointers()

virtual Bool_t TVirtualCollectionProxy::HasPointers ( ) const
pure virtual

Return true if the content is of type 'pointer to'.

Implemented in TGenCollectionProxy.

◆ Insert()

virtual void TVirtualCollectionProxy::Insert ( const void *  data,
void *  container,
size_t  size 
)
pure virtual

Insert elements into the proxied container.

data is a C-style array of the value type of the given size. For associative containers, e.g. std::map, the data type should be std::pair<Key_t, Value_t>.

Implemented in TEmulatedCollectionProxy, and TGenCollectionProxy.

◆ New() [1/2]

virtual void * TVirtualCollectionProxy::New ( ) const
inlinevirtual

Construct a new container object and return its address.

Reimplemented in TEmulatedCollectionProxy.

Definition at line 111 of file TVirtualCollectionProxy.h.

◆ New() [2/2]

virtual void * TVirtualCollectionProxy::New ( void *  arena) const
inlinevirtual

Construct a new container object at the address given by arena

Reimplemented in TEmulatedCollectionProxy.

Definition at line 113 of file TVirtualCollectionProxy.h.

◆ NewArray() [1/2]

virtual void * TVirtualCollectionProxy::NewArray ( Int_t  nElements) const
inlinevirtual

Construct an array of nElements container objects and return the base address of the array.

Reimplemented in TEmulatedCollectionProxy.

Definition at line 126 of file TVirtualCollectionProxy.h.

◆ NewArray() [2/2]

virtual void * TVirtualCollectionProxy::NewArray ( Int_t  nElements,
void *  arena 
) const
inlinevirtual

Construct an array of nElements container objects at the address given by arena

Reimplemented in TEmulatedCollectionProxy.

Definition at line 128 of file TVirtualCollectionProxy.h.

◆ NewObject() [1/2]

virtual TClass::ObjectPtr TVirtualCollectionProxy::NewObject ( ) const
inlinevirtual

Construct a new container object and return its address.

Reimplemented in TEmulatedCollectionProxy.

Definition at line 115 of file TVirtualCollectionProxy.h.

◆ NewObject() [2/2]

virtual TClass::ObjectPtr TVirtualCollectionProxy::NewObject ( void *  arena) const
inlinevirtual

Construct a new container object at the address given by arena

Reimplemented in TEmulatedCollectionProxy.

Definition at line 120 of file TVirtualCollectionProxy.h.

◆ NewObjectArray() [1/2]

virtual TClass::ObjectPtr TVirtualCollectionProxy::NewObjectArray ( Int_t  nElements) const
inlinevirtual

Construct an array of nElements container objects and return the base address of the array.

Reimplemented in TEmulatedCollectionProxy.

Definition at line 133 of file TVirtualCollectionProxy.h.

◆ NewObjectArray() [2/2]

virtual TClass::ObjectPtr TVirtualCollectionProxy::NewObjectArray ( Int_t  nElements,
void *  arena 
) const
inlinevirtual

Construct an array of nElements container objects at the address given by arena

Reimplemented in TEmulatedCollectionProxy.

Definition at line 138 of file TVirtualCollectionProxy.h.

◆ operator=()

TVirtualCollectionProxy & TVirtualCollectionProxy::operator= ( const TVirtualCollectionProxy )
privatedelete

◆ operator[]()

char * TVirtualCollectionProxy::operator[] ( UInt_t  idx) const
inline

Return the address of the value at index idx

Definition at line 199 of file TVirtualCollectionProxy.h.

◆ PopProxy()

virtual void TVirtualCollectionProxy::PopProxy ( )
pure virtual

Reset the address of the container being proxied to the previous container.

Implemented in TGenCollectionProxy.

◆ PushProxy()

virtual void TVirtualCollectionProxy::PushProxy ( void *  objectstart)
pure virtual

Set the address of the container being proxied and keep track of the previous one.

Implemented in TGenCollectionProxy.

◆ Reset()

virtual Bool_t TVirtualCollectionProxy::Reset ( )
inlinevirtual

Reset the information gathered from StreamerInfos and value's TClass.

Reimplemented in TGenCollectionProxy.

Definition at line 95 of file TVirtualCollectionProxy.h.

◆ Size()

virtual UInt_t TVirtualCollectionProxy::Size ( ) const
pure virtual

Return the current number of elements in the container.

Implemented in TEmulatedCollectionProxy, TEmulatedMapProxy, and TGenCollectionProxy.

◆ Sizeof()

virtual UInt_t TVirtualCollectionProxy::Sizeof ( ) const
pure virtual

Return the sizeof() of the collection object.

Implemented in TEmulatedCollectionProxy, and TGenCollectionProxy.

Friends And Related Symbol Documentation

◆ TClass

friend class TClass
friend

Definition at line 60 of file TVirtualCollectionProxy.h.

Member Data Documentation

◆ fClass

TClassRef TVirtualCollectionProxy::fClass
protected

Definition at line 58 of file TVirtualCollectionProxy.h.

◆ fgIteratorArenaSize

const Int_t TVirtualCollectionProxy::fgIteratorArenaSize = 16
static

The size of a small buffer that can be allocated on the stack to store iterator-specific information.

Definition at line 207 of file TVirtualCollectionProxy.h.

◆ fProperties

UInt_t TVirtualCollectionProxy::fProperties
protected

Definition at line 59 of file TVirtualCollectionProxy.h.

Libraries for TVirtualCollectionProxy:

The documentation for this class was generated from the following file: