SmartSoft Component-Developer API
Public Types | Public Member Functions | Protected Member Functions | List of all members
Smart::IQueryServerPattern< RequestType, AnswerType > Class Template Referenceabstract

The server part of the Query pattern to perform two-way (request-response) communication. More...

#include <smartIQueryServerPattern_T.h>

Inheritance diagram for Smart::IQueryServerPattern< RequestType, AnswerType >:
Smart::IServerPattern Smart::InputSubject< std::pair< QueryIdPtr, RequestType > > Smart::ICommunicationPattern Smart::IShutdownObserver

Public Types

using IQueryServerHandlerPtr = std::shared_ptr< Smart::IQueryServerHandler< RequestType, AnswerType > >
 

Public Member Functions

 IQueryServerPattern (IComponent *component, const std::string &service, IQueryServerHandlerPtr query_handler=nullptr)
 Default constructor. More...
 
virtual ~IQueryServerPattern ()=default
 Destructor. More...
 
virtual StatusCode answer (const QueryIdPtr id, const AnswerType &answer)=0
 Provide answer to be sent back to the requestor. More...
 
- Public Member Functions inherited from Smart::IServerPattern
 IServerPattern (IComponent *component, const std::string &serviceName)
 Constructor. More...
 
virtual ~IServerPattern ()
 Destructor. 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...
 
- Public Member Functions inherited from Smart::InputSubject< std::pair< QueryIdPtr, RequestType > >
virtual ~InputSubject ()=default
 Default destructor. More...
 

Protected Member Functions

void handleQuery (const QueryIdPtr id, const RequestType &request)
 please call this method in derived classes from within the middleware-specific data handler More...
 
- Protected Member Functions inherited from Smart::IServerPattern
bool is_shutting_down () const
 
virtual void on_shutdown ()
 implements individual shutdown strategy. More...
 
virtual void serverInitiatedDisconnect ()=0
 implements server-initiated-disconnect (SID) More...
 
- 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 Member Functions inherited from Smart::InputSubject< std::pair< QueryIdPtr, RequestType > >
virtual void attach (IInputHandler< std::pair< QueryIdPtr, RequestType > > *handler, const unsigned int &prescaleFactor=1)
 Attach an IInputHandler<InputType> instance. More...
 
virtual void detach (IInputHandler< std::pair< QueryIdPtr, RequestType > > *handler)
 Detach an IInputHandler<InputType> instance. More...
 
virtual bool notify_input (const std::pair< QueryIdPtr, RequestType > &input)
 Notifies all attached IInputHandler instances about incoming data. More...
 

Additional Inherited Members

- Protected Attributes inherited from Smart::IServerPattern
std::string serviceName
 the current serviceName (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

template<class RequestType, class AnswerType>
class Smart::IQueryServerPattern< RequestType, AnswerType >

The server part of the Query pattern to perform two-way (request-response) communication.

Template parameters

Member Typedef Documentation

◆ IQueryServerHandlerPtr

template<class RequestType , class AnswerType >
using Smart::IQueryServerPattern< RequestType, AnswerType >::IQueryServerHandlerPtr = std::shared_ptr<Smart::IQueryServerHandler<RequestType,AnswerType> >

Constructor & Destructor Documentation

◆ IQueryServerPattern()

template<class RequestType , class AnswerType >
Smart::IQueryServerPattern< RequestType, AnswerType >::IQueryServerPattern ( IComponent component,
const std::string &  service,
IQueryServerHandlerPtr  query_handler = nullptr 
)
inline

Default constructor.

Note that a handler has to be supplied. Without a handler, the QueryServer could not accept a query.

Parameters
componentmanagement class of the component
servicename of the service
query_handleran optional query_handler

◆ ~IQueryServerPattern()

template<class RequestType , class AnswerType >
virtual Smart::IQueryServerPattern< RequestType, AnswerType >::~IQueryServerPattern ( )
virtualdefault

Destructor.

Properly disconnects all service requestors in case of destruction such that all pending queries are handled correctly at client side even when the service provider disappears during pending queries.

Member Function Documentation

◆ answer()

template<class RequestType , class AnswerType >
virtual StatusCode Smart::IQueryServerPattern< RequestType, AnswerType >::answer ( const QueryIdPtr  id,
const AnswerType &  answer 
)
pure virtual

Provide answer to be sent back to the requestor.

Member function is thread safe and thread reentrant.

Parameters
ididentifies the request to which the answer belongs
answeris the reply itself.
Returns
status code:
  • SMART_OK : everything is ok and answer sent to requesting client
  • SMART_WRONGID : no pending query with that id known
  • SMART_DISCONNECTED : answer not needed anymore since client got disconnected meanwhile
  • SMART_ERROR_COMMUNICATION : communication problems
  • SMART_ERROR : something went wrong

◆ handleQuery()

template<class RequestType , class AnswerType >
void Smart::IQueryServerPattern< RequestType, AnswerType >::handleQuery ( const QueryIdPtr  id,
const RequestType &  request 
)
inlineprotected

please call this method in derived classes from within the middleware-specific data handler


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