ATLAS Offline Software
Loading...
Searching...
No Matches
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
79namespace 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:
153 TDVCollectionProxy* proxy =
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
An STL vector of pointers that by default owns its pointed-to elements.
static std::string name()
Return the name of class T as a string.
Interface for non-const operations on an auxiliary store.
Definition IAuxStore.h:48
Set up collection proxy for a DataVector class.
Definition AddDVProxy.h:87
static void add(ROOT::TGenericClassInfo *clInfo)
Set up collection proxy for a DataVector class.
Definition AddDVProxy.h:147
static void loadDictionaries()
Helper function force-loading all the needed dictionaries.
A Root collection proxy for DataVector containers.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
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