Patrick Venture | 33bf169 | 2018-11-06 20:19:17 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 3 | #include <cstdint> |
| 4 | #include <vector> |
| 5 | |
Patrick Venture | 33bf169 | 2018-11-06 20:19:17 -0800 | [diff] [blame] | 6 | namespace blobs |
| 7 | { |
| 8 | |
| 9 | /** |
| 10 | * Each data transport mechanism must implement the DataInterface. |
| 11 | */ |
| 12 | class DataInterface |
| 13 | { |
| 14 | public: |
| 15 | virtual ~DataInterface() = default; |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 16 | |
| 17 | /** |
| 18 | * Copy bytes from external interface (blocking call). |
| 19 | * |
| 20 | * @param[in] length - number of bytes to copy |
| 21 | * @return the bytes read |
| 22 | */ |
| 23 | virtual std::vector<std::uint8_t> copyFrom(std::uint32_t length) = 0; |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 24 | |
| 25 | /** |
| 26 | * set configuration. |
| 27 | * |
| 28 | * @param[in] configuration - byte vector of data. |
| 29 | * @return bool - returns true on success. |
| 30 | */ |
| 31 | virtual bool write(const std::vector<std::uint8_t>& configuration) = 0; |
| 32 | |
| 33 | /** |
| 34 | * read configuration. |
| 35 | * |
| 36 | * @return bytes - whatever bytes are required configuration information for |
| 37 | * the mechanism. |
| 38 | */ |
| 39 | virtual std::vector<std::uint8_t> read() = 0; |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | struct DataHandlerPack |
| 43 | { |
| 44 | std::uint16_t bitmask; |
| 45 | DataInterface* handler; |
Patrick Venture | 33bf169 | 2018-11-06 20:19:17 -0800 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | } // namespace blobs |