Report problems to ATLAS LXR Team (with time and IP address indicated)

The LXR Cross Referencer

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Architecture: linux ]
Version: head ] [ nightly ] [ GaudiDev ]
  Links to LXR source navigation pages for stable releases [ 12.*.* ]   [ 13.*.* ]   [ 14.*.* ]   [ 15.*.* ] 

001 // $Id: GetData.h,v 1.1 2008/10/10 08:06:33 marcocle Exp $
002 // ============================================================================
003 #ifndef GAUDIUTILS_GETDATA_H 
004 #define GAUDIUTILS_GETDATA_H 1
005 // ============================================================================
006 // Include files
007 // ============================================================================
008 // GaudiKernel
009 // ============================================================================
010 #include "GaudiKernel/IDataProviderSvc.h"
011 #include "GaudiKernel/SmartDataPtr.h"
012 // ============================================================================
013 // GaudiUtils
014 // ============================================================================
015 #include "GaudiUtils/Range.h"
016 #include "GaudiUtils/NamedRange.h"
017 // ============================================================================
018 // Forward declaration 
019 // ============================================================================
020 template <class BASE> class GaudiCommon ; // GaudiAlg
021 // ============================================================================
022 namespace Gaudi
023 {
024   namespace Utils 
025   {
026     // ========================================================================
027     /** @struct _GetType 
028      *  Helper structure to define the proper return type for 
029      *  "get"-functions 
030      *  @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
031      *  @date   2008-07-22
032      */
033     template <class TYPE> 
034     struct _GetType        
035     { typedef TYPE* return_type ; };
036     // ========================================================================
037     /// the template specilization for pointers 
038     template <class TYPE> 
039     struct _GetType<TYPE*> 
040     { typedef TYPE* return_type ; };
041     // ========================================================================
042     /// the template specialization for references 
043     template <class TYPE> 
044     struct _GetType<TYPE&> 
045     { typedef TYPE* return_type ; };
046     // ========================================================================
047     /// the template specialization for "ranges"
048     template <class CONTAINER>
049     struct _GetType<Gaudi::Range_<CONTAINER> >
050     { typedef Gaudi::Range_<CONTAINER>      return_type ; };
051     // ========================================================================
052     /// the template specialization for "named ranges"
053     template <class CONTAINER>
054     struct _GetType<Gaudi::NamedRange_<CONTAINER> >
055     { typedef Gaudi::NamedRange_<CONTAINER> return_type ; };
056     // ========================================================================
057     /** @struct GetData GetData.h GaudiUtils/GetData.h
058      *
059      *  Helper structure for iplementation of  "get"-functions for 
060      *  GaudiCommon<BASE> 
061      *
062      *  @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
063      *  @date   2008-07-22
064      */
065     template <class TYPE>
066     struct GetData 
067     {
068     public:
069       // ======================================================================
070       typedef TYPE                                   Type        ;
071       /// the actual return type 
072       typedef typename _GetType<Type>::return_type   return_type ;
073       // ======================================================================
074     public:
075       // ======================================================================
076       /** the only one essential method 
077        *  @param common the actual "worker"
078        *  @param service pointer to Data Provider Service 
079        *  @param location location of objects in TES 
080        *  @return the data 
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         /// use Data Provider Service 
089         SmartDataPtr<TYPE> obj ( service , location ) ;
090         return_type aux = obj ;
091         /// check the data 
092         common.Assert ( !(!aux) , "get():: No valid data at '" + location + "'"  ) ;
093         /// debug printout 
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         // return located *VALID* data
100         return aux ;
101         // ====================================================================== 
102       }
103     };
104     // ========================================================================
105     /// the template specialization for ranges 
106     template <class TYPE>
107     struct GetData<Gaudi::Range_<std::vector<const TYPE*> > >
108     {
109     public:
110       // ======================================================================  
111       /// the actual return type 
112       typedef Gaudi::Range_<std::vector<const TYPE*> >   Type        ;
113       typedef typename _GetType<Type>::return_type       return_type ;
114       // ======================================================================  
115     public:
116       // ======================================================================  
117       /** the only one essential method 
118        *  @param common the actual "worker"
119        *  @param service pointer to Data Provider Service 
120        *  @param location location of objects in TES 
121        *  @return the data 
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         { // try to get the selection from TES 
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         { // get from TES the container 
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         // no valid data 
156         common.Assert ( false , "get():: No valid data at '" + location + "'"  ) ;
157         // the fictive return 
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     /// the template specialization for named ranges 
178     template <class TYPE>
179     struct GetData<Gaudi::NamedRange_<std::vector<const TYPE*> > > 
180     {
181     public:
182       // ======================================================================
183       /// the actual return type 
184       typedef Gaudi::NamedRange_<std::vector<const TYPE*> > Type        ;
185       typedef typename _GetType<Type>::return_type          return_type ;
186       // ======================================================================
187     public:
188       // ======================================================================
189       /** the only one essential method 
190        *  @param common the actual "worker"
191        *  @param service pointer to Data Provider Service 
192        *  @param location location of objects in TES 
193        *  @return the data 
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         { // try to get the selection from TES 
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         { // get from TES the container 
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         // no valid data 
228         common.Assert ( false , "get():: No valid data at '" + location + "'"  ) ;
229         // the fictive return 
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     /// the template specialization for pointer types 
252     template <class TYPE>
253     struct GetData<TYPE*> : public GetData<TYPE> {} ;
254     // ========================================================================
255     /// the template specialization for reference types 
256     template <class TYPE>
257     struct GetData<TYPE&> : public GetData<TYPE> {} ;
258     // ========================================================================
259   } // end of namespace Gaudi::Utils 
260   // ==========================================================================
261 } // end of namespace Gaudi 
262 // ============================================================================
263 // The END 
264 // ============================================================================
265 #endif // GAUDIUTILS_GETDATA_H
266 // ============================================================================
267 

source navigation ] diff markup ] identifier search ] general search ]

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. Valid HTML 4.01!