diff options
| author | Vasile Vilvoiu <vasi@vilvoiu.ro> | 2021-07-21 21:14:30 +0300 |
|---|---|---|
| committer | Vasile Vilvoiu <vasi@vilvoiu.ro> | 2021-07-21 21:14:30 +0300 |
| commit | ee8a1573204f76b16b9fb711608447aabee55696 (patch) | |
| tree | 50bbcf182716ee0b5b2e5c1ecf104f7143d0bbfe /src/input-reader.hpp | |
| parent | a7c430fa81c9e22dbce74869a0a27304da78855b (diff) | |
Added header file comments for classes and methods.
Renamed all factory methods to ::Build().
Diffstat (limited to 'src/input-reader.hpp')
| -rw-r--r-- | src/input-reader.hpp | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/input-reader.hpp b/src/input-reader.hpp index 3a98ef8..88843aa 100644 --- a/src/input-reader.hpp +++ b/src/input-reader.hpp @@ -13,14 +13,18 @@ #include <thread> #include <vector> -/* +/** * Input reader base class */ class InputReader { protected: - std::istream * const stream_; - const std::size_t block_size_bytes_; + std::istream * const stream_; /* stream we are straddling */ + const std::size_t block_size_bytes_; /* the size of a block in bytes */ + /** + * Retrieves an internal buffer that may or may not be block sized. + * @return Buffer. + */ virtual std::vector<char> GetBuffer() = 0; public: @@ -29,15 +33,26 @@ public: InputReader(InputReader&&) = delete; InputReader & operator=(const InputReader&) = delete; + /** + * @param stream Input stream to use. + * @param block_size_bytes Block size in bytes. + */ InputReader(std::istream * stream, std::size_t block_size_bytes); virtual ~InputReader() = default; + /** + * @return True if end of stream was received. + */ virtual bool ReachedEOF() const = 0; + + /** + * @return A block of bytes, if such a block exists. + */ virtual std::optional<std::vector<char>> GetBlock() = 0; }; -/* - * Synchronous input reader +/** + * Synchronous input reader specialization */ class SyncInputReader : public InputReader { protected: @@ -50,8 +65,8 @@ public: std::optional<std::vector<char>> GetBlock() override; }; -/* - * Asynchronous input reader +/** + * Asynchronous input reader specialization. */ class AsyncInputReader : public InputReader { private: @@ -75,7 +90,7 @@ public: AsyncInputReader(std::istream * stream, std::size_t block_size_bytes); ~AsyncInputReader() override; - bool ReachedEOF() const override; + bool ReachedEOF() const override; /* no EOF support is assumed in async input */ std::optional<std::vector<char>> GetBlock() override; }; |
