Regilo
A simple C++ library for controlling the Neato XV robot and the Hokuyo scanner.
regilo::Log Class Reference

The Log class is a basic log with a simple read/write functionality. More...

#include <log.hpp>

Inheritance diagram for regilo::Log:
regilo::ILog regilo::TimedLog< DurationT >

Public Member Functions

 Log (const std::string &filePath)
 Log constructor with logging to a file. More...
 
 Log (std::iostream &stream)
 Log constructor with logging to a stream. More...
 
virtual const std::string & getFilePath () const override
 Get the path of file if the log was created with a path otherwise the empty string. More...
 
virtual std::iostream & getStream () override
 Get the current underlying stream. More...
 
virtual bool isEnd () const override
 Test if the stream is EOF. More...
 
virtual std::string read () override
 Read one command from the log. More...
 
virtual std::string read (std::string &logCommand) override
 Read one command from the log. More...
 
virtual std::string readCommand (const std::string &command) override
 Read specified command from the log (the others are skipped). More...
 
virtual std::string readCommand (const std::string &command, std::string &logCommand) override
 Read specified command from the log (the others are skipped). More...
 
virtual void write (const std::string &command, const std::string &response) override
 Write a command and response to the log. More...
 
- Public Member Functions inherited from regilo::ILog
virtual ~ILog ()=default
 Default destructor.
 

Public Attributes

char MESSAGE_END = '$'
 A char that the log message ends with.
 

Protected Member Functions

virtual void readMetadata (std::istream &metaStream)
 Read meta data from the log. More...
 
virtual void writeMetadata (std::ostream &metaStream)
 Write meta data to the log. More...
 

Protected Attributes

std::iostream & stream
 The underlying stream.
 
std::size_t version = 1
 The log version.
 

Detailed Description

The Log class is a basic log with a simple read/write functionality.

It is used to log all commands that were send to the device.

Constructor & Destructor Documentation

regilo::Log::Log ( const std::string &  filePath)

Log constructor with logging to a file.

Parameters
filePathThe path of file.
regilo::Log::Log ( std::iostream &  stream)

Log constructor with logging to a stream.

Parameters
streamInput/output stream.

Member Function Documentation

virtual const std::string& regilo::Log::getFilePath ( ) const
inlineoverridevirtual

Get the path of file if the log was created with a path otherwise the empty string.

Returns
The path or empty string.

Implements regilo::ILog.

virtual std::iostream& regilo::Log::getStream ( )
inlineoverridevirtual

Get the current underlying stream.

Returns
The underlying stream.

Implements regilo::ILog.

virtual bool regilo::Log::isEnd ( ) const
inlineoverridevirtual

Test if the stream is EOF.

Returns
True if the log is in the EOF state.

Implements regilo::ILog.

virtual std::string regilo::Log::read ( )
overridevirtual

Read one command from the log.

Returns
The response of the command.

Implements regilo::ILog.

virtual std::string regilo::Log::read ( std::string &  logCommand)
overridevirtual

Read one command from the log.

Parameters
logCommandThe input of the command that was read.
Returns
The response of the command.

Implements regilo::ILog.

Reimplemented in regilo::TimedLog< DurationT >.

virtual std::string regilo::Log::readCommand ( const std::string &  command)
overridevirtual

Read specified command from the log (the others are skipped).

Parameters
commandThe command to read (The boost::algorithm::starts_with() method is used to compare).
Returns
The response of the command.

Implements regilo::ILog.

virtual std::string regilo::Log::readCommand ( const std::string &  command,
std::string &  logCommand 
)
overridevirtual

Read specified command from the log (the others are skipped).

Parameters
commandThe command to read (The boost::algorithm::starts_with() method is used to compare).
logCommandThe input of the command that was read.
Returns
The response of the command.

Implements regilo::ILog.

virtual void regilo::Log::readMetadata ( std::istream &  metaStream)
protectedvirtual

Read meta data from the log.

Parameters
metaStreamA stream that is used for reading.

Reimplemented in regilo::TimedLog< DurationT >.

virtual void regilo::Log::write ( const std::string &  command,
const std::string &  response 
)
overridevirtual

Write a command and response to the log.

Parameters
commandThe command (with all parameters).
responseThe response of the command.

Implements regilo::ILog.

Reimplemented in regilo::TimedLog< DurationT >.

virtual void regilo::Log::writeMetadata ( std::ostream &  metaStream)
protectedvirtual

Write meta data to the log.

Parameters
metaStreamA stream that is used for writing.

Reimplemented in regilo::TimedLog< DurationT >.


The documentation for this class was generated from the following file: