NAP
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
UDPAdapter Class Referenceabstract

#include <udpadapter.h>

Public Member Functions

 UDPAdapter ()
 
virtual ~UDPAdapter ()
 
virtual bool init (utility::ErrorState &errorState) override final
 
virtual void onDestroy () override final
 
virtual bool start (utility::ErrorState &errorState) override final
 
virtual void stop () override final
 
- Public Member Functions inherited from Resource
 Resource ()
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Public Attributes

ResourcePtr< UDPThreadmThread
 Property: 'Thread' the udp thread the adapter registers itself to. More...
 
bool mAllowFailure = false
 Property: 'AllowFailure' if binding to socket is allowed to fail on initialization. More...
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Protected Member Functions

virtual bool onStart (utility::ErrorState &errorState)=0
 
virtual void onStop ()=0
 
virtual void onProcess ()=0
 
void process ()
 
bool handleAsioError (const std::error_code &errorCode, utility::ErrorState &errorState, bool &success)
 
asio::io_context & getIOContext ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 

Description

Base class of specific UDP client and server resources. process() is automatically called by the thread this adapter links to. Both UDPClient & UDPServer extend UDPAdapter.

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

Constructor & Destructor Documentation

◆ UDPAdapter()

Constructor

◆ ~UDPAdapter()

virtual ~UDPAdapter ( )
virtual

Destructor

Member Function Documentation

◆ getIOContext()

asio::io_context& getIOContext ( )
protected

◆ handleAsioError()

bool handleAsioError ( const std::error_code &  errorCode,
utility::ErrorState errorState,
bool &  success 
)
protected

◆ init()

virtual bool init ( utility::ErrorState errorState)
finaloverridevirtual

Initialization

Parameters
errorStatecontains error information
Returns
true on success

Reimplemented from Object.

◆ onDestroy()

virtual void onDestroy ( )
finaloverridevirtual

called on destruction

Reimplemented from Object.

◆ onProcess()

virtual void onProcess ( )
protectedpure virtual

called by a UDPThread

Implemented in UDPServer, and UDPClient.

◆ onStart()

virtual bool onStart ( utility::ErrorState errorState)
protectedpure virtual

Called by start method and needs to be implemented by derived class

Parameters
errorStateThe error state
Returns
: true on success

Implemented in UDPServer, and UDPClient.

◆ onStop()

virtual void onStop ( )
protectedpure virtual

Called by stop method and needs to be implemented by derived class

Implemented in UDPServer, and UDPClient.

◆ process()

void process ( )
protected

◆ start()

virtual bool start ( utility::ErrorState errorState)
finaloverridevirtual

Start the adapter. Called after initialization. When called it is safe to assume that all dependencies have been resolved up to this point. Internally calls virtual method 'onStart' that is implemented in derived class Upon successfull start, registers adapter to UDP thread

Parameters
errorStateThe error state
Returns
: true on success

Reimplemented from Device.

◆ stop()

virtual void stop ( )
finaloverridevirtual

Called when the adapter needs to be stopped, but only if start has previously been called on this Device. It is safe to assume that when stop is called the device is in a 'started' state. Called in reverse init order. Removed adapter from UDP thread

Reimplemented from Device.

Member Data Documentation

◆ mAllowFailure

bool mAllowFailure = false

Property: 'AllowFailure' if binding to socket is allowed to fail on initialization.

◆ mThread

Property: 'Thread' the udp thread the adapter registers itself to.