NDEVR
API Documentation
ConnectionBackendabstract

Provides the unseen backend logic for setting up, tearing down, and sending data over a specific type of connection. More...

Inheritance diagram for ConnectionBackend:
[legend]
Collaboration diagram for ConnectionBackend:
[legend]

Public Member Functions

 ConnectionBackend (LogPtr log)
 Constructs a ConnectionBackend with the given log.
virtual uint04 bytesAvailable () const =0
 Returns the number of bytes available to read.
virtual void close ()=0
 Closes the connection.
void connectionStateChangedSignal (ConnectionState state)
 Emitted when the connection state changes.
void dataAvailableSignal ()
 Emitted when data is available to be read from the connection.
virtual bool isOpen () const =0
 Checks whether the connection is currently open.
virtual TranslatedString lastError () const =0
 Returns the last error message from this backend.
virtual bool open (const ConnectionInfo &request)=0
 Opens the connection using the provided connection info.
virtual uint04 peek (char *s, uint04 size=Constant< uint04 >::Max) const =0
 Reads data from the receive buffer without consuming it.
virtual uint04 rx (char *s, uint04 max_size=Constant< uint04 >::Max)=0
 Reads and consumes data from the receive buffer.
virtual String threadID () const
 Returns the thread ID this backend must execute on, if any.
virtual void tx (const StringView &command)=0
 Transmits a string command over the connection.
virtual bool waitForReadyRead (const TimeSpan &span)=0
 Blocks until data is available to read or the timeout expires.

Protected Attributes

LogPtr m_log
 Log for diagnostic messages.

Detailed Description

Provides the unseen backend logic for setting up, tearing down, and sending data over a specific type of connection.


Definition at line 168 of file Connection.h.

Constructor & Destructor Documentation

◆ ConnectionBackend()

ConnectionBackend::ConnectionBackend ( LogPtr log)

Constructs a ConnectionBackend with the given log.

Parameters
[in]logThe log for diagnostic messages.

Member Function Documentation

◆ bytesAvailable()

virtual uint04 ConnectionBackend::bytesAvailable ( ) const
pure virtual

Returns the number of bytes available to read.

Returns
The number of bytes in the receive buffer.

Implemented in BluetoothConnection, DeviCounterSimulatorIO, SerialPortConnection, and SocketConnection.

◆ connectionStateChangedSignal()

void ConnectionBackend::connectionStateChangedSignal ( ConnectionState state)

Emitted when the connection state changes.

Parameters
[in]stateThe new connection state.

◆ isOpen()

virtual bool ConnectionBackend::isOpen ( ) const
pure virtual

Checks whether the connection is currently open.

Returns
True if the connection is open.

Implemented in BluetoothConnection, DeviCounterSimulatorIO, SerialPortConnection, and SocketConnection.

◆ lastError()

virtual TranslatedString ConnectionBackend::lastError ( ) const
pure virtual

Returns the last error message from this backend.

Returns
A translated error string describing the last error.

Implemented in BluetoothConnection, DeviCounterSimulatorIO, SerialPortConnection, and SocketConnection.

◆ open()

virtual bool ConnectionBackend::open ( const ConnectionInfo & request)
pure virtual

Opens the connection using the provided connection info.

Parameters
[in]requestThe connection parameters.
Returns
True if the connection was opened successfully.

Implemented in BluetoothConnection, DeviCounterSimulatorIO, SerialPortConnection, and SocketConnection.

◆ peek()

virtual uint04 ConnectionBackend::peek ( char * s,
uint04 size = Constantuint04 >::Max ) const
pure virtual

Reads data from the receive buffer without consuming it.

Parameters
[in]sThe buffer to write peeked data into.
[in]sizeMaximum number of bytes to peek.
Returns
The number of bytes actually peeked.

Implemented in BluetoothConnection, DeviCounterSimulatorIO, SerialPortConnection, and SocketConnection.

◆ rx()

virtual uint04 ConnectionBackend::rx ( char * s,
uint04 max_size = Constantuint04 >::Max )
pure virtual

Reads and consumes data from the receive buffer.

Parameters
[in]sThe buffer to write received data into.
[in]max_sizeMaximum number of bytes to read.
Returns
The number of bytes actually read.

Implemented in BluetoothConnection, DeviCounterSimulatorIO, SerialPortConnection, and SocketConnection.

◆ threadID()

virtual String ConnectionBackend::threadID ( ) const
inlinevirtual

Returns the thread ID this backend must execute on, if any.

Returns
The thread identifier, or an empty string if no constraint.

Reimplemented in SerialPortConnection.

Definition at line 231 of file Connection.h.

◆ tx()

virtual void ConnectionBackend::tx ( const StringView & command)
pure virtual

Transmits a string command over the connection.

Parameters
[in]commandThe data to transmit.

Implemented in BluetoothConnection, DeviCounterSimulatorIO, SerialPortConnection, and SocketConnection.

◆ waitForReadyRead()

virtual bool ConnectionBackend::waitForReadyRead ( const TimeSpan & span)
pure virtual

Blocks until data is available to read or the timeout expires.

Parameters
[in]spanMaximum time to wait.
Returns
True if data became available before the timeout.

Implemented in BluetoothConnection, DeviCounterSimulatorIO, SerialPortConnection, and SocketConnection.


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