apps/argos/CollectedData.hpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // <CollectedData.hpp> -*- C++ -*- | ||
| 2 | |||
| 3 | #pragma once | ||
| 4 | |||
| 5 | #include "simdb/apps/argos/StreamBuffer.hpp" | ||
| 6 | |||
| 7 | #include <string> | ||
| 8 | |||
| 9 | namespace simdb::argos { | ||
| 10 | |||
| 11 | /// \class CollectedData | ||
| 12 | /// \brief Wrapper around StreamBuffer which provides collection-specific APIs | ||
| 13 | class CollectedData | ||
| 14 | { | ||
| 15 | public: | ||
| 16 | 132720 | CollectedData(uint16_t cid) : | |
| 17 | 132720 | CollectedData(cid, nullptr) | |
| 18 | { | ||
| 19 | 132720 | } | |
| 20 | |||
| 21 | 132720 | CollectedData(uint16_t cid, TinyStrings<>* tiny_strings) : | |
| 22 | 132720 | cid_(cid), | |
| 23 | 132720 | buffer_(data_, tiny_strings) | |
| 24 | { | ||
| 25 | 132720 | reset(); | |
| 26 | 132720 | } | |
| 27 | |||
| 28 | CollectedData(CollectedData&&) = default; | ||
| 29 | CollectedData(const CollectedData&) = delete; | ||
| 30 | |||
| 31 | uint16_t getCID() const { return cid_; } | ||
| 32 | |||
| 33 | 170181 | const std::vector<char>& getData() const { return data_; } | |
| 34 | |||
| 35 | 132720 | StreamBuffer& getBuffer() { return buffer_; } | |
| 36 | |||
| 37 | 132720 | void reset() | |
| 38 | { | ||
| 39 | 132720 | data_.clear(); | |
| 40 | 132720 | buffer_.append(cid_); | |
| 41 | 132720 | } | |
| 42 | |||
| 43 | private: | ||
| 44 | uint16_t cid_ = 0; | ||
| 45 | std::vector<char> data_; | ||
| 46 | StreamBuffer buffer_; | ||
| 47 | }; | ||
| 48 | |||
| 49 | } // namespace simdb::argos | ||
| 50 |