| 1 |
#include <pbcopper/data/Frames.h> |
| 2 |
|
| 3 |
#include <pbcopper/data/FrameEncoders.h> |
| 4 |
|
| 5 |
#include <boost/algorithm/string/join.hpp> |
| 6 |
#include <boost/range/adaptor/transformed.hpp> |
| 7 |
|
| 8 |
#include <ostream> |
| 9 |
#include <type_traits> |
| 10 |
|
| 11 |
namespace PacBio { |
| 12 |
namespace Data { |
| 13 |
|
| 14 |
Frames::Frames(std::vector<uint16_t> frames) noexcept : std::vector<uint16_t>{std::move(frames)} {} |
| 15 |
|
| 16 |
const std::vector<uint16_t>& Frames::Data() const { return *this; } |
| 17 |
|
| 18 |
std::vector<uint16_t>& Frames::Data() { return *this; } |
| 19 |
|
| 20 |
std::vector<uint16_t>& Frames::DataRaw() { return *this; } |
| 21 |
|
| 22 |
Frames Frames::Decode(const std::vector<uint8_t>& codedData) |
| 23 |
{ |
| 24 |
return Decode(codedData, V1FrameEncoder{}); |
| 25 |
} |
| 26 |
|
| 27 |
std::vector<uint8_t> Frames::Encode(const std::vector<uint16_t>& frames) |
| 28 |
{ |
| 29 |
return Encode(frames, V1FrameEncoder{}); |
| 30 |
} |
| 31 |
|
| 32 |
std::vector<uint8_t> Frames::Encode(FrameCodec /*unused*/) const { return Encode(*this); } |
| 33 |
|
| 34 |
Frames& Frames::Data(std::vector<uint16_t> frames) |
| 35 |
{ |
| 36 |
*this = std::move(frames); |
| 37 |
return *this; |
| 38 |
} |
| 39 |
|
| 40 |
bool Frames::operator==(const Frames& other) const noexcept |
| 41 |
{ |
| 42 |
return static_cast<const std::vector<uint16_t>&>(*this) == |
| 43 |
static_cast<const std::vector<uint16_t>&>(other); |
| 44 |
} |
| 45 |
|
| 46 |
bool Frames::operator!=(const Frames& other) const noexcept { return !(*this == other); } |
| 47 |
|
| 48 |
std::ostream& operator<<(std::ostream& os, const Frames& frames) |
| 49 |
{ |
| 50 |
return os << "Frames(" |
| 51 |
<< boost::algorithm::join(frames | boost::adaptors::transformed( |
| 52 |
[](uint16_t i) { return std::to_string(i); }), |
| 53 |
", ") |
| 54 |
<< ')'; |
| 55 |
} |
| 56 |
|
| 57 |
} // namespace Data |
| 58 |
} // namespace PacBio |