Patrick Venture | 25528b4 | 2018-11-06 18:29:43 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Patrick Venture | 400c636 | 2018-11-06 20:06:11 -0800 | [diff] [blame] | 3 | #include <cstdint> |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 4 | #include <functional> |
| 5 | #include <memory> |
| 6 | #include <string> |
Patrick Venture | 400c636 | 2018-11-06 20:06:11 -0800 | [diff] [blame] | 7 | #include <vector> |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 8 | |
Patrick Venture | 25528b4 | 2018-11-06 18:29:43 -0800 | [diff] [blame] | 9 | namespace blobs |
| 10 | { |
| 11 | |
| 12 | /** |
| 13 | * Each image update mechanism must implement the ImageHandlerInterface. |
| 14 | */ |
| 15 | class ImageHandlerInterface |
| 16 | { |
| 17 | public: |
| 18 | virtual ~ImageHandlerInterface() = default; |
| 19 | |
| 20 | /** |
| 21 | * open the firmware update mechanism. |
| 22 | * |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 23 | * @param[in] path - the path passed to the handler (the blob_id). |
Patrick Venture | 25528b4 | 2018-11-06 18:29:43 -0800 | [diff] [blame] | 24 | * @return bool - returns true on success. |
| 25 | */ |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 26 | virtual bool open(const std::string& path) = 0; |
Patrick Venture | 400c636 | 2018-11-06 20:06:11 -0800 | [diff] [blame] | 27 | |
| 28 | /** |
| 29 | * write data to the staged file. |
| 30 | * |
| 31 | * @param[in] offset - 0-based offset into the file. |
| 32 | * @param[in] data - the data to write. |
| 33 | * @return bool - returns true on success. |
| 34 | */ |
| 35 | virtual bool write(std::uint32_t offset, |
| 36 | const std::vector<std::uint8_t>& data) = 0; |
Patrick Venture | a78e39f | 2018-11-06 18:37:06 -0800 | [diff] [blame] | 37 | }; |
| 38 | |
| 39 | struct HandlerPack |
| 40 | { |
| 41 | std::string blobName; |
| 42 | ImageHandlerInterface* handler; |
Patrick Venture | 25528b4 | 2018-11-06 18:29:43 -0800 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | } // namespace blobs |