001
002
003 #ifndef GAUDIUTILS_GETDATA_H
004 #define GAUDIUTILS_GETDATA_H 1
005
006
007
008
009
010 #include "GaudiKernel/IDataProviderSvc.h"
011 #include "GaudiKernel/SmartDataPtr.h"
012
013
014
015 #include "GaudiUtils/Range.h"
016 #include "GaudiUtils/NamedRange.h"
017
018
019
020 template <class BASE> class GaudiCommon ;
021
022 namespace Gaudi
023 {
024 namespace Utils
025 {
026
027
028
029
030
031
032
033 template <class TYPE>
034 struct _GetType
035 { typedef TYPE* return_type ; };
036
037
038 template <class TYPE>
039 struct _GetType<TYPE*>
040 { typedef TYPE* return_type ; };
041
042
043 template <class TYPE>
044 struct _GetType<TYPE&>
045 { typedef TYPE* return_type ; };
046
047
048 template <class CONTAINER>
049 struct _GetType<Gaudi::Range_<CONTAINER> >
050 { typedef Gaudi::Range_<CONTAINER> return_type ; };
051
052
053 template <class CONTAINER>
054 struct _GetType<Gaudi::NamedRange_<CONTAINER> >
055 { typedef Gaudi::NamedRange_<CONTAINER> return_type ; };
056
057
058
059
060
061
062
063
064
065 template <class TYPE>
066 struct GetData
067 {
068 public:
069
070 typedef TYPE Type ;
071
072 typedef typename _GetType<Type>::return_type return_type ;
073
074 public:
075
076
077
078
079
080
081
082 template <class COMMON>
083 inline return_type operator()
084 ( const COMMON& common ,
085 IDataProviderSvc* service ,
086 const std::string& location ) const
087 {
088
089 SmartDataPtr<TYPE> obj ( service , location ) ;
090 return_type aux = obj ;
091
092 common.Assert ( !(!aux) , "get():: No valid data at '" + location + "'" ) ;
093
094 if ( common.msgLevel ( MSG::DEBUG ) )
095 { common.debug() << "The object of type '"
096 << System::typeinfoName(typeid(aux))
097 << "' has been retrieved from TS at address '"
098 << location << "'" << endreq ; }
099
100 return aux ;
101
102 }
103 };
104
105
106 template <class TYPE>
107 struct GetData<Gaudi::Range_<std::vector<const TYPE*> > >
108 {
109 public:
110
111
112 typedef Gaudi::Range_<std::vector<const TYPE*> > Type ;
113 typedef typename _GetType<Type>::return_type return_type ;
114
115 public:
116
117
118
119
120
121
122
123 template <class COMMON>
124 inline return_type operator()
125 ( const COMMON& common ,
126 IDataProviderSvc* service ,
127 const std::string& location ) const
128 {
129 {
130 SmartDataPtr<typename TYPE::Selection> obj ( service , location ) ;
131 typename TYPE::Selection* aux = obj ;
132 if ( 0 != aux )
133 {
134 if ( common.msgLevel ( MSG::DEBUG ) )
135 { common.debug() << "The object of type '"
136 << System::typeinfoName(typeid(*aux))
137 << "' has been retrieved from TS at address '"
138 << location << "'" << endreq ; }
139 return make_range ( aux->begin() , aux->end() ) ;
140 }
141 }
142 {
143 SmartDataPtr<typename TYPE::Container> obj ( service , location ) ;
144 typename TYPE::Container* aux = obj ;
145 if ( 0 != aux )
146 {
147 if ( common.msgLevel ( MSG::DEBUG ) )
148 { common.debug() << "The object of type '"
149 << System::typeinfoName(typeid(*aux))
150 << "' has been retrieved from TS at address '"
151 << location << "'" << endreq ; }
152 return make_range ( aux->begin() , aux->end() ) ;
153 }
154 }
155
156 common.Assert ( false , "get():: No valid data at '" + location + "'" ) ;
157
158 return return_type () ;
159 }
160
161 private:
162
163 template <class ITERATOR>
164 return_type make_range
165 ( ITERATOR first ,
166 ITERATOR last ) const
167 {
168 ITERATOR _begin = first ;
169 ITERATOR _end = last ;
170 return return_type
171 ( *reinterpret_cast<typename return_type::const_iterator*> ( &_begin ) ,
172 *reinterpret_cast<typename return_type::const_iterator*> ( &_end ) ) ;
173 }
174
175 } ;
176
177
178 template <class TYPE>
179 struct GetData<Gaudi::NamedRange_<std::vector<const TYPE*> > >
180 {
181 public:
182
183
184 typedef Gaudi::NamedRange_<std::vector<const TYPE*> > Type ;
185 typedef typename _GetType<Type>::return_type return_type ;
186
187 public:
188
189
190
191
192
193
194
195 template <class COMMON>
196 inline return_type operator()
197 ( const COMMON& common ,
198 IDataProviderSvc* service ,
199 const std::string& location ) const
200 {
201 {
202 SmartDataPtr<typename TYPE::Selection> obj ( service , location ) ;
203 typename TYPE::Selection* aux = obj ;
204 if ( 0 != obj )
205 {
206 if ( common.msgLevel ( MSG::DEBUG ) )
207 { common.debug() << "The object of type '"
208 << System::typeinfoName(typeid(*aux))
209 << "' has been retrieved from TS at address '"
210 << location << "'" << endreq ; }
211 return make_range ( aux -> begin() , aux -> end() , location ) ;
212 }
213 }
214 {
215 SmartDataPtr<typename TYPE::Container> obj ( service , location ) ;
216 typename TYPE::Container* aux = obj ;
217 if ( 0 != obj )
218 {
219 if ( common.msgLevel ( MSG::DEBUG ) )
220 { common.debug() << "The object of type '"
221 << System::typeinfoName(typeid(*aux))
222 << "' has been retrieved from TS at address '"
223 << location << "'" << endreq ; }
224 return make_range ( aux -> begin() , aux -> end() , location ) ;
225 }
226 }
227
228 common.Assert ( false , "get():: No valid data at '" + location + "'" ) ;
229
230 return return_type () ;
231 }
232
233 private:
234
235 template <class ITERATOR>
236 return_type make_range
237 ( ITERATOR first ,
238 ITERATOR last ,
239 const std::string& location ) const
240 {
241 ITERATOR _begin = first ;
242 ITERATOR _end = last ;
243 return return_type
244 ( *reinterpret_cast<typename return_type::const_iterator*> ( &_begin ) ,
245 *reinterpret_cast<typename return_type::const_iterator*> ( &_end ) ,
246 location ) ;
247 }
248
249 } ;
250
251
252 template <class TYPE>
253 struct GetData<TYPE*> : public GetData<TYPE> {} ;
254
255
256 template <class TYPE>
257 struct GetData<TYPE&> : public GetData<TYPE> {} ;
258
259 }
260
261 }
262
263
264
265 #endif
266
267
| Due to the LXR bug, the updates fail sometimes to remove references to deleted files. The Saturday's full rebuilds fix these problems |
|
This page was automatically generated by the
LXR engine.
|
|