SmartSoft Component-Developer API
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Smart::IClientPattern Class Referenceabstract

This is the base class for all client-patterns implementing a connection-oriented communication. More...

#include <smartIClientPattern.h>

Inheritance diagram for Smart::IClientPattern:
Smart::ICommunicationPattern Smart::IShutdownObserver Smart::IEventClientPattern< ActivationType, EventType > Smart::IPushClientPattern< DataType > Smart::IQueryClientPattern< RequestType, AnswerType > Smart::ISendClientPattern< DataType >

Public Member Functions

 IClientPattern (IComponent *component)
 Default Constructor (not yet connecting with any service provider). More...
 
 IClientPattern (IComponent *component, const std::string &server, const std::string &service)
 Connection Constructor (implicitly connecting with specified service provider). More...
 
virtual ~IClientPattern ()=default
 Default destructor. More...
 
virtual StatusCode connect (const std::string &server, const std::string &service)=0
 Connect this service requestor to the denoted service provider. More...
 
virtual StatusCode disconnect ()=0
 Disconnect the service requestor from the service provider. More...
 
virtual StatusCode blocking (const bool blocking)=0
 Allow or abort and reject blocking calls. More...
 
- Public Member Functions inherited from Smart::ICommunicationPattern
 ICommunicationPattern (IComponent *component)
 Default Constructor initializing an IShutdownObserver. More...
 
virtual ~ICommunicationPattern ()=default
 Default Destructor. More...
 
- Public Member Functions inherited from Smart::IShutdownObserver
 IShutdownObserver (ShutdownSubject *subject=nullptr)
 The default constructor. More...
 
virtual ~IShutdownObserver ()
 The default destructor. More...
 

Protected Member Functions

bool is_shutting_down () const
 
virtual void on_shutdown () override
 implements individual shutdown strategy The default behavior for each client during component shutdown is to call disconnect() which automatically disconnects the current client instance. More...
 
 IClientPattern ()=delete
 
- Protected Member Functions inherited from Smart::ICommunicationPattern
 ICommunicationPattern (const ICommunicationPattern &)=delete
 
ICommunicationPatternoperator= (const ICommunicationPattern &)=delete
 
 ICommunicationPattern ()=delete
 
- Protected Member Functions inherited from Smart::IShutdownObserver
void attach_self_to (ShutdownSubject *subject)
 call this method from within the constructor of derived classes More...
 
void detach_self_from (ShutdownSubject *subject)
 this method is called within the destructor More...
 

Protected Attributes

std::string connectionServerName
 the server-name used for the last connection (can be used in derived classes) More...
 
std::string connectionServiceName
 the service-name used for the last connection (can be used in derived classes) More...
 
std::atomic< bool > is_blocking
 the flag indicating the current blocking state of this client (can be used in derived classes) More...
 
- Protected Attributes inherited from Smart::ICommunicationPattern
IComponenticomponent
 the internal pointer to the component (can be accessed in derived classes) More...
 

Detailed Description

This is the base class for all client-patterns implementing a connection-oriented communication.

Each ClientPattern needs to implement the connection-oriented user API (i.e. the methods connect() / disconnect() ). In addition all clients need to implement the method blocking() that allows to globally manage all blocking user API calls. This provides a thread-save implementation of blocking-call management.

Constructor & Destructor Documentation

◆ IClientPattern() [1/3]

Smart::IClientPattern::IClientPattern ( )
protecteddelete

◆ IClientPattern() [2/3]

Smart::IClientPattern::IClientPattern ( IComponent component)
inline

Default Constructor (not yet connecting with any service provider).

connect() / disconnect() can always be used to change the connection status of the instance.

Parameters
componentthe management class of the component

◆ IClientPattern() [3/3]

Smart::IClientPattern::IClientPattern ( IComponent component,
const std::string &  server,
const std::string &  service 
)
inline

Connection Constructor (implicitly connecting with specified service provider).

Connects to the denoted service and blocks until the connection has been established. Blocks infinitely if denoted service becomes unavailable since constructor performs retries. Blocking is useful to simplify startup of components which have mutual dependencies. connect() / disconnect() can always be used to change the connection-status of the instance.

Parameters
componentthe management class of the component
servername of the server (i.e. the component-name to connect to)
servicename of the service (i.e. the port-name of the component to connect to)

◆ ~IClientPattern()

virtual Smart::IClientPattern::~IClientPattern ( )
virtualdefault

Default destructor.

Member Function Documentation

◆ blocking()

virtual StatusCode Smart::IClientPattern::blocking ( const bool  blocking)
pure virtual

Allow or abort and reject blocking calls.

If blocking is set to false all blocking calls return with SMART_CANCELLED. This can be used to abort blocking calls.

Parameters
blockingtrue/false
Returns
status code
  • SMART_OK : new mode set
  • SMART_ERROR : something went wrong

◆ connect()

virtual StatusCode Smart::IClientPattern::connect ( const std::string &  server,
const std::string &  service 
)
pure virtual

Connect this service requestor to the denoted service provider.

An already established connection is first disconnected. See disconnect()

It is no problem to change the connection to a service provider at any point in time irrespective of any other calls.

Parameters
servername of the server (i.e. the component-name to connect to)
servicename of the service (i.e. the port-name of the component to connect to)
Returns
status code
  • SMART_OK : everything is OK and connected to the specified service.
  • SMART_SERVICEUNAVAILABLE : the specified service is currently not available and the requested connection can not be established. Service requestor is now not connected to any service provider.
  • SMART_INCOMPATIBLESERVICE : the specified service provider is not compatible (wrong communication pattern or wrong communication objects) to this service requestor and can therefore not be connected. Service requestor is now not connected to any service provider.
  • SMART_ERROR_COMMUNICATION : communication problems, service requestor is now not connected to any service provider.
  • SMART_ERROR : something went wrong, service requestor is now not connected to any service provider.

◆ disconnect()

virtual StatusCode Smart::IClientPattern::disconnect ( )
pure virtual

Disconnect the service requestor from the service provider.

It is no problem to change the connection to a service provider at any point in time irrespective of any other calls.

Returns
status code
  • SMART_OK : everything is OK and service requestor is disconnected from the service provider.
  • SMART_ERROR_COMMUNICATION : something went wrong at the level of the intercomponent communication. At least the service requestor is in the disconnected state irrespective of the service provider side clean up procedures.
  • SMART_ERROR : something went wrong. Again at least the service requestor is in the disconnected state.

◆ is_shutting_down()

bool Smart::IClientPattern::is_shutting_down ( ) const
inlineprotected

◆ on_shutdown()

virtual void Smart::IClientPattern::on_shutdown ( )
inlineoverrideprotectedvirtual

implements individual shutdown strategy The default behavior for each client during component shutdown is to call disconnect() which automatically disconnects the current client instance.

Implements Smart::IShutdownObserver.

Member Data Documentation

◆ connectionServerName

std::string Smart::IClientPattern::connectionServerName
protected

the server-name used for the last connection (can be used in derived classes)

◆ connectionServiceName

std::string Smart::IClientPattern::connectionServiceName
protected

the service-name used for the last connection (can be used in derived classes)

◆ is_blocking

std::atomic<bool> Smart::IClientPattern::is_blocking
protected

the flag indicating the current blocking state of this client (can be used in derived classes)


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