BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Reconstruction/MdcPatRec/MdcRecoUtil/include/MdcRecoUtil/ComPackBase.h
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: ComPackBase.h,v 1.4 2009/12/23 02:59:56 zhangy Exp $
4//
5// Description:
6// Class ComPackBase
7// - Templated base class for utility classes that
8// take a concrete numerical type and convert it for use in micro
9// and nano databases.
10//
11// Environment:
12// Software developed for the BaBar Detector at the SLAC B-Factory.
13//
14// Author List:
15// D.E.Azzopardi Originator.
16//
17// Copyright Information:
18// Copyright (C) 1999 DESVA Research & Design, for Hedgehog Concepts
19//
20// History:
21// Migration for BESIII MDC
22//
23// Quote:
24// "It ain't what you do, it's the way that you do it"
25//
26//--------------------------------------------------------------------------
27
28#ifndef COMPACKBASE_HH
29#define COMPACKBASE_HH
30
31//
32// C includes
33//
34#include "MdcRecoUtil/BesODMGTypes.h"
35#include "MdcRecoUtil/ComPackBaseBase.h"
36#include <stddef.h>
37#include <stdlib.h>
38
39template <class T> class ComPackBase : public ComPackBaseBase {
40public:
41 ///////////////////
42 // Constructors: //
43 ///////////////////
45
46 ComPackBase( T minval, T maxval, d_ULong bitrange )
47 : _minVal( minval )
48 , _maxVal( maxval )
49 , _valRange( maxval - minval )
50 , _bitRange( bitrange )
51 , _bitMask( ( 1 << bitrange ) - 1 ) {
52 ;
53 }
54
55 ///////////////////
56 // Destructor: //
57 ///////////////////
58 virtual ~ComPackBase(){};
59
60 ///////////////////
61 // Packers: //
62 ///////////////////
63 virtual StatusCode pack( const T, d_ULong& ) const = 0;
64
65 ///////////////////
66 // Unpackers: //
67 ///////////////////
68 virtual StatusCode unpack( const d_ULong, T& ) const = 0;
69
70 ///////////////////
71 // Accessors: //
72 ///////////////////
73 virtual const T& getMinVal() const { return _minVal; };
74 virtual const T& getMaxVal() const { return _maxVal; };
75 virtual const T& getRange() const { return _valRange; };
76 // bitrange is defined as the number of bits used; bitmask is the hex map
77 d_ULong bitRange() const { return _bitRange; }
78 d_ULong bitMask() const { return _bitMask; }
79
80 // Don't allow copies, assignment
81 ComPackBase( const ComPackBase& ) { ::abort(); }
83 ::abort();
84 return *this;
85 }
86
87protected:
88 enum { _maxlongbits = 32 };
89 T _minVal;
90 T _maxVal;
91 T _valRange;
94};
95
96#endif
virtual StatusCode unpack(const d_ULong, T &) const =0
virtual StatusCode pack(const T, d_ULong &) const =0