ATLAS Offline Software
Loading...
Searching...
No Matches
xAOD::AddDVProxy::Helper< T > Struct Template Reference

Helper structure implementing the resize(...) function. More...

Collaboration diagram for xAOD::AddDVProxy::Helper< T >:

Public Types

typedef T Cont_t
 Type of the DataVector container.
typedef Cont_t::base_value_type Value_t
 Type of the elements in the DataVector.

Static Public Member Functions

static void resize (void *obj, size_t size)
 Function taking care of resizing DataVector<T> objects in memory.

Detailed Description

template<class T>
struct xAOD::AddDVProxy::Helper< T >

Helper structure implementing the resize(...) function.

When reading a branch of DataVector<T>, one needs to use a non-generic version of the resize(...) function. This implementation should work fine for all DataVector<T> types.

Author
Attila Krasznahorkay Attil.nosp@m.a.Kr.nosp@m.aszna.nosp@m.hork.nosp@m.ay@ce.nosp@m.rn.c.nosp@m.h

Definition at line 99 of file AddDVProxy.h.

Member Typedef Documentation

◆ Cont_t

template<class T>
typedef T xAOD::AddDVProxy::Helper< T >::Cont_t

Type of the DataVector container.

Definition at line 102 of file AddDVProxy.h.

◆ Value_t

template<class T>
typedef Cont_t::base_value_type xAOD::AddDVProxy::Helper< T >::Value_t

Type of the elements in the DataVector.

Definition at line 104 of file AddDVProxy.h.

Member Function Documentation

◆ resize()

template<class T>
void xAOD::AddDVProxy::Helper< T >::resize ( void * obj,
size_t size )
inlinestatic

Function taking care of resizing DataVector<T> objects in memory.

when branches are read from a TTree.

Parameters
objA pointer to the full-blown DataVector object
sizeThe size to re-size the vector to

Definition at line 111 of file AddDVProxy.h.

111 {
112
113 // Cast the container to the right type:
114 Cont_t* c = reinterpret_cast< Cont_t* >( obj );
115
116 // Detach the DataVector from its auxiliary store:
117 c->setStore( ( SG::IAuxStore* ) 0 );
118
119 // Resize the container:
120 c->resize( size );
121
122 // Make sure that all elements exist and are usable:
123 for( size_t i = 0; i < size; ++i ) {
124
125 // If the element already exists, we're done:
126 if( ( *c )[ i ] ) continue;
127
128 // Create a new element:
129 ( *c )[ i ] = new Value_t();
130 }
131
132 return;
133 }
Helper structure implementing the resize(...) function.
Definition AddDVProxy.h:99
Cont_t::base_value_type Value_t
Type of the elements in the DataVector.
Definition AddDVProxy.h:104
static void resize(void *obj, size_t size)
Function taking care of resizing DataVector<T> objects in memory.
Definition AddDVProxy.h:111
T Cont_t
Type of the DataVector container.
Definition AddDVProxy.h:102

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