| Report problems to ATLAS LXR Team (with time and IP address indicated) |
|
[ source navigation ] [ diff markup ] [ identifier search ] [ general search ] |
||||
|
||||||
| Links to LXR source navigation pages for stable releases | [ 12.*.* ] [ 13.*.* ] [ 14.*.* ] [ 15.*.* ] | |||||
001 // $Id: TupleDetail.h,v 1.2 2004/10/18 08:18:00 mato Exp $ 002 #ifndef GAUDIALG_TUPLEDETAIL_H 003 #define GAUDIALG_TUPLEDETAIL_H 1 004 // ============================================================================ 005 // Include files 006 // ============================================================================ 007 #include "GaudiAlg/Tuples.h" 008 #include "GaudiAlg/Tuple.h" 009 #include "GaudiAlg/TupleObj.h" 010 // ============================================================================ 011 012 // ============================================================================ 013 /** @file 014 * Colelction fo few 'technical' methods for instatiation of tuples 015 * @author Ivan BELYAEV 016 * @date 2004-01-27 017 */ 018 // ============================================================================ 019 020 namespace Tuples 021 { 022 /** @namespace detail TupleObj.h GaudiAlg/TupleObj.h 023 * namespace with few technical implementations 024 * 025 * @author Vanya BELYAEV Ivan.Belyaev@itep.ru 026 * @date 2004-01-23 027 */ 028 namespace detail 029 { 030 /** @class TupleObjImp 031 * 032 * The simplest concrete implementationof class TupleObj 033 * with 3 arbitrary error handlers 034 * Any types (classes, functions, etc.) which supports the 035 * semantics 036 * 037 * @code 038 * 039 * HANDLER obj = .. ; 040 * 041 * StatusCode obj( msg , sc ) 042 * 043 * @endcode 044 * 045 * can be used as error handler, e.g. 046 * 047 * @code 048 * 049 * void print_error ( const std::string& msg , StatusCode sc ) 050 * { std::cout << 051 * "Error" << msg << " code " << sc.getCode() << std::endl ; } 052 * void print_warning ( const std::string& msg , StatusCode sc ) 053 * { std::cout << 054 * "Warning" << msg << " code " << sc.getCode() << std::endl ; } 055 * void print_print ( const std::string& msg , StatusCode sc ) 056 * { std::cout << msg << " code " << sc.getCode() << std::endl ; } 057 * 058 * NTuple::Tuple* tuple = ... ; 059 * TupleObj* obj = 060 * createTupleObj( print_errror , 061 * print_warning , 062 * print_print , 063 * " my tuple " , ntuple ) ; 064 * 065 * @endcode 066 * 067 * Templated helper functions allow to avoid heavy semantics of 068 * dealing with explicit type 069 * 070 * Few concrete error handlers for dealing with classes, 071 * which suports member functions Erorr and Warning 072 * ( e.g. class GaudiAlgorithm or class GaudiTool ) 073 * are provided 074 * 075 * @author Vanya BELYAEV Ivan.Belyaev@itep.ru 076 * @date 2004-1-24 077 */ 078 template<class HANDLER1, class HANDLER2> 079 class TupleObjImp: public TupleObj 080 { 081 public: 082 /** constructor 083 * @param handler1 error handler 084 * @param handler2 warning handler 085 * @param name Name of the NTuple 086 * @param tuple NTuple itself 087 * @param clid NTuple CLID 088 * @param type NTuple type 089 */ 090 TupleObjImp ( HANDLER1 handler1 , 091 HANDLER2 handler2 , 092 const std::string& name , 093 NTuple::Tuple* tuple , 094 const CLID& clid = CLID_ColumnWiseTuple , 095 const Tuples::Type type = Tuples::NTUPLE ) 096 : TupleObj ( name , tuple , clid, type ) 097 , m_handler1 ( handler1 ) 098 , m_handler2 ( handler2 ) 099 {}; 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: 113 /// empty protected destructor 114 virtual ~TupleObjImp(){} 115 private: 116 HANDLER1 m_handler1 ; 117 HANDLER2 m_handler2 ; 118 }; 119 120 /** @fn createTupleObj 121 * 122 * Templated helper functions allow to avoid heavy semantics of 123 * dealing with explicit type of class TupleObjImp 124 * 125 * @code 126 * 127 * void print_error ( const std::string& msg , StatusCode sc ) 128 * { std::cout << 129 * "Error" << msg << " code " << sc.getCode() << std::endl ; } 130 * void print_warning ( const std::string& msg , StatusCode sc ) 131 * { std::cout << 132 * "Warning" << msg << " code " << sc.getCode() << std::endl ; } 133 * 134 * NTuple::Tuple* tuple = ... ; 135 * TupleObj* obj = 136 * createTupleObj( print_errror , 137 * print_warning , 138 * " my tuple " , ntuple ) ; 139 * 140 * @endcode 141 * 142 * Few concrete error handlers for dealing with classes, 143 * which suports member functions Erorr,Warning and Print 144 * ( e.g. class GaudiAlgorithm or class GaudiTool ) 145 * are provided 146 * 147 * @author Vanya BELYAEV Ivan.Belyaev@itep.ru 148 * @date 2004-1-24 149 */ 150 template<class HANDLER1, class HANDLER2> 151 inline TupleObj* createTupleObj 152 ( HANDLER1 handler1 , 153 HANDLER2 handler2 , 154 const std::string& name , 155 NTuple::Tuple* tuple , 156 const CLID& clid = CLID_ColumnWiseTuple , 157 const Tuples::Type type = Tuples::NTUPLE ) 158 { 159 return new TupleObjImp<HANDLER1,HANDLER2> 160 ( handler1 , handler2 , 161 name , tuple , clid , type ) ; 162 } 163 164 /** @class ErrorHandler 165 * 166 * Concrete error handlers for dealing with classes, 167 * which suports member functions Erorr,Warning and Print 168 * ( e.g. class GaudiAlgorithm or class GaudiTool ) 169 * are provided 170 * 171 * @author Vanya BELYAEV Ivan.Belyaev@itep.ru 172 * @date 2004-1-24 173 */ 174 template <class OBJECT, class FUNCTION> 175 class ErrorHandler 176 { 177 public: 178 /// constructor 179 ErrorHandler( const OBJECT* obj , 180 FUNCTION fun ) 181 : m_obj ( obj ) , m_fun ( fun ) {}; 182 public: 183 /// the only one 'useful' method 184 StatusCode operator() ( const std::string& msg , 185 const StatusCode sc , 186 const size_t mp = 10 ) const 187 { 188 return (m_obj->*m_fun)( msg , sc , mp ) ; 189 } 190 private: 191 // defualt constructor is private 192 ErrorHandler(); 193 private: 194 const OBJECT* m_obj ; 195 FUNCTION m_fun ; 196 }; 197 198 /** @fn make_handler 199 * 200 * Templated helper functions allow to avoid heavy semantics of 201 * dealing with explicit type of class ErrorHandler 202 * 203 * @code 204 * 205 * const GaudiAlgorithm* algo = ... ; 206 * 207 * // error handler using GaudiAlgorithm::Error member function 208 * make_handler( algo , &GaudiAlgorithm::Error ) ; 209 * 210 * const GaudiTool* tool = .... ; 211 * // error handler using GaudiTool::Print member function 212 * make_handler( tool , &GaudiTool::Print ) ; 213 * 214 * @endcode 215 * 216 * @author Vanya BELYAEV Ivan.Belyaev@itep.ru 217 * @date 2004-1-24 218 */ 219 template <class OBJECT, class FUNCTION> 220 inline ErrorHandler<OBJECT,FUNCTION> 221 make_handler ( const OBJECT* object , 222 FUNCTION function ) 223 { return ErrorHandler<OBJECT,FUNCTION>( object , function ); }; 224 225 }; 226 227 /** @fn createTupleObj 228 * 229 * Templated helper functions allow to avoid heavy semantics of 230 * dealing with explicit type of class TupleObjImp 231 * 232 * @code 233 * 234 * const GaudiAlgorithm* algo = ... ; 235 * NTuple::Tuple* tuple = ... ; 236 * TupleObj* obj = createTupleObj( algo , " my tuple 1 " , ntuple ) ; 237 * 238 * const GaudiTool* tool = ... ; 239 * NTuple::Tuple* tuple2 = ... ; 240 * TupleObj* obj2 = createTupleObj( tool , " my tuple 2 " , ntuple2 ) ; 241 * 242 * @endcode 243 * 244 * @author Vanya BELYAEV Ivan.Belyaev@itep.ru 245 * @date 2004-1-24 246 */ 247 template <class OWNER> 248 inline TupleObj* createTupleObj 249 ( const OWNER* owner , 250 const std::string& name , 251 NTuple::Tuple* tuple , 252 const CLID& clid = CLID_ColumnWiseTuple , 253 const Tuples::Type type = Tuples::NTUPLE ) 254 { 255 return detail::createTupleObj 256 ( detail::make_handler ( owner , &OWNER::Error ) , 257 detail::make_handler ( owner , &OWNER::Warning ) , 258 name , tuple , clid , type ) ; 259 }; 260 261 }; // end of namespace Tuples 262 263 264 265 // ============================================================================ 266 // The END 267 // ============================================================================ 268 #endif // GAUDIALG_TUPLEDETAIL_H 269 // ============================================================================ 270
| [ 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. |
|