The ByteConverter
class represents a converter for byte data into string values based on their type and data.
ByteConverter(Source *source, Sink *sink)
: Class constructor. Takes pointers toSource
andSink
objects and creates an instance of theByteConverter
class.void start()
: Starts the process of byte data conversion. Creates a new execution thread and calls therun()
method.void stop()
: Stops the process of byte data conversion. Sets theisRunning_
flag tofalse
and waits for the execution thread to finish.
void run()
: Method that performs the byte data conversion process. In a loop, it checks for data availability in the source, reads the next byte, converts it into a string value, and writes it to theSink
. In case of an error, it outputs an error message to the standard error stream.
The Sink
class represents an interface for writing data.
virtual void writeData(const std::string &data) = 0
: Virtual method for writing data. Takes a stringdata
to be written.
The Source
class represents an interface for retrieving data.
virtual bool hasDataNext() const = 0
: Virtual method for checking if there is more data available. Returnstrue
if there is data to read, andfalse
otherwise.virtual std::uint8_t read() = 0
: Virtual method for reading the next byte of data. Returns the read byte.