Kanzi Connect  1.1.10
Kanzi Connect C++ API
kanzi::connect::ClientConnectionAdapter Class Referenceabstract

An abstract class that acts as an interface to underlying network transport layer. More...

#include <connection_adapter_client.hpp>

Inheritance diagram for kanzi::connect::ClientConnectionAdapter:
kanzi::connect::ClientSocketConnectionAdapter

Classes

class  Observer
 Observer class that allows to receive notifications from the connection adapter. More...
 

Public Types

typedef map< string, string > Parameters
 Container type for parameters. More...
 

Public Member Functions

void addObserver (Observer *observer)
 Adds observer to receive notification from this adapter. More...
 
 ClientConnectionAdapter ()
 Constructor. More...
 
virtual bool configure (const Parameters &parameters)
 Allows to configure the adapter with adapter-specific settings (key-value pairs). More...
 
virtual bool connect ()=0
 Connects adapter to server. More...
 
virtual void disconnect ()=0
 Disconnects adapter from server. More...
 
virtual string getParameter (const string &parameter)
 Adapter can expose it's parameters using key-value pairs. More...
 
virtual string getState (const string &parameter)=0
 Adapter can expose it's internal state by using key-value pairs. More...
 
virtual string getType () const =0
 Returns type of the adapter, this needs to be unique for every adapter. More...
 
virtual void interrupt ()=0
 Signals to stop waiting for events. More...
 
void removeObserver (Observer *observer)
 Removes observer from this adapter. More...
 
virtual void send (const vector< char > &data)=0
 Sends data to network. More...
 
virtual int wait ()=0
 Starts waiting event(s) from network, can block to preserve CPU. More...
 
virtual void work (int status)=0
 Once wait is completed, this method is called for the adapter to process the received network events. More...
 
virtual ~ClientConnectionAdapter ()
 Destructor. More...
 

Protected Member Functions

void notifyConnected ()
 Allows derived class to invoke connection notification to all observers. More...
 
void notifyDisconnected ()
 Allows derived class to invoke disconnect notification to all observers. More...
 
void notifyReceive (const vector< char > &data)
 Allows derived class to invoke data received notification to all observers. More...
 

Static Protected Member Functions

static string getConfigurationParameterString (const Parameters &parameters, const string &parameter)
 Get single single string type configuration parameter. Returns empty string for missing parameter. More...
 

Detailed Description

An abstract class that acts as an interface to underlying network transport layer.

This class interface provides functionality to connect to server and transmit & receive data.

Member Typedef Documentation

◆ Parameters

Container type for parameters.

Constructor & Destructor Documentation

◆ ClientConnectionAdapter()

kanzi::connect::ClientConnectionAdapter::ClientConnectionAdapter ( )
inline

Constructor.

◆ ~ClientConnectionAdapter()

virtual kanzi::connect::ClientConnectionAdapter::~ClientConnectionAdapter ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ addObserver()

void kanzi::connect::ClientConnectionAdapter::addObserver ( Observer observer)

Adds observer to receive notification from this adapter.

Parameters
observerObserver to add.

◆ configure()

virtual bool kanzi::connect::ClientConnectionAdapter::configure ( const Parameters parameters)
inlinevirtual

Allows to configure the adapter with adapter-specific settings (key-value pairs).

Parameters
parametersConfiguration parameters, as string-based key value pairs.
Returns
True if the adapter was successfully configured, otherwise false.

Reimplemented in kanzi::connect::ClientSocketConnectionAdapter.

◆ connect()

virtual bool kanzi::connect::ClientConnectionAdapter::connect ( )
pure virtual

Connects adapter to server.

Returns
True if connection attempt is successful.

Implemented in kanzi::connect::ClientSocketConnectionAdapter.

◆ disconnect()

virtual void kanzi::connect::ClientConnectionAdapter::disconnect ( )
pure virtual

Disconnects adapter from server.

Implemented in kanzi::connect::ClientSocketConnectionAdapter.

◆ getConfigurationParameterString()

static string kanzi::connect::ClientConnectionAdapter::getConfigurationParameterString ( const Parameters parameters,
const string &  parameter 
)
staticprotected

Get single single string type configuration parameter. Returns empty string for missing parameter.

◆ getParameter()

virtual string kanzi::connect::ClientConnectionAdapter::getParameter ( const string &  parameter)
virtual

Adapter can expose it's parameters using key-value pairs.

This function allows to retrieve a parameter value that was used to configure the adapter.

Parameters
parameterKey argument for parameter query.
Returns
Value for a given key that represents configuration parameter.

◆ getState()

virtual string kanzi::connect::ClientConnectionAdapter::getState ( const string &  parameter)
pure virtual

Adapter can expose it's internal state by using key-value pairs.

This function allows to retrieve a state value from adapter for a given key.

Parameters
parameterKey argument for state query.
Returns
Value for a given key that represents a state of the given parameter.

Implemented in kanzi::connect::ClientSocketConnectionAdapter.

◆ getType()

virtual string kanzi::connect::ClientConnectionAdapter::getType ( ) const
pure virtual

Returns type of the adapter, this needs to be unique for every adapter.

Returns
Adapter type as string.

◆ interrupt()

virtual void kanzi::connect::ClientConnectionAdapter::interrupt ( )
pure virtual

Signals to stop waiting for events.

Implemented in kanzi::connect::ClientSocketConnectionAdapter.

◆ notifyConnected()

void kanzi::connect::ClientConnectionAdapter::notifyConnected ( )
protected

Allows derived class to invoke connection notification to all observers.

◆ notifyDisconnected()

void kanzi::connect::ClientConnectionAdapter::notifyDisconnected ( )
protected

Allows derived class to invoke disconnect notification to all observers.

◆ notifyReceive()

void kanzi::connect::ClientConnectionAdapter::notifyReceive ( const vector< char > &  data)
protected

Allows derived class to invoke data received notification to all observers.

◆ removeObserver()

void kanzi::connect::ClientConnectionAdapter::removeObserver ( Observer observer)

Removes observer from this adapter.

Parameters
observerObserver to remove.

◆ send()

virtual void kanzi::connect::ClientConnectionAdapter::send ( const vector< char > &  data)
pure virtual

Sends data to network.

Parameters
dataData to send.

◆ wait()

virtual int kanzi::connect::ClientConnectionAdapter::wait ( )
pure virtual

Starts waiting event(s) from network, can block to preserve CPU.

Returns
Must return <0 in case unrecoverable error occured and method should not be called anymore. >= 0 in case processing should continue. In this case returned value is passed to work(..) routine.

Implemented in kanzi::connect::ClientSocketConnectionAdapter.

◆ work()

virtual void kanzi::connect::ClientConnectionAdapter::work ( int  status)
pure virtual

Once wait is completed, this method is called for the adapter to process the received network events.

Parameters
statusthe status (>=0) value returned by the wait() routine called earlier.

Implemented in kanzi::connect::ClientSocketConnectionAdapter.


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