| The Gaudi Framework v28r2p1 (f1a77ff4)

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

- File List
- File Members

TupleDetail.h
Go to the documentation of this file.
1 #ifndef GAUDIALG_TUPLEDETAIL_H
2 #define GAUDIALG_TUPLEDETAIL_H 1
3 // ============================================================================
4 // Include files
5 // ============================================================================
6 #include "GaudiAlg/Tuples.h"
7 #include "GaudiAlg/Tuple.h"
8 #include "GaudiAlg/TupleObj.h"
9 // ============================================================================
10
11 // ============================================================================
17 // ============================================================================
18
19 namespace Tuples
20 {
27 namespace detail
28 {
77 template<class HANDLER1, class HANDLER2>
78 class TupleObjImp: public TupleObj
79 {
80 public:
89 TupleObjImp ( HANDLER1 handler1 ,
90 HANDLER2 handler2 ,
91 const std::string& name ,
92 NTuple::Tuple* tuple ,
93 const CLID& clid = CLID_ColumnWiseTuple ,
94 const Tuples::Type type = Tuples::NTUPLE )
95 : TupleObj ( name , tuple , clid, type )
96 , m_handler1 ( handler1 )
97 , m_handler2 ( handler2 )
98 {}
99 public:
100
101 StatusCode Error
102 ( const std::string& msg ,
103 const StatusCode sc = StatusCode::FAILURE ) const override
104 { m_handler1 ( name() + " " + msg , sc ) ; return sc ; }
105
106 StatusCode Warning
107 ( const std::string& msg ,
108 const StatusCode sc = StatusCode::FAILURE ) const override
109 { m_handler2 ( name() + " " + msg , sc ) ; return sc ; }
110
111 protected:
113 ~TupleObjImp() override = default;
114 private:
115 HANDLER1 m_handler1 ;
116 HANDLER2 m_handler2 ;
117 };
118
147 template<class HANDLER1, class HANDLER2>
148 inline TupleObj* createTupleObj
149 ( HANDLER1 handler1 ,
150 HANDLER2 handler2 ,
151 const std::string& name ,
152 NTuple::Tuple* tuple ,
153 const CLID& clid = CLID_ColumnWiseTuple ,
154 const Tuples::Type type = Tuples::NTUPLE )
155 {
156 return new TupleObjImp<HANDLER1,HANDLER2>
157 ( handler1 , handler2 ,
158 name , tuple , clid , type ) ;
159 }
160
171 template <class OBJECT, class FUNCTION>
172 class ErrorHandler
173 {
174 public:
176 ErrorHandler( const OBJECT* obj ,
177 FUNCTION fun )
178 : m_obj ( obj ) , m_fun ( fun ) {}
179 public:
181 StatusCode operator() ( const std::string& msg ,
182 const StatusCode sc ,
183 const size_t mp = 10 ) const
184 {
185 return (m_obj->*m_fun)( msg , sc , mp ) ;
186 }
187 private:
188 // default constructor is private
189 ErrorHandler();
190 private:
191 const OBJECT* m_obj = nullptr;
192 FUNCTION m_fun ;
193 };
194
214 template <class OBJECT, class FUNCTION>
215 inline ErrorHandler<OBJECT,FUNCTION>
216 make_handler ( const OBJECT* object ,
217 FUNCTION function )
218 { return ErrorHandler<OBJECT,FUNCTION>( object , function ); }
219
220 }
221
240 template <class OWNER>
241 inline TupleObj* createTupleObj
242 ( const OWNER* owner ,
243 const std::string& name ,
244 NTuple::Tuple* tuple ,
245 const CLID& clid = CLID_ColumnWiseTuple ,
246 const Tuples::Type type = Tuples::NTUPLE )
247 {
248 return detail::createTupleObj
249 ( detail::make_handler ( owner , &OWNER::Error ) ,
250 detail::make_handler ( owner , &OWNER::Warning ) ,
251 name , tuple , clid , type ) ;
252 }
253
254 } // end of namespace Tuples
255
256
257
258 // ============================================================================
259 // The END
260 // ============================================================================
261 #endif // GAUDIALG_TUPLEDETAIL_H
262 // ============================================================================
Tuples::detail::createTupleObj
TupleObj * createTupleObj(HANDLER1 handler1, HANDLER2 handler2, const std::string &name, NTuple::Tuple *tuple, const CLID &clid=CLID_ColumnWiseTuple, const Tuples::Type type=Tuples::NTUPLE)
Templated helper functions allow to avoid heavy semantics of dealing with explicit type of class Tupl...
Definition: TupleDetail.h:149
Tuples::TupleObj::tuple
const NTuple::Tuple * tuple() const
provide the access to underlying Gaudi N-tuple
Definition: TupleObj.h:1988
Tuples::detail::TupleObjImp::~TupleObjImp
~TupleObjImp() override=default
empty protected destructor
Tuples::detail::ErrorHandler::ErrorHandler
ErrorHandler(const OBJECT *obj, FUNCTION fun)
constructor
Definition: TupleDetail.h:176
StatusCode::FAILURE
Definition: StatusCode.h:29
TupleObj.h
Header file for class TupleObj.
Tuples::detail::TupleObjImp
The simplest concrete implementation of class TupleObj with 3 arbitrary error handlers Any types (cla...
Definition: TupleDetail.h:78
std::string
STL class.
detail
TupleObj.h GaudiAlg/TupleObj.h namespace with few technical implementations.
Tuples::TupleObj
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
Definition: TupleObj.h:196
Tuples::detail::TupleObjImp::TupleObjImp
TupleObjImp(HANDLER1 handler1, HANDLER2 handler2, const std::string &name, NTuple::Tuple *tuple, const CLID &clid=CLID_ColumnWiseTuple, const Tuples::Type type=Tuples::NTUPLE)
constructor
Definition: TupleDetail.h:89
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Tuples::detail::ErrorHandler::m_fun
FUNCTION m_fun
Definition: TupleDetail.h:192
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
NTuple::Tuple
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:370
Tuples::detail::TupleObjImp::Error
StatusCode Error(const std::string &msg, const StatusCode sc=StatusCode::FAILURE) const override
Definition: TupleDetail.h:102
Gaudi::Functional::operator()
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
Tuples::TupleObj::type
Tuples::Type type() const
accessor to the N-Tuple type
Definition: TupleObj.h:2015
fun
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
Tuples.h
Tuples::NTUPLE
Definition: TupleObj.h:81
Tuples::detail::make_handler
ErrorHandler< OBJECT, FUNCTION > make_handler(const OBJECT *object, FUNCTION function)
Templated helper functions allow to avoid heavy semantics of dealing with explicit type of class Erro...
Definition: TupleDetail.h:216
Tuples::detail::TupleObjImp::Warning
StatusCode Warning(const std::string &msg, const StatusCode sc=StatusCode::FAILURE) const override
Definition: TupleDetail.h:107
Tuples::TupleObj::clid
const CLID & clid() const
accessor to the N-Tuple CLID
Definition: TupleObj.h:2012
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
Tuples::detail::TupleObjImp::m_handler2
HANDLER2 m_handler2
Definition: TupleDetail.h:116
Tuples::Type
Type
the list of available types for ntuples
Definition: TupleObj.h:79
Tuples::TupleObj::name
const std::string & name() const
get the name
Definition: TupleObj.h:1983
Tuples::detail::TupleObjImp::m_handler1
HANDLER1 m_handler1
Definition: TupleDetail.h:115
Tuple.h
Header file for class : Tuple.
Tuples::detail::ErrorHandler
Concrete error handlers for dealing with classes, which supports member functions Error...
Definition: TupleDetail.h:172
Tuples
General namespace for Tuple properties.
Definition: Maps.h:34