| The Gaudi Framework v32r1 (f65d50dc)

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/Tuple.h"
7 #include "GaudiAlg/TupleObj.h"
8 #include "GaudiAlg/Tuples.h"
9 // ============================================================================
10
11 // ============================================================================
17 // ============================================================================
18
19 namespace Tuples {
26 namespace detail {
75 template <class HANDLER1, class HANDLER2>
76 class TupleObjImp : public TupleObj {
77 public:
86 TupleObjImp( HANDLER1 handler1, HANDLER2 handler2, const std::string& name, NTuple::Tuple* tuple,
87 const CLID& clid = CLID_ColumnWiseTuple, const Tuples::Type type = Tuples::NTUPLE )
88 : TupleObj( name, tuple, clid, type ), m_handler1( handler1 ), m_handler2( handler2 ) {}
89
90 public:
91 StatusCode Error( const std::string& msg, const StatusCode sc = StatusCode::FAILURE ) const override {
92 m_handler1( name() + " " + msg, sc );
93 return sc;
94 }
95
96 StatusCode Warning( const std::string& msg, const StatusCode sc = StatusCode::FAILURE ) const override {
97 m_handler2( name() + " " + msg, sc );
98 return sc;
99 }
100
101 private:
102 HANDLER1 m_handler1;
103 HANDLER2 m_handler2;
104 };
105
134 template <class HANDLER1, class HANDLER2>
135 auto createTupleObj( HANDLER1 handler1, HANDLER2 handler2, const std::string& name, NTuple::Tuple* tuple,
136 const CLID& clid = CLID_ColumnWiseTuple, const Tuples::Type type = Tuples::NTUPLE ) {
137 return std::make_unique<TupleObjImp<HANDLER1, HANDLER2>>( handler1, handler2, name, tuple, clid, type );
138 }
139
150 template <class OBJECT, class FUNCTION>
151 class ErrorHandler {
152 public:
154 ErrorHandler( const OBJECT* obj, FUNCTION fun ) : m_obj( obj ), m_fun( fun ) {}
155
156 public:
158 StatusCode operator()( const std::string& msg, const StatusCode sc, const size_t mp = 10 ) const {
159 return ( m_obj->*m_fun )( msg, sc, mp );
160 }
161
162 private:
163 // default constructor is private
164 ErrorHandler();
165
166 private:
167 const OBJECT* m_obj = nullptr;
168 FUNCTION m_fun;
169 };
170
190 template <class OBJECT, class FUNCTION>
191 inline ErrorHandler<OBJECT, FUNCTION> make_handler( const OBJECT* object, FUNCTION function ) {
192 return ErrorHandler<OBJECT, FUNCTION>( object, function );
193 }
194 } // namespace detail
195
214 template <class OWNER>
215 auto createTupleObj( const OWNER* owner, const std::string& name, NTuple::Tuple* tuple,
216 const CLID& clid = CLID_ColumnWiseTuple, const Tuples::Type type = Tuples::NTUPLE ) {
217 return detail::createTupleObj( detail::make_handler( owner, &OWNER::Error ),
218 detail::make_handler( owner, &OWNER::Warning ), name, tuple, clid, type );
219 }
220
221 } // end of namespace Tuples
222
223 // ============================================================================
224 // The END
225 // ============================================================================
226 #endif // GAUDIALG_TUPLEDETAIL_H
Tuples::detail::ErrorHandler::operator()
StatusCode operator()(const std::string &msg, const StatusCode sc, const size_t mp=10) const
the only one 'useful' method
Definition: TupleDetail.h:158
Tuples::detail::ErrorHandler::ErrorHandler
ErrorHandler(const OBJECT *obj, FUNCTION fun)
constructor
Definition: TupleDetail.h:154
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
TupleObj.h
Header file for class TupleObj.
Tuples::detail::createTupleObj
auto 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:135
Tuples::TupleObj::clid
const CLID & clid() const
accessor to the N-Tuple CLID
Definition: TupleObj.h:1859
Tuples::detail::TupleObjImp
The simplest concrete implementation of class TupleObj with 3 arbitrary error handlers Any types (cla...
Definition: TupleDetail.h:76
Tuples::detail::ErrorHandler::m_obj
const OBJECT * m_obj
Definition: TupleDetail.h:167
Tuples::TupleObj::type
Tuples::Type type() const
accessor to the N-Tuple type
Definition: TupleObj.h:1862
std::string
STL class.
Tuples::detail::TupleObjImp::Error
StatusCode Error(const std::string &msg, const StatusCode sc=StatusCode::FAILURE) const override
Definition: TupleDetail.h:91
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:199
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:86
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
gaudirun.type
type
Definition: gaudirun.py:142
Tuples::detail::ErrorHandler::m_fun
FUNCTION m_fun
Definition: TupleDetail.h:168
Tuples::TupleObj::tuple
const NTuple::Tuple * tuple() const
provide the access to underlying Gaudi N-tuple
Definition: TupleObj.h:1851
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:375
Tuples::createTupleObj
auto createTupleObj(const OWNER *owner, 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:215
Tuples::TupleObj::name
const std::string & name() const
get the name
Definition: TupleObj.h:1846
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:191
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
Tuples.h
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
Tuples::NTUPLE
Definition: TupleObj.h:80
Tuples::detail::ErrorHandler::ErrorHandler
ErrorHandler()
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:103
Tuples::Type
Type
the list of available types for ntuples
Definition: TupleObj.h:79
Tuples::detail::TupleObjImp::m_handler1
HANDLER1 m_handler1
Definition: TupleDetail.h:102
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:151
Tuples::detail::TupleObjImp::Warning
StatusCode Warning(const std::string &msg, const StatusCode sc=StatusCode::FAILURE) const override
Definition: TupleDetail.h:96
Tuples
General namespace for Tuple properties.
Definition: Maps.h:33