blob: 28675cead67e7f8c27d7901a6512c9a48802e099 [file] [log] [blame]
Patrick Venture25528b42018-11-06 18:29:43 -08001#pragma once
2
Patrick Venture400c6362018-11-06 20:06:11 -08003#include <cstdint>
Patrick Venturea78e39f2018-11-06 18:37:06 -08004#include <functional>
5#include <memory>
6#include <string>
Patrick Venture400c6362018-11-06 20:06:11 -08007#include <vector>
Patrick Venturea78e39f2018-11-06 18:37:06 -08008
Patrick Venture25528b42018-11-06 18:29:43 -08009namespace blobs
10{
11
12/**
13 * Each image update mechanism must implement the ImageHandlerInterface.
14 */
15class ImageHandlerInterface
16{
17 public:
18 virtual ~ImageHandlerInterface() = default;
19
20 /**
21 * open the firmware update mechanism.
22 *
Patrick Venturea78e39f2018-11-06 18:37:06 -080023 * @param[in] path - the path passed to the handler (the blob_id).
Patrick Venture25528b42018-11-06 18:29:43 -080024 * @return bool - returns true on success.
25 */
Patrick Venturea78e39f2018-11-06 18:37:06 -080026 virtual bool open(const std::string& path) = 0;
Patrick Venture400c6362018-11-06 20:06:11 -080027
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 Venturea78e39f2018-11-06 18:37:06 -080037};
38
39struct HandlerPack
40{
41 std::string blobName;
42 ImageHandlerInterface* handler;
Patrick Venture25528b42018-11-06 18:29:43 -080043};
44
45} // namespace blobs