| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 2010

# TupleDetail.h

Go to the documentation of this file.

    00001 // $Id: TupleDetail.h,v 1.2 2004/10/18 08:18:00 mato Exp $
    00002 #ifndef GAUDIALG_TUPLEDETAIL_H
    00003 #define GAUDIALG_TUPLEDETAIL_H 1
    00004 // ============================================================================
    00005 // Include files
    00006 // ============================================================================
    00007 #include "GaudiAlg/Tuples.h"
    00008 #include "GaudiAlg/Tuple.h"
    00009 #include "GaudiAlg/TupleObj.h"
    00010 // ============================================================================
    00011
    00012 // ============================================================================
    00018 // ============================================================================
    00019
    00020 namespace Tuples
    00021 {
    00028   namespace detail
    00029   {
    00078     template<class HANDLER1, class HANDLER2>
    00079     class TupleObjImp: public TupleObj
    00080     {
    00081     public:
    00090       TupleObjImp ( HANDLER1              handler1                      ,
    00091                     HANDLER2              handler2                      ,
    00092                     const std::string&    name                          ,
    00093                     NTuple::Tuple*        tuple                         ,
    00094                     const CLID&           clid = CLID_ColumnWiseTuple   ,
    00095                     const Tuples::Type    type = Tuples::NTUPLE         )
    00096         : TupleObj ( name , tuple , clid, type )
    00097         , m_handler1 ( handler1 )
    00098         , m_handler2 ( handler2 )
    00099       {}
    00100     public:
    00101
    00102       virtual StatusCode Error
    00103       ( const std::string& msg ,
    00104         const StatusCode   sc  = StatusCode::FAILURE ) const
    00105       { m_handler1 ( name() + msg , sc  ) ; return sc ; }
    00106
    00107       virtual StatusCode Warning
    00108       ( const std::string& msg ,
    00109         const StatusCode   sc  = StatusCode::FAILURE ) const
    00110       { m_handler2 ( name() + msg , sc  ) ; return sc ; }
    00111
    00112     protected:
    00114       virtual ~TupleObjImp(){}
    00115     private:
    00116       HANDLER1 m_handler1 ;
    00117       HANDLER2 m_handler2 ;
    00118     };
    00119
    00148     template<class HANDLER1, class HANDLER2>
    00149     inline TupleObj* createTupleObj
    00150     ( HANDLER1 handler1  ,
    00151       HANDLER2 handler2  ,
    00152       const std::string& name                          ,
    00153       NTuple::Tuple*     tuple                         ,
    00154       const CLID&        clid = CLID_ColumnWiseTuple   ,
    00155       const Tuples::Type type = Tuples::NTUPLE         )
    00156     {
    00157       return new TupleObjImp<HANDLER1,HANDLER2>
    00158         ( handler1 , handler2 ,
    00159           name     , tuple    , clid     , type  ) ;
    00160     }
    00161
    00172     template <class OBJECT, class FUNCTION>
    00173     class ErrorHandler
    00174     {
    00175     public:
    00177       ErrorHandler( const OBJECT* obj ,
    00178                     FUNCTION      fun )
    00179         : m_obj ( obj ) , m_fun ( fun ) {}
    00180     public:
    00182       StatusCode operator() ( const std::string& msg     ,
    00183                               const StatusCode   sc      ,
    00184                               const size_t       mp = 10 ) const
    00185       {
    00186         return (m_obj->*m_fun)( msg , sc , mp ) ;
    00187       }
    00188     private:
    00189       // default constructor is private
    00190       ErrorHandler();
    00191     private:
    00192       const OBJECT* m_obj ;
    00193       FUNCTION      m_fun ;
    00194     };
    00195
    00215     template <class OBJECT, class FUNCTION>
    00216     inline ErrorHandler<OBJECT,FUNCTION>
    00217     make_handler ( const OBJECT* object   ,
    00218                    FUNCTION      function )
    00219     { return ErrorHandler<OBJECT,FUNCTION>( object , function ); }
    00220
    00221   }
    00222
    00241   template <class OWNER>
    00242   inline TupleObj* createTupleObj
    00243   ( const OWNER*       owner                         ,
    00244     const std::string& name                          ,
    00245     NTuple::Tuple*     tuple                         ,
    00246     const CLID&        clid = CLID_ColumnWiseTuple   ,
    00247     const Tuples::Type type = Tuples::NTUPLE         )
    00248   {
    00249     return detail::createTupleObj
    00250       ( detail::make_handler ( owner , &OWNER::Error   ) ,
    00251         detail::make_handler ( owner , &OWNER::Warning ) ,
    00252         name , tuple , clid , type ) ;
    00253   }
    00254
    00255 } // end of namespace Tuples
    00256
    00257
    00258
    00259 // ============================================================================
    00260 // The END
    00261 // ============================================================================
    00262 #endif // GAUDIALG_TUPLEDETAIL_H
    00263 // ============================================================================