1 #pragma once
2 
3 #include <cstdlib>
4 
5 namespace host_tool
6 {
7 
8 class HostIoInterface
9 {
10   public:
11     virtual ~HostIoInterface() = default;
12 
13     /**
14      * Attempt to read bytes from offset to the destination from the host
15      * memory device.
16      *
17      * @param[in] offset - offset into the host memory device.
18      * @param[in] length - the number of bytes to copy from source.
19      * @param[in] destination - where to write the bytes.
20      * @return true on success, false on failure (such as unable to initialize
21      * device).
22      */
23     virtual bool read(const std::size_t offset, const std::size_t length,
24                       void* const destination) = 0;
25 
26     /**
27      * Attempt to write bytes from source to offset into the host memory device.
28      *
29      * @param[in] offset - offset into the host memory device.
30      * @param[in] length - the number of bytes to copy from source.
31      * @param[in] source - the source of the bytes to copy to the memory device.
32      * @return true on success, false on failure (such as unable to initialize
33      * device).
34      */
35     virtual bool write(const std::size_t offset, const std::size_t length,
36                        const void* const source) = 0;
37 };
38 
39 } // namespace host_tool
40