SmartSoft Component-Developer API
|
Handles the event service on client side. More...
#include <smartIEventClientPattern_T.h>
Public Member Functions | |
IEventClientPattern (IComponent *component) | |
Constructor (not wired with a service provider). More... | |
IEventClientPattern (IComponent *component, const std::string &server, const std::string &service) | |
Connection Constructor (implicitly wiring with specified service provider). More... | |
virtual | ~IEventClientPattern () |
Destructor. More... | |
virtual StatusCode | activate (const EventMode &mode, const ActivationType ¶meter, EventIdPtr &id)=0 |
Activate an event with the provided parameters in either "single" or "continuous" mode. More... | |
virtual StatusCode | deactivate (const EventIdPtr id)=0 |
Deactivate the event with the specified identifier. More... | |
virtual StatusCode | tryEvent (const EventIdPtr id)=0 |
Check whether event has already fired and return immediately with status information. More... | |
virtual StatusCode | getEvent (const EventIdPtr id, EventType &event, const Duration &timeout=Duration::max())=0 |
Blocking call which waits for the event to fire and then consumes the event. More... | |
virtual StatusCode | getNextEvent (const EventIdPtr id, EventType &event, const Duration &timeout=Duration::max())=0 |
Blocking call which waits for the next event. More... | |
Public Member Functions inherited from Smart::IClientPattern | |
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... | |
Public Member Functions inherited from Smart::InputSubject< EventInputType< EventType > > | |
virtual | ~InputSubject ()=default |
Default destructor. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from Smart::IClientPattern | |
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 | |
ICommunicationPattern & | operator= (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< EventInputType< EventType > > | |
virtual void | attach (IInputHandler< EventInputType< EventType > > *handler, const unsigned int &prescaleFactor=1) |
Attach an IInputHandler<InputType> instance. More... | |
virtual void | detach (IInputHandler< EventInputType< EventType > > *handler) |
Detach an IInputHandler<InputType> instance. More... | |
virtual bool | notify_input (const EventInputType< EventType > &input) |
Notifies all attached IInputHandler instances about incoming data. More... | |
Protected Attributes inherited from Smart::IClientPattern | |
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 | |
IComponent * | icomponent |
the internal pointer to the component (can be accessed in derived classes) More... | |
Handles the event service on client side.
Template parameters:
Demonstrated in fifth example
|
inline |
Constructor (not wired with a service provider).
connect() / disconnect() can always be used to change the status of the connection.
component | the management class of the component |
|
inline |
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.
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) |
|
inlinevirtual |
Destructor.
The destructor calls disconnect().
|
pure virtual |
Activate an event with the provided parameters in either "single" or "continuous" mode.
mode | "single" or "continuous" mode |
parameter | activation parameter class (Communication Object) |
id | is set to the unique id of the event activation |
|
pure virtual |
Deactivate the event with the specified identifier.
An event must always be deactivated, even if it has already fired in single mode. This is just necessary for cleanup procedures and provides a uniform user API independently of the event mode. Calling deactivate() while there are blocking calls aborts them with the appropriate status code.
id | of event to be disabled |
(Hint: can not return SMART_DISCONNECTED since then each event is for sure also deactivated resulting in SMART_WRONGID)
|
pure virtual |
Blocking call which waits for the event to fire and then consumes the event.
This method consumes an event. Returns immediately if an unconsumed event is available. Blocks otherwise till event becomes available. If method is called concurrently from several threads with the same id and method is blocking, then every call returns with the same event once the event fired. If there is however already an unconsumed event available, then only one out of the concurrent calls consumes the event and the other calls return with appropriate status codes.
id | of the event activation |
event | is set to the returned event if fired (Communication Object) |
timeout | is the timeout time to block the method maximally (default value zero block infinitelly) |
Since an event in single mode fires only once, return immediately if the event is already consumed. Also return immediately with an available and unconsumed event and consume it. Otherwise wait until the event fires.
Returns status code:
Returns immediately if an unconsumed event is available. Returns the newest unconsumed event since activation. Otherwise waits until the event fires again.
Returns status code:
|
pure virtual |
Blocking call which waits for the next event.
This methods waits for the next arriving event to make sure that only events arriving after entering the method are considered. Method consumes event. An old event that has been fired is ignored (in contrary to getEvent()). If method is called concurrently from several threads with the same id, then every call returns with the same event once the event fired.
id | of the event activation |
event | is set to the returned event if fired (Communication Object) |
timeout | is the timeout time to block the method maximally (default value zero block infinitelly) |
In single mode one misses the event if it fired before entering this member function.
Returns status code:
Makes sure that only events fired after entering this member function are considered.
Returns status code:
|
pure virtual |
Check whether event has already fired and return immediately with status information.
This method does not consume an available event.
id | of the event activation to be checked |