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 TVirtualCollectionProxy * | Generate () const =0 |
Returns a clean object of the actual class that derives from TVirtualCollectionProxy. | |
virtual TClass * | GetCollectionClass () 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::TActionSequence * | GetConversionReadMemberWiseActions (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::TActionSequence * | GetReadMemberWiseActions (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 TClass * | GetValueClass () 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::TActionSequence * | GetWriteMemberWiseActions ()=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 | |
TVirtualCollectionProxy & | operator= (const TVirtualCollectionProxy &)=delete |
Friends | |
class | TClass |
#include <TVirtualCollectionProxy.h>
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.
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.
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.
typedef void(* TVirtualCollectionProxy::DeleteTwoIterators_t) (void *begin, void *end) |
Definition at line 245 of file TVirtualCollectionProxy.h.
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.
Definition at line 63 of file TVirtualCollectionProxy.h.
|
privatedelete |
|
inline |
Definition at line 86 of file TVirtualCollectionProxy.h.
|
inline |
Definition at line 87 of file TVirtualCollectionProxy.h.
|
inlinevirtual |
Definition at line 88 of file TVirtualCollectionProxy.h.
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.
|
pure virtual |
Return the address of the value at index idx
Implemented in TEmulatedCollectionProxy, TEmulatedMapProxy, TGenCollectionProxy, TGenVectorProxy, TGenVectorBoolProxy, TGenBitsetProxy, TGenListProxy, and TGenSetProxy.
|
pure virtual |
Clear the container.
Implemented in TEmulatedCollectionProxy, and TGenCollectionProxy.
|
pure virtual |
Commits pending elements in a staging area (see Allocate() for more information).
Implemented in TEmulatedCollectionProxy, and TGenCollectionProxy.
|
inlinevirtual |
Execute the container array destructor.
Reimplemented in TEmulatedCollectionProxy.
Definition at line 151 of file TVirtualCollectionProxy.h.
|
inlinevirtual |
Execute the container destructor.
Reimplemented in TEmulatedCollectionProxy.
Definition at line 144 of file TVirtualCollectionProxy.h.
|
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.
|
inlinevirtual |
Return a pointer to the TClass
representing the proxied container class.
Reimplemented in TGenCollectionProxy.
Definition at line 98 of file TVirtualCollectionProxy.h.
|
pure virtual |
Return the type of the proxied collection (see enumeration TClassEdit::ESTLType)
Implemented in TGenCollectionProxy.
|
pure virtual |
Implemented in TGenCollectionProxy.
|
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.
|
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.
|
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.
|
pure virtual |
Implemented in TGenCollectionProxy.
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.
|
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.
|
inlinevirtual |
Return miscallenous properties of the proxy (see TVirtualCollectionProxy::EProperty)
Definition at line 108 of file TVirtualCollectionProxy.h.
|
pure virtual |
Implemented in TGenCollectionProxy.
|
pure virtual |
If the value type is a fundamental data type, return its type (see enumeration EDataType).
Implemented in TGenCollectionProxy.
|
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.
|
pure virtual |
Implemented in TGenCollectionProxy.
|
pure virtual |
Return true
if the content is of type 'pointer to'.
Implemented in TGenCollectionProxy.
|
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.
|
inlinevirtual |
Construct a new container object and return its address.
Reimplemented in TEmulatedCollectionProxy.
Definition at line 111 of file TVirtualCollectionProxy.h.
|
inlinevirtual |
Construct a new container object at the address given by arena
Reimplemented in TEmulatedCollectionProxy.
Definition at line 113 of file TVirtualCollectionProxy.h.
|
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.
|
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.
|
inlinevirtual |
Construct a new container object and return its address.
Reimplemented in TEmulatedCollectionProxy.
Definition at line 115 of file TVirtualCollectionProxy.h.
|
inlinevirtual |
Construct a new container object at the address given by arena
Reimplemented in TEmulatedCollectionProxy.
Definition at line 120 of file TVirtualCollectionProxy.h.
|
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.
|
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.
|
privatedelete |
|
inline |
Return the address of the value at index idx
Definition at line 199 of file TVirtualCollectionProxy.h.
|
pure virtual |
Reset the address of the container being proxied to the previous container.
Implemented in TGenCollectionProxy.
|
pure virtual |
Set the address of the container being proxied and keep track of the previous one.
Implemented in TGenCollectionProxy.
|
inlinevirtual |
Reset the information gathered from StreamerInfos and value's TClass.
Reimplemented in TGenCollectionProxy.
Definition at line 95 of file TVirtualCollectionProxy.h.
|
pure virtual |
Return the current number of elements in the container.
Implemented in TEmulatedCollectionProxy, TEmulatedMapProxy, and TGenCollectionProxy.
|
pure virtual |
Return the sizeof()
of the collection object.
Implemented in TEmulatedCollectionProxy, and TGenCollectionProxy.
|
friend |
Definition at line 60 of file TVirtualCollectionProxy.h.
|
protected |
Definition at line 58 of file TVirtualCollectionProxy.h.
|
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.
|
protected |
Definition at line 59 of file TVirtualCollectionProxy.h.