ATLAS Offline Software
AddDVProxy.h
Go to the documentation of this file.
1 // Dear emacs, this is -*- c++ -*-
2 /*
3  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4 */
5 #ifndef XAODCORE_ADDDVPROXY_H
6 #define XAODCORE_ADDDVPROXY_H
7 
8 // STL include(s):
9 #include <vector>
10 #include <set>
11 
12 // ROOT include(s):
13 #include <TClass.h>
14 #include <TError.h>
15 #include <TInterpreter.h>
16 
17 // EDM include(s):
19 
20 // Local include(s):
22 
39 #define ADD_DV_PROXY( TYPE ) \
40  namespace ROOT { \
41  TGenericClassInfo* GenerateInitInstance( const TYPE* ); \
42  } \
43  int register_##TYPE##_CollectionProxy() { \
44  xAOD::AddDVProxy::add< TYPE >( ROOT::GenerateInitInstance( ( TYPE* ) 0x0 ) ); \
45  return 1; \
46  } \
47  static int _R__UNIQUE_( dummy_##TYPE##_Var ) = \
48  register_##TYPE##_CollectionProxy(); \
49  R__UseDummy( _R__UNIQUE_( dummy_##TYPE##_Var ) )
50 
67 #define ADD_NS_DV_PROXY( NS, TYPE ) \
68  namespace ROOT { \
69  TGenericClassInfo* GenerateInitInstance( const NS::TYPE* ); \
70  } \
71  int register_##NS##_##TYPE##_CollectionProxy() { \
72  xAOD::AddDVProxy::add< NS::TYPE >( ROOT::GenerateInitInstance( ( NS::TYPE* ) 0x0 ) ); \
73  return 1; \
74  } \
75  static int _R__UNIQUE_( dummy_##NS##_##TYPE##_Var ) = \
76  register_##NS##_##TYPE##_CollectionProxy(); \
77  R__UseDummy( _R__UNIQUE_( dummy_##NS##_##TYPE##_Var ) )
78 
79 namespace xAOD {
80 
87  class AddDVProxy {
88 
89  private:
98  template< class T >
99  struct Helper {
100 
102  typedef T Cont_t;
104  typedef typename Cont_t::base_value_type Value_t;
105 
111  static void resize( void* obj, size_t size ) {
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  }
134 
135  }; // struct Helper
136 
138  static void loadDictionaries();
139 
140  public:
146  template < typename T >
147  static void add( ROOT::TGenericClassInfo* clInfo ) {
148 
149  // Load the minimal amount of required dictionaries:
151 
152  // Create the collection proxy instance:
154  new TDVCollectionProxy( ClassName< T >::name().c_str() );
155  proxy->SetResize( Helper< T >::resize );
156 
157  // Add it to the class info:
158  clInfo->AdoptCollectionProxy( proxy );
159 
160  return;
161  }
162 
163  }; // struct AddDVProxy
164 
165 } // namespace xAOD
166 
167 #endif // XAODCORE_ADDDVPROXY_H
xAOD::AddDVProxy::Helper::resize
static void resize(void *obj, size_t size)
Function taking care of resizing DataVector<T> objects in memory.
Definition: AddDVProxy.h:111
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
xAOD::TDVCollectionProxy
A Root collection proxy for DataVector containers.
Definition: TDVCollectionProxy.h:46
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
TDVCollectionProxy.h
xAOD::AddDVProxy::Helper::Cont_t
T Cont_t
Type of the DataVector container.
Definition: AddDVProxy.h:102
xAOD::AddDVProxy::loadDictionaries
static void loadDictionaries()
Helper function force-loading all the needed dictionaries.
Definition: AddDVProxy.cxx:104
lumiFormat.i
int i
Definition: lumiFormat.py:92
ClassName
An interface for getting the name of a class as a string.
Definition: AthenaKernel/AthenaKernel/ClassName.h:33
xAOD::AddDVProxy::add
static void add(ROOT::TGenericClassInfo *clInfo)
Set up collection proxy for a DataVector class.
Definition: AddDVProxy.h:147
xAOD::AddDVProxy::Helper
Helper structure implementing the resize(...) function.
Definition: AddDVProxy.h:99
SG::IAuxStore
Interface for non-const operations on an auxiliary store.
Definition: IAuxStore.h:48
DataVector.h
An STL vector of pointers that by default owns its pointed-to elements.
xAOD::AddDVProxy::Helper::Value_t
Cont_t::base_value_type Value_t
Type of the elements in the DataVector.
Definition: AddDVProxy.h:104
xAOD::AddDVProxy
Set up collection proxy for a DataVector class.
Definition: AddDVProxy.h:87
python.PyAthena.obj
obj
Definition: PyAthena.py:135
python.compressB64.c
def c
Definition: compressB64.py:93