ATLAS Offline Software
Loading...
Searching...
No Matches
BitPacker.h
Go to the documentation of this file.
1// This file's extension implies that it's C, but it's really -*- C++ -*-.
2
3/*
4 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5*/
6
7// $Id$
14
15
16#ifndef CXXUTILS_BITPACKER_H
17#define CXXUTILS_BITPACKER_H
18
19
20#include <stdint.h>
21#include <cassert>
22
23
24namespace CxxUtils {
25
26
37template <class STREAM>
39{
40public:
46 BitPacker (uint8_t nbits, STREAM& stream);
47
48
55
56
62 void pack (uint32_t x);
63
64
65private:
67 uint32_t m_buf;
68
70 uint8_t m_nbuf;
71
73 uint8_t m_nbits;
74
76 STREAM& m_stream;
77};
78
79
89template <class STREAM>
91{
92public:
97 BitPacker8 (STREAM& stream);
98
99
105 BitPacker8 (uint8_t nbits, STREAM& stream);
106
107
114
115
121 void pack (uint32_t x);
122
123
124private:
126 uint32_t m_buf;
127
129 uint8_t m_nbuf;
130
132 STREAM& m_stream;
133};
134
135
145template <class STREAM>
147{
148public:
154 BitPacker16 (STREAM& stream);
155
156
162 BitPacker16 (uint8_t nbits, STREAM& stream);
163
164
171
172
178 void pack (uint32_t x);
179
180
181private:
183 uint32_t m_buf;
184
186 uint8_t m_nbuf;
187
189 STREAM& m_stream;
190};
191
192
193} // namespace CxxUtils
194
195
196#include "CxxUtils/BitPacker.icc"
197
198
199#endif // not CXXUTILS_BITPACKER_H
200
#define x
~BitPacker16()
Destructor.
uint8_t m_nbuf
Number of valid words currently buffered.
Definition BitPacker.h:186
BitPacker16(uint8_t nbits, STREAM &stream)
Constructor.
BitPacker16(STREAM &stream)
Constructor.
uint32_t m_buf
Buffer for the current words being packed.
Definition BitPacker.h:183
STREAM & m_stream
The output stream.
Definition BitPacker.h:189
void pack(uint32_t x)
Pack one value to the stream.
STREAM & m_stream
The output stream.
Definition BitPacker.h:132
~BitPacker8()
Destructor.
BitPacker8(uint8_t nbits, STREAM &stream)
Constructor.
uint32_t m_buf
Buffer for the current words being packed.
Definition BitPacker.h:126
void pack(uint32_t x)
Pack one value to the stream.
uint8_t m_nbuf
Number of valid bits currently buffered.
Definition BitPacker.h:129
BitPacker8(STREAM &stream)
Constructor.
uint8_t m_nbuf
Number of valid bits currently buffered.
Definition BitPacker.h:70
uint32_t m_buf
Buffer for the current words being packed.
Definition BitPacker.h:67
BitPacker(uint8_t nbits, STREAM &stream)
Constructor.
uint8_t m_nbits
Number of bits to use for each item.
Definition BitPacker.h:73
~BitPacker()
Destructor.
void pack(uint32_t x)
Pack one value to the stream.
STREAM & m_stream
The output stream.
Definition BitPacker.h:76