| # Gaudi Framework, version v20r2
Generated: 18 Jul 2008

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

- Search for |

- File List
- File Members

# 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
    00150     template<class HANDLER1, class HANDLER2>
    00151     inline TupleObj* createTupleObj
    00152     ( HANDLER1 handler1  ,
    00153       HANDLER2 handler2  ,
    00154       const std::string& name                          ,
    00155       NTuple::Tuple*     tuple                         ,
    00156       const CLID&        clid = CLID_ColumnWiseTuple   ,
    00157       const Tuples::Type type = Tuples::NTUPLE         )
    00158     {
    00159       return new TupleObjImp<HANDLER1,HANDLER2>
    00160         ( handler1 , handler2 ,
    00161           name     , tuple    , clid     , type  ) ;
    00162     }
    00163
    00174     template <class OBJECT, class FUNCTION>
    00175     class ErrorHandler
    00176     {
    00177     public:
    00179       ErrorHandler( const OBJECT* obj ,
    00180                     FUNCTION      fun )
    00181         : m_obj ( obj ) , m_fun ( fun ) {};
    00182     public:
    00184       StatusCode operator() ( const std::string& msg     ,
    00185                               const StatusCode   sc      ,
    00186                               const size_t       mp = 10 ) const
    00187       {
    00188         return (m_obj->*m_fun)( msg , sc , mp ) ;
    00189       }
    00190     private:
    00191       // defualt constructor is private
    00192       ErrorHandler();
    00193     private:
    00194       const OBJECT* m_obj ;
    00195       FUNCTION      m_fun ;
    00196     };
    00197
    00219     template <class OBJECT, class FUNCTION>
    00220     inline ErrorHandler<OBJECT,FUNCTION>
    00221     make_handler ( const OBJECT* object   ,
    00222                    FUNCTION      function )
    00223     { return ErrorHandler<OBJECT,FUNCTION>( object , function ); };
    00224
    00225   };
    00226
    00247   template <class OWNER>
    00248   inline TupleObj* createTupleObj
    00249   ( const OWNER*       owner                         ,
    00250     const std::string& name                          ,
    00251     NTuple::Tuple*     tuple                         ,
    00252     const CLID&        clid = CLID_ColumnWiseTuple   ,
    00253     const Tuples::Type type = Tuples::NTUPLE         )
    00254   {
    00255     return detail::createTupleObj
    00256       ( detail::make_handler ( owner , &OWNER::Error   ) ,
    00257         detail::make_handler ( owner , &OWNER::Warning ) ,
    00258         name , tuple , clid , type ) ;
    00259   };
    00260
    00261 }; // end of namespace Tuples
    00262
    00263
    00264
    00265 // ============================================================================
    00266 // The END
    00267 // ============================================================================
    00268 #endif // GAUDIALG_TUPLEDETAIL_H
    00269 // ============================================================================