BAOS SDK v2  1.2.1
An SDK providing access to IP-BAOS devices through BAOS binary protocol version 2.x
Loading...
Searching...
No Matches
TransportIO Class Referenceabstract

Base class for a Transport input output connection. More...

#include <baos/transport/TransportIO.h>

+ Inheritance diagram for TransportIO:

Classes

struct  BaosPromise
 

Public Types

enum class  PromiseState {
  UNUSED ,
  SET ,
  RESOLVED
}
 
using Clock = std::chrono::system_clock
 An alias for the clock internaly used.
 
using UPtr = std::unique_ptr< TransportIO >
 Alias for a std::unique_ptr to this class.
 
using UniqueLock = std::unique_lock< std::mutex >
 Alias for unique lock used by this class.
 

Public Member Functions

 TransportIO (BaosMsgQueue &msgQueue, wzcpp::ExecutorBase &executor, wzcpp::TimerManager< Clock > &timerManager)
 Construct a new TransportIO object with a given message queue and executor.
 
 TransportIO (const TransportIO &)=delete
 
TransportIO & operator= (const TransportIO &)=delete
 
 TransportIO (TransportIO &&)=delete
 
TransportIO & operator= (TransportIO &&)=delete
 
template<typename LayerType >
void addLayer (std::uint32_t layerId)
 
ProtocolLayer & getLayer (unsigned int layerId)
 
void start ()
 
virtual void stop ()=0
 
virtual void send (const Buffer &frame)=0
 Send a baos frame.
 
virtual void close ()=0
 Close the Transport connection.
 
virtual void waitForFinished ()=0
 Wait till the worker of this class has finished.
 
virtual bool isOpen ()
 Get the open state of the Transport connection.
 
bool isIdle () const
 Get the idle state of the Transport connection.
 
void onTimersElapsed (wzcpp::TimerManager< Clock >::TimerIdList &timerIds)
 

Protected Member Functions

virtual void eventHandler ()=0
 Handles the incoming IOEvents.
 
virtual void sendToIo (const Buffer &frame)=0
 

Protected Attributes

std::unique_ptr< ProtocolStack > transportStack_
 The transport stack to use for actual sending and receiving.
 
std::atomic< bool > shouldStop_ {false}
 Flag to indicate that the receiver worker should stop.
 
std::condition_variable cvFinished_
 Condition variable which is set when the receiver worker has stopped.
 
std::mutex cvFinished_mut_
 The correponding mutex for the cvFinished_ condition variable.
 
bool stopped_ {false}
 
std::atomic< bool > isOpen_ {false}
 Flag to show if the Transport connection is open or not.
 
TransportMsgQueue msgQueue_
 Reference to the message queue in which events will be posted by this class.
 
BaosMsgQueue & bMsgQ_
 Reference to the message queue in which baos events will be posted by this class.
 
wzcpp::ExecutorBase & executor_
 Reference to the executor to use for running the receive(RX) worker.
 
wzcpp::TimerManager< Clock > & timerManager_
 Reference to the timer manager used by this transport IO.
 
wzcpp::TimerManager< Clock >::AllTimersCallbackId timerCallbackId_ {0}
 The id of the callback registered in the timer manager to handle timer events for this transport io.
 
BaosPromise connectionPromise_
 A promise to be resolved when the connection is established, or disconnected.
 

Static Protected Attributes

static std::atomic< std::uint64_t > msgId
 Used to generate a continuous unique message id.
 

Detailed Description

Base class for a Transport input output connection.

This establishes a Transport connection to the BAOS devices. It sends and receives raw bytes.

Constructor & Destructor Documentation

◆ TransportIO() [1/3]

TransportIO ( BaosMsgQueue &  msgQueue,
wzcpp::ExecutorBase &  executor,
wzcpp::TimerManager< Clock > &  timerManager 
)

Construct a new TransportIO object with a given message queue and executor.

Parameters
msgQueueAn external message queue to post events into
executorAn external executor to run this class worker in
timerManagerAn external timer manager to manage timers for this transport io

◆ TransportIO() [2/3]

TransportIO ( const TransportIO &  )
delete

Copy constructor is not supported

◆ TransportIO() [3/3]

TransportIO ( TransportIO &&  )
delete

Move constructor is not supported

Member Function Documentation

◆ operator=() [1/2]

TransportIO & operator= ( const TransportIO &  )
delete

Copy assignment operator is not supported

◆ operator=() [2/2]

TransportIO & operator= ( TransportIO &&  )
delete

Move assignment operator is not supported

◆ start()

void start ( )

Starts the protocol stack

◆ stop()

virtual void stop ( )
pure virtual

Stops the protocol stack

Implemented in TransportTcpIO.

◆ send()

virtual void send ( const Buffer &  frame)
pure virtual

Send a baos frame.

Parameters
frameThe baos frame to send

Implemented in TransportTcpIO.

◆ close()

virtual void close ( )
pure virtual

Close the Transport connection.

Implemented in TransportTcpIO.

◆ waitForFinished()

virtual void waitForFinished ( )
pure virtual

Wait till the worker of this class has finished.

Implemented in TransportTcpIO.

◆ isOpen()

virtual bool isOpen ( )
virtual

Get the open state of the Transport connection.

Returns
true if the Transport connection is established false otherwise

Reimplemented in TransportTcpIO.

◆ isIdle()

bool isIdle ( ) const

Get the idle state of the Transport connection.

Returns
true if the Transport connection is idle false otherwise

Member Data Documentation

◆ stopped_

bool stopped_ {false}
protected

Flag to show the actual state of the receive worker. Because condition variables may suffer from spurious wakeups.


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