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 ,
94  const CLID& clid = CLID_ColumnWiseTuple ,
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 ,
156  {
158  ( handler1 , handler2 ,
159  name , tuple , clid , type ) ;
160  }
161 
172  template <class OBJECT, class FUNCTION>
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>
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 ,
248  {
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 // ============================================================================
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:150
ErrorHandler(const OBJECT *obj, FUNCTION fun)
constructor
Definition: TupleDetail.h:177
Header file for class TupleObj.
virtual StatusCode Error(const std::string &msg, const StatusCode sc=StatusCode::FAILURE) const
Definition: TupleDetail.h:103
TupleObj * 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:243
The simplest concrete implementation of class TupleObj with 3 arbitrary error handlers Any types (cla...
Definition: TupleDetail.h:79
virtual ~TupleObjImp()
empty protected destructor
Definition: TupleDetail.h:114
NTuple::Tuple * tuple() const
provide the access to underlying Gaudi N-tuple
Definition: TupleObj.h:2088
string type
Definition: gaudirun.py:126
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
Definition: TupleObj.h:180
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:90
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
unsigned int CLID
Class ID definition.
Definition: ClassID.h:9
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:367
StatusCode operator()(const std::string &msg, const StatusCode sc, const size_t mp=10) const
the only one 'useful' method
Definition: TupleDetail.h:182
Tuples::Type type() const
accessor to the N-Tuple type
Definition: TupleObj.h:2110
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:27
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:217
const CLID & clid() const
accessor to the N-Tuple CLID
Definition: TupleObj.h:2107
virtual StatusCode Warning(const std::string &msg, const StatusCode sc=StatusCode::FAILURE) const
Definition: TupleDetail.h:108
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:31
Type
the list of available types for ntuples
Definition: TupleObj.h:63
const std::string & name() const
get the name
Definition: TupleObj.h:2083
Header file for class : Tuple.
Concrete error handlers for dealing with classes, which supports member functions Error...
Definition: TupleDetail.h:173