00001 //-------------------------------------------------------------------------- 00002 // File and Version Information: 00003 // $Id: ComPackBase.h,v 1.4 2009/12/23 02:59:56 zhangy Exp $ 00004 // 00005 // Description: 00006 // Class ComPackBase 00007 // - Templated base class for utility classes that 00008 // take a concrete numerical type and convert it for use in micro 00009 // and nano databases. 00010 // 00011 // Environment: 00012 // Software developed for the BaBar Detector at the SLAC B-Factory. 00013 // 00014 // Author List: 00015 // D.E.Azzopardi Originator. 00016 // 00017 // Copyright Information: 00018 // Copyright (C) 1999 DESVA Research & Design, for Hedgehog Concepts 00019 // 00020 // History: 00021 // Migration for BESIII MDC 00022 // 00023 // Quote: 00024 // "It ain't what you do, it's the way that you do it" 00025 // 00026 //-------------------------------------------------------------------------- 00027 00028 #ifndef COMPACKBASE_HH 00029 #define COMPACKBASE_HH 00030 00031 // 00032 // C includes 00033 // 00034 #include <stddef.h> 00035 #include <stdlib.h> 00036 #include "MdcRecoUtil/ComPackBaseBase.h" 00037 #include "MdcRecoUtil/BesODMGTypes.h" 00038 00039 template <class T> 00040 class ComPackBase : public ComPackBaseBase{ 00041 public: 00042 00044 // Constructors: // 00046 ComPackBase(){}; 00047 00048 ComPackBase(T minval, T maxval,d_ULong bitrange) : 00049 _minVal(minval),_maxVal(maxval),_valRange(maxval-minval), 00050 _bitRange(bitrange),_bitMask((1<<bitrange)-1){;} 00051 00053 // Destructor: // 00055 virtual ~ComPackBase(){}; 00056 00058 // Packers: // 00060 virtual StatusCode pack (const T ,d_ULong&) const =0; 00061 00063 // Unpackers: // 00065 virtual StatusCode unpack (const d_ULong, T &) const =0; 00066 00068 // Accessors: // 00070 virtual const T& getMinVal() const { return _minVal;}; 00071 virtual const T& getMaxVal() const { return _maxVal;}; 00072 virtual const T& getRange() const { return _valRange;}; 00073 // bitrange is defined as the number of bits used; bitmask is the hex map 00074 d_ULong bitRange() const { return _bitRange; } 00075 d_ULong bitMask() const { return _bitMask; } 00076 00077 // Don't allow copies, assignment 00078 ComPackBase( const ComPackBase& ) { ::abort(); } 00079 ComPackBase& operator= ( const ComPackBase& ) {::abort(); return *this;} 00080 00081 protected: 00082 00083 enum { _maxlongbits = 32 }; 00084 T _minVal; 00085 T _maxVal; 00086 T _valRange; 00087 d_ULong _bitRange; 00088 d_ULong _bitMask; 00089 }; 00090 00091 #endif 00092