1 #pragma once
2 
3 #include "flags.hpp"
4 #include "progress.hpp"
5 
6 #include <chrono>
7 #include <cstdint>
8 #include <string>
9 #include <thread>
10 
11 namespace host_tool
12 {
13 
14 class DataInterface
15 {
16   public:
17     virtual ~DataInterface() = default;
18 
19     /**
20      * Given an open session to either /flash/image, /flash/tarball, or
21      * /flash/hash, this method will configure, and send the data, but not close
22      * the session.
23      *
24      * @param[in] input - path to file to send.
25      * @param[in] session - the session ID to use.
26      * @return bool on success.
27      */
28     virtual bool sendContents(const std::string& input,
29                               std::uint16_t session) = 0;
30 
waitForRetry()31     virtual void waitForRetry()
32     {
33         std::this_thread::sleep_for(std::chrono::seconds(1));
34     }
35 
36     /**
37      * Return the supported data interface for this.
38      *
39      * @return the enum value corresponding to the supported type.
40      */
41     virtual ipmi_flash::FirmwareFlags::UpdateFlags supportedType() const = 0;
42 };
43 
44 } // namespace host_tool
45