| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TupleDetail.h
Go to the documentation of this file.
1 // $Id: TupleDetail.h,v 1.2 2004/10/18 08:18:00 mato Exp $
2 #ifndef GAUDIALG_TUPLEDETAIL_H
3 #define GAUDIALG_TUPLEDETAIL_H 1
4 // ============================================================================
5 // Include files
6 // ============================================================================
7 #include "GaudiAlg/Tuples.h"
8 #include "GaudiAlg/Tuple.h"
9 #include "GaudiAlg/TupleObj.h"
10 // ============================================================================
11
12 // ============================================================================
18 // ============================================================================
19
20 namespace Tuples
21 {
28 namespace detail
29 {
78 template<class HANDLER1, class HANDLER2>
79 class TupleObjImp: public TupleObj
80 {
81 public:
90 TupleObjImp ( HANDLER1 handler1 ,
91 HANDLER2 handler2 ,
92 const std::string& name ,
93 NTuple::Tuple* tuple ,
94 const CLID& clid = CLID_ColumnWiseTuple ,
95 const Tuples::Type type = Tuples::NTUPLE )
96 : TupleObj ( name , tuple , clid, type )
97 , m_handler1 ( handler1 )
98 , m_handler2 ( handler2 )
99 {}
100 public:
101
102 virtual StatusCode Error
103 ( const std::string& msg ,
104 const StatusCode sc = StatusCode::FAILURE ) const
105 { m_handler1 ( name() + " " + msg , sc ) ; return sc ; }
106
107 virtual StatusCode Warning
108 ( const std::string& msg ,
109 const StatusCode sc = StatusCode::FAILURE ) const
110 { m_handler2 ( name() + " " + msg , sc ) ; return sc ; }
111
112 protected:
114 virtual ~TupleObjImp(){}
115 private:
116 HANDLER1 m_handler1 ;
117 HANDLER2 m_handler2 ;
118 };
119
148 template<class HANDLER1, class HANDLER2>
149 inline TupleObj* createTupleObj
150 ( HANDLER1 handler1 ,
151 HANDLER2 handler2 ,
152 const std::string& name ,
153 NTuple::Tuple* tuple ,
154 const CLID& clid = CLID_ColumnWiseTuple ,
155 const Tuples::Type type = Tuples::NTUPLE )
156 {
157 return new TupleObjImp<HANDLER1,HANDLER2>
158 ( handler1 , handler2 ,
159 name , tuple , clid , type ) ;
160 }
161
172 template <class OBJECT, class FUNCTION>
173 class ErrorHandler
174 {
175 public:
177 ErrorHandler( const OBJECT* obj ,
178 FUNCTION fun )
179 : m_obj ( obj ) , m_fun ( fun ) {}
180 public:
182 StatusCode operator() ( const std::string& msg ,
183 const StatusCode sc ,
184 const size_t mp = 10 ) const
185 {
186 return (m_obj->*m_fun)( msg , sc , mp ) ;
187 }
188 private:
189 // default constructor is private
190 ErrorHandler();
191 private:
192 const OBJECT* m_obj ;
193 FUNCTION m_fun ;
194 };
195
215 template <class OBJECT, class FUNCTION>
216 inline ErrorHandler<OBJECT,FUNCTION>
217 make_handler ( const OBJECT* object ,
218 FUNCTION function )
219 { return ErrorHandler<OBJECT,FUNCTION>( object , function ); }
220
221 }
222
241 template <class OWNER>
242 inline TupleObj* createTupleObj
243 ( const OWNER* owner ,
244 const std::string& name ,
245 NTuple::Tuple* tuple ,
246 const CLID& clid = CLID_ColumnWiseTuple ,
247 const Tuples::Type type = Tuples::NTUPLE )
248 {
249 return detail::createTupleObj
250 ( detail::make_handler ( owner , &OWNER::Error ) ,
251 detail::make_handler ( owner , &OWNER::Warning ) ,
252 name , tuple , clid , type ) ;
253 }
254
255 } // end of namespace Tuples
256
257
258
259 // ============================================================================
260 // The END
261 // ============================================================================
262 #endif // GAUDIALG_TUPLEDETAIL_H
263 // ============================================================================