Regilo
A simple C++ library for controlling the Neato XV robot and the Hokuyo scanner.
regilo::TimedLog< DurationT > Class Template Reference

The TimedLog class is used to log all commands with their timestamp. More...

#include <log.hpp>

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

Public Types

typedef DurationT Duration
 The duration type for this log.
 

Public Member Functions

virtual ~TimedLog ()=default
 Default destructor.
 
virtual std::chrono::nanoseconds getLastCommandNanoseconds () const override
 Get the last command time (after reading). More...
 
DurationT getLastCommandTime () const
 Get the last command time (after reading). More...
 
virtual void syncTime (bool sync=true) override
 Sync command times with real time. More...
 
virtual std::string read (std::string &logCommand) override
 Read one command from the log. 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::Log
 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 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...
 
- Public Member Functions inherited from regilo::ILog
virtual ~ILog ()=default
 Default destructor.
 
- Public Member Functions inherited from regilo::ITimedLog
virtual ~ITimedLog ()=default
 Default destructor.
 
template<typename Duration >
Duration getLastCommandTimeAs () const
 Get the last command time (after reading). More...
 

Protected Member Functions

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

Additional Inherited Members

- Public Attributes inherited from regilo::Log
char MESSAGE_END = '$'
 A char that the log message ends with.
 
- Protected Attributes inherited from regilo::Log
std::iostream & stream
 The underlying stream.
 
std::size_t version = 1
 The log version.
 

Detailed Description

template<typename DurationT = std::chrono::milliseconds>
class regilo::TimedLog< DurationT >

The TimedLog class is used to log all commands with their timestamp.

Member Function Documentation

template<typename DurationT = std::chrono::milliseconds>
virtual std::chrono::nanoseconds regilo::TimedLog< DurationT >::getLastCommandNanoseconds ( ) const
inlineoverridevirtual

Get the last command time (after reading).

Returns
Time since epoch as std::chrono::nanoseconds.

Implements regilo::ITimedLog.

template<typename DurationT = std::chrono::milliseconds>
DurationT regilo::TimedLog< DurationT >::getLastCommandTime ( ) const
inline

Get the last command time (after reading).

Returns
Time since epoch as Duration.
template<typename DurationT >
std::string regilo::TimedLog< DurationT >::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.

Reimplemented from regilo::Log.

template<typename DurationT >
void regilo::TimedLog< DurationT >::readMetadata ( std::istream &  metaStream)
overrideprotectedvirtual

Read meta data from the log.

Parameters
metaStreamA stream that is used for reading.

Reimplemented from regilo::Log.

template<typename DurationT = std::chrono::milliseconds>
virtual void regilo::TimedLog< DurationT >::syncTime ( bool  sync = true)
inlineoverridevirtual

Sync command times with real time.

It means that all read methods will block their executions until the current time is bigger than the command time.

Implements regilo::ITimedLog.

template<typename DurationT >
void regilo::TimedLog< DurationT >::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.

Reimplemented from regilo::Log.

template<typename DurationT >
void regilo::TimedLog< DurationT >::writeMetadata ( std::ostream &  metaStream)
overrideprotectedvirtual

Write meta data to the log.

Parameters
metaStreamA stream that is used for writing.

Reimplemented from regilo::Log.


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