1 #ifndef MARNAV_IO_DEVICE_HPP
2 #define MARNAV_IO_DEVICE_HPP
10 /// This is the base class for devices needed to perform IO operations.
11 /// It is simply an interface, no data members.
19 /// @exception std::runtime_error Error on opening the device.
20 virtual void open() = 0;
22 /// Closes the device.
23 virtual void close() = 0;
25 /// Reads data from the opened device into the buffer of the specified size.
27 /// @param[out] buffer The buffer to contain all read data.
28 /// @param[in] size The size of the buffer.
29 /// @return The number of bytes read into the buffer.
30 /// @exception std::invalid_argument Parameter errors (buffer is nullptr, size is zero, ...)
31 /// @exception std::runtime_error Probably a read error. This does not include EOF.
32 virtual int read(char * buffer
, uint32_t size
) = 0;
34 /// Writes to the opened device.
36 /// @param[in] buffer Data to write.
37 /// @param[in] size Number of bytes to write to the device.
38 /// @return The number of bytes written to the device.
39 /// @exception std::invalid_argument Parameter errors (buffer is nullptr, size is zero, ...)
40 /// @exception std::runtime_error Probably a read error. This does not include EOF.
41 virtual int write(const char * buffer
, uint32_t size
) = 0;