PackerBase.hh 744 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
#ifndef PackerBase_HH
#define PackerBase_HH

#include <iostream>
#include <cstdint>
#include <cmath>
#include <cassert>

#include "utilities.cc"

class PackerBase {
public:
  PackerBase() : fDatum(0) {
  }
 
  ~PackerBase() {
  }
  
  void datum(uint8_t d) {
    fDatum=d;
  }

  uint8_t datum() const {
    return fDatum;
  }

  virtual std::string name() const {
    return "PackerBase";
  }
  
  virtual void pack(uint32_t d) {
    assert(false);
  }

  virtual uint32_t unpack() const {
    assert(false);
  }
  void print() const {
    std::cout << "PackerBase::print()  Datum = "
	      << printDec(fDatum) << " = "
	      << printHex(fDatum) << " = "
	      << printBin(fDatum) << std::endl;
  }

protected:
  uint8_t fDatum;
};

#endif