Client part of the Push pattern to provide a flexible publish/subscribe service.
More...
#include <smartIPushClientPattern_T.h>
template<class DataType>
class Smart::IPushClientPattern< DataType >
Client part of the Push pattern to provide a flexible publish/subscribe service.
Clients can subscribe to regularly get every n-th update. This class inherits the API from IClientPattern.
Template parameters
- DataType: Pushed value class (Communication Object)
◆ IPushClientPattern() [1/2]
template<class DataType >
Constructor (not wired with service provider and not exposed as port).
connect() / disconnect() can always be used to change the status of the instance. Instance is not connected to a service provider and is not exposed as port wireable from outside the component.
- Parameters
-
component | the management class of the component |
◆ IPushClientPattern() [2/2]
template<class DataType >
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) |
◆ ~IPushClientPattern()
template<class DataType >
Destructor.
The destructor calls disconnect() and therefore properly cleans up every pending data reception and removes the instance from the set of wireable ports.
◆ getUpdate()
template<class DataType >
Non-blocking call to immediately return the latest available data buffered at the client side from the most recent update.
No data is returned as long as no update is received since subscription. To avoid returning old data, no data is returned after the client is unsubscribed or when the server is not active.
- Parameters
-
d | is set to the newest currently available data |
- Returns
- status code
- SMART_OK : everything ok and latest data since client got subscribed is returned.
- SMART_NODATA : client has not yet received an update since subscription and therefore no data is available and no data is returned.
- SMART_NOTACTIVATED : the server is currently not active and does therefore not provide updates at the expected rate. No valid data returned.
- SMART_UNSUBSCRIBED : no data available since client is not subscribed and can therefore not receive updates. Method does not return old data from last subscription since these might be based on too old parameter settings. To get data one has to be subscribed.
- SMART_DISCONNECTED : no data returned since client is even not connected to a server.
- SMART_ERROR : something went wrong
◆ getUpdateWait()
template<class DataType >
Blocking call which waits until the next update is received.
Blocking is aborted with the appropriate status if either the server gets deactivated, the client gets unsubscribed or disconnected or if blocking is not allowed any more at the client.
- Parameters
-
d | is set to the newest currently available data |
timeout | is the timeout time to block the method maximally (default value max blocks infinitely) |
- Returns
- status code
- SMART_OK : everything is ok and just received data is returned.
- SMART_CANCELLED : blocking is not allowed or is not allowed anymore. Waiting for the next update is aborted and no valid data is returned.
- SMART_NOTACTIVATED : the server is currently not active and does therefore not provide updates at the expected rate. No valid data returned.
- SMART_UNSUBSCRIBED : returns immediately without data if the client is not subscribed.
- SMART_DISCONNECTED : returns immediately without data since client is even not connected to a server.
- SMART_ERROR : something went completely wrong and no valid data returned.
◆ subscribe()
template<class DataType >
Subscribe at the server to periodically get every n-th update.
A newly subscribed client gets the next available new data and is then updated with regard to its individual prescale-factor. If the prescale factor is omitted then every update will be received.
- Parameters
-
prescale | whole-numbered value to set the update rate to every n-th value (must be greater than 0) |
- Returns
- status code
- SMART_OK : everything is ok and client is subscribed
- SMART_DISCONNECTED : client is not connected to a server and can therefore not subscribe for updates, not subscribed
- SMART_ERROR_COMMUNICATION : communication problems, not subscribed
- SMART_ERROR : something went wrong, not subscribed
◆ unsubscribe()
template<class DataType >
Unsubscribe to get no more updates.
All blocking calls are aborted with the appropriate status and yet received and still buffered data is deleted to avoid returning old data.
- Returns
- status code
- SMART_OK : everything is ok and client is now unsubscribed or has already been unsubscribed
- SMART_ERROR_COMMUNICATION : communication problems, not unsubscribed
- SMART_ERROR : something went wrong, not unsubscribed
(can not return SMART_DISCONNECTED since then client is for sure also unsubscribed which results in SMART_OK)
The documentation for this class was generated from the following file:
- smartIPushClientPattern_T.h