mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Refactor to use FluxmapReader.
This commit is contained in:
@@ -3,11 +3,11 @@
|
||||
|
||||
#include "bytes.h"
|
||||
|
||||
class RawBits;
|
||||
|
||||
class Fluxmap
|
||||
{
|
||||
public:
|
||||
uint32_t getAndIncrement(size_t& index) const;
|
||||
|
||||
nanoseconds_t duration() const { return _duration; }
|
||||
size_t bytes() const { return _bytes.size(); }
|
||||
const Bytes& rawBytes() const { return _bytes; }
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
}
|
||||
|
||||
nanoseconds_t guessClock() const;
|
||||
std::vector<bool> decodeToBits(nanoseconds_t clock_period) const;
|
||||
const RawBits decodeToBits(nanoseconds_t clock_period) const;
|
||||
|
||||
Fluxmap& appendBits(const std::vector<bool>& bits, nanoseconds_t clock);
|
||||
|
||||
@@ -43,4 +43,30 @@ private:
|
||||
Bytes _bytes;
|
||||
};
|
||||
|
||||
class FluxmapReader
|
||||
{
|
||||
public:
|
||||
FluxmapReader(const Fluxmap& fluxmap):
|
||||
_fluxmap(fluxmap),
|
||||
_bytes(fluxmap.ptr()),
|
||||
_size(fluxmap.bytes())
|
||||
{
|
||||
rewind();
|
||||
}
|
||||
|
||||
FluxmapReader(const Fluxmap&& fluxmap) = delete;
|
||||
|
||||
void rewind()
|
||||
{ _cursor = 0; }
|
||||
|
||||
int read(unsigned& ticks);
|
||||
int readPulse(unsigned& ticks);
|
||||
|
||||
private:
|
||||
const Fluxmap& _fluxmap;
|
||||
const uint8_t* _bytes;
|
||||
const size_t _size;
|
||||
size_t _cursor;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user