| # Gaudi Framework, version v20r4
Generated: 8 Jan 2009

# HCWNTupleCnv.h

Go to the documentation of this file.

    00001 // $Header: /tmp/svngaudi/tmp.jEpFh25751/Gaudi/HbookCnv/src/HCWNTupleCnv.h,v 1.3 2006/11/30 14:59:27 mato Exp $
    00002 #ifndef HBOOKCNV_HCWNTUPLECNV_H
    00003 #define HBOOKCNV_HCWNTUPLECNV_H 1
    00004
    00005
    00006 // Include files
    00007 #include "HNTupleCnv.h"
    00008
    00009
    00010 // Forward declarations
    00011 template <class TYPE> class CnvFactory;
    00012
    00013
    00014 //====================================================================
    00015 //  Column wise NTuple converter class definition
    00016 //--------------------------------------------------------------------
    00017 //
    00018 //  Package    : HbookCnv ( The LHCb Offline System)
    00019 //  Author     : M.Frank
    00020 //
    00021 //====================================================================
    00022
    00023
    00024 namespace HbookCnv {
    00025
    00048   class HCWNTupleCnv : public HNTupleCnv   {
    00049
    00051     friend class CnvFactory<HCWNTupleCnv>;
    00052
    00053   public:
    00055     static const CLID& classID()    {
    00056       return CLID_ColumnWiseTuple;
    00057     }
    00059     HCWNTupleCnv( ISvcLocator* svc ) : HNTupleCnv(svc, classID())    {
    00060     }
    00062     virtual ~HCWNTupleCnv()   {
    00063     }
    00064   protected:
    00066     virtual StatusCode load( long id, INTuple*& refpObject );
    00068     virtual StatusCode book(long idh, const std::string& location, INTuple* pObject);
    00070     virtual StatusCode declare(long idh, INTuple* pObject);
    00072     virtual StatusCode writeData(long idh, INTuple* pObject);
    00074     virtual StatusCode readData(long idh, INTuple* pObject, long ievt);
    00075     template <class T>
    00076     size_t saveItem(char* target, const T* src, size_t len)   {
    00077       long* tar = (long*)target;
    00078       for ( size_t i = 0; i < len; i++ )   {
    00079         *(tar++) = long( *(src++));
    00080       }
    00081       return sizeof(long)*len;
    00082     }
    00083     template <class T>
    00084     size_t loadItem(char* src, T* tar, size_t len)   {
    00085       long* s = (long*)src;
    00086       for ( size_t i = 0; i < len; i++ )   {
    00087         *(tar++) = T( *(s++));
    00088       }
    00089       return sizeof(long)*len;
    00090     }
    00091     size_t loadItem(char* src, bool* tar, size_t len)   {
    00092       long* s = (long*)src;
    00093       for ( size_t i = 0; i < len; i++ )   {
    00094         *(tar++) = (*(s++)) ? true : false;
    00095       }
    00096       return sizeof(long)*len;
    00097     }
    00098     size_t loadItem(char* src, float* target, size_t len)   {
    00099       memcpy(target, src, sizeof(float)*len);
    00100       return sizeof(float)*len;
    00101     }
    00102     size_t loadItem(char* src, double* target, size_t len)   {
    00103       memcpy(target, src, sizeof(double)*len);
    00104       return sizeof(double)*len;
    00105     }
    00106     size_t loadItem(char* src, long* target, size_t len)   {
    00107       memcpy(target, src, sizeof(long)*len);
    00108       return sizeof(long)*len;
    00109     }
    00110     size_t loadItem(char* src, unsigned long* target, size_t len)   {
    00111       memcpy(target, src, sizeof(unsigned long)*len);
    00112       return sizeof(unsigned long)*len;
    00113     }
    00114
    00115     size_t saveItem(char* target, float* src, size_t len)   {
    00116       memcpy(target, src, sizeof(float)*len);
    00117       return sizeof(float)*len;
    00118     }
    00119     size_t saveItem(char* target, double* src, size_t len)   {
    00120       memcpy(target, src, sizeof(double)*len);
    00121       return sizeof(double)*len;
    00122     }
    00123     size_t saveItem(char* target, long* src, size_t len)   {
    00124       memcpy(target, src, sizeof(long)*len);
    00125       return sizeof(long)*len;
    00126     }
    00127     size_t saveItem(char* target, unsigned long* src, size_t len)   {
    00128       memcpy(target, src, sizeof(unsigned long)*len);
    00129       return sizeof(unsigned long)*len;
    00130     }
    00131
    00132   };
    00133
    00134 }    // namespace HbookCnv
    00135
    00136
    00137 #endif    // HBOOKCNV_HCWNTUPLECNV_H