Newer
Older
TB_Chris / TbIO / src / .svn / text-base / TbRawFile.h.svn-base
  1. #pragma once
  2.  
  3. // Tb/TbKernel
  4. #include "TbKernel/TbBufferedFile.h"
  5.  
  6. // Local
  7. #include "TbHeaderDecoder.h"
  8.  
  9. /** @class TbRawFile TbRawFile.h
  10. *
  11. * Interface for raw files in SPIDR format via TbBufferedFile (ROOT I/O)
  12. *
  13. */
  14.  
  15. class TbRawFile : public TbBufferedFile<1000000, uint64_t> {
  16. public:
  17. /// Constructor
  18. TbRawFile(const std::string& filename, TbHeaderDecoder* headerDecoder);
  19. /// Destructor
  20. virtual ~TbRawFile() {}
  21.  
  22. /// Return the file index
  23. unsigned int splitIndex() const { return m_split_index; }
  24. uint64_t size() const { return m_size; }
  25. /// Return the chip identifier
  26. std::string id() const { return m_id; }
  27. /// Return whether the file has been opened successfully
  28. bool good() const { return m_good; }
  29. /// Return the number of data packets in the file
  30. uint64_t nPackets() const { return m_nPackets; }
  31.  
  32. /// Set the offset in size of packets
  33. virtual void setOffset(const uint64_t offset) {
  34. TbBufferedFile::setOffset(offset * 8 + m_headerSize);
  35. }
  36.  
  37. protected:
  38. uint64_t m_size;
  39. /// Number of data packets in the file
  40. uint64_t m_nPackets;
  41. /// Index by which large files are divided
  42. unsigned int m_split_index;
  43. /// Header size in bytes
  44. unsigned int m_headerSize;
  45. /// Chip identifier
  46. std::string m_id;
  47. bool m_good;
  48. };