The client part of Query pattern to perform two-way (request-response) communication.
More...
#include <smartIQueryClientPattern_T.h>
|
| IQueryClientPattern (IComponent *component) |
| Constructor (not wired with any service provider). More...
|
|
| IQueryClientPattern (IComponent *component, const std::string &server, const std::string &service) |
| Connection Constructor (implicitly wiring with specified service provider). More...
|
|
virtual | ~IQueryClientPattern () |
| Destructor. More...
|
|
virtual StatusCode | query (const RequestType &request, AnswerType &answer) |
| Blocking Query. More...
|
|
virtual StatusCode | queryRequest (const RequestType &request, QueryIdPtr &id)=0 |
| Asynchronous Query. More...
|
|
virtual StatusCode | queryReceive (const QueryIdPtr id, AnswerType &answer)=0 |
| Check if answer is available. More...
|
|
virtual StatusCode | queryReceiveWait (const QueryIdPtr id, AnswerType &answer, const Duration &timeout=Duration::max())=0 |
| Wait for reply. More...
|
|
virtual StatusCode | queryDiscard (const QueryIdPtr id)=0 |
| Discard the pending answer with the identifier id More...
|
|
| 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...
|
|
| ICommunicationPattern (IComponent *component) |
| Default Constructor initializing an IShutdownObserver. More...
|
|
virtual | ~ICommunicationPattern ()=default |
| Default Destructor. More...
|
|
| IShutdownObserver (ShutdownSubject *subject=nullptr) |
| The default constructor. More...
|
|
virtual | ~IShutdownObserver () |
| The default destructor. More...
|
|
template<class RequestType, class AnswerType>
class Smart::IQueryClientPattern< RequestType, AnswerType >
The client part of Query pattern to perform two-way (request-response) communication.
Template parameters
- RequestType: request class (Communication Object)
- AnswerType: answer (reply) class (Communication Object)
◆ IQueryClientPattern() [1/2]
template<class RequestType , class AnswerType >
Constructor (not wired with any service provider).
connect() / disconnect() can always be used to change the connection status of the instance. Instance is not connected to a service provider.
- Parameters
-
component | the management class of the component |
◆ IQueryClientPattern() [2/2]
template<class RequestType , class AnswerType >
Connection Constructor (implicitly wiring 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 status of the instance.
- Parameters
-
component | the management class of the component |
server | name of the server (i.e. the component-name to connect to) |
service | name of the service (i.e. the port-name of the component to connect to) |
◆ ~IQueryClientPattern()
template<class RequestType , class AnswerType >
Destructor.
The destructor calls disconnect() and therefore properly cleans up every pending query and removes the instance from the set of wireable ports.
◆ query()
template<class RequestType , class AnswerType >
Blocking Query.
Perform a blocking query and return only when the query answer is available. Member function is thread safe and thread reentrant.
- Parameters
-
request | send this request to the server (Communication Object) |
answer | returned answer from the server (Communication Object) |
- Returns
- status code:
- SMART_OK : everything is ok and answer contains answer
- SMART_CANCELLED : blocking is not allowed or is not allowed anymore and therefore pending query is aborted, answer is lost and answer contains no valid answer.
- SMART_DISCONNECTED : the client is either disconnected and no query can be made or it got disconnected and a pending query is aborted without answer. In both cases, answer is not valid.
- SMART_ERROR_COMMUNICATION : communication problems, answer is not valid.
- SMART_ERROR : something went wrong, answer is not valid.
◆ queryDiscard()
template<class RequestType , class AnswerType >
Discard the pending answer with the identifier id
Call this member function if you do not want to get the answer of a request anymore which was invoked by queryRequest(). This member function invalidates the identifier id.
- Warning
- This member function does NOT abort blocking calls ! This is done by the blocking() member function. It has to be called if you have not yet received an answer and the identifier is still valid, for example due to a CANCELLED return value, and you don't want to get the answer anymore.
-
It is not allowed to call queryReceive(), queryReceiveWait() or queryDiscard() concurrently with the same query id (which is not a restriction since it makes no sense !)
- Parameters
-
id | provides the identifier of the query |
- Returns
- status code:
- SMART_OK : everything is ok and query with the identifier id discarded.
- SMART_WRONGID : no pending query with this identifier.
- SMART_ERROR : something went wrong, id not valid any longer.
◆ queryReceive()
template<class RequestType , class AnswerType >
Check if answer is available.
Non-blocking call to fetch the answer belonging to the given identifier. Returns immediately. Member function is thread safe and reentrant.
- Warning
- It is not allowed to call queryReceive(), queryReceiveWait() or queryDiscard() concurrently with the same query id (which is not a restriction since it makes no sense !)
- Parameters
-
id | provides the identifier of the query |
answer | is set to the answer returned from the server if it was available |
- Returns
- status code:
- SMART_OK : everything is ok and answer contains the answer
- SMART_WRONGID : no pending query with this identifier available, therefore no valid answer returned.
- SMART_NODATA : answer not yet available, therefore try again later. The identifier id keeps valid, but answer contains no valid answer.
- SMART_DISCONNECTED : the answer belonging to the id can not be received anymore since the client got disconnected. id is not valid any longer and answer contains no valid answer.
- SMART_ERROR : something went wrong, answer contains no answer and id is not valid any longer.
◆ queryReceiveWait()
template<class RequestType , class AnswerType >
Wait for reply.
Blocking call to fetch the answer belonging to the given identifier. Waits until the answer is received.
- Warning
- It is not allowed to call queryReceive(), queryReceiveWait() or queryDiscard() concurrently with the same query id (which is not a restriction since it makes no sense !)
- Parameters
-
id | provides the identifier of the query |
answer | is set to the answer returned from the server if it was available |
timeout | is the timeout time to block the method maximally (default value max blocks infinitely) |
- Returns
- status code:
- SMART_OK : everything is ok and answer contains the answer
- SMART_WRONGID : no pending query with this identifier available, therefore no valid answer returned.
- SMART_CANCELLED : blocking call is not allowed or is not allowed anymore and therefore blocking call is aborted and no valid answer is returned. The query identifier id keeps valid and one can either again call queryReceive(), queryReceiveWait() or discard the answer by calling queryDiscard().
- SMART_DISCONNECTED : blocking call is aborted and the answer belonging to id can not be received anymore since client got disconnected. id is not valid any longer and answer contains no valid answer.
- SMART_ERROR : something went wrong, answer contains no answer and id is not valid any longer.
◆ queryRequest()
template<class RequestType , class AnswerType >
Asynchronous Query.
Perform a query and receive the answer later, returns immediately. Member function is thread safe and reentrant.
- Parameters
-
request | send this request to the server (Communication Object) |
id | is set to the identifier which is later used to receive the reply to this request |
- Returns
- status code:
- SMART_OK : everything is ok and id contains query identifier used to either fetch or discard the answer.
- SMART_DISCONNECTED : request is rejected since client is not connected to a server and therefore id is not a valid identifier.
- SMART_ERROR_COMMUNICATION : communication problems, id is not valid.
- SMART_ERROR : something went wrong, id is not valid.
The documentation for this class was generated from the following file:
- smartIQueryClientPattern_T.h