blob: 2df5b1543b11a07f3b4c88757d963c8e4a680e36 [file] [log] [blame]
Patrick Venture33bf1692018-11-06 20:19:17 -08001#pragma once
2
Patrick Venture1cde5f92018-11-07 08:26:47 -08003#include <cstdint>
4#include <vector>
5
Patrick Venture33bf1692018-11-06 20:19:17 -08006namespace blobs
7{
8
9/**
10 * Each data transport mechanism must implement the DataInterface.
11 */
12class DataInterface
13{
14 public:
15 virtual ~DataInterface() = default;
Patrick Venture1cde5f92018-11-07 08:26:47 -080016
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 Venture8c535332018-11-08 15:58:00 -080024
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 Venture1cde5f92018-11-07 08:26:47 -080040};
41
42struct DataHandlerPack
43{
44 std::uint16_t bitmask;
45 DataInterface* handler;
Patrick Venture33bf1692018-11-06 20:19:17 -080046};
47
48} // namespace blobs