nebula::comm::EventElement
EventElement represents a named event. It uses nebula::comm::proxy::DataProvider interface as backend and internally takes care of mapping event names to concrete events provided by the proxy backend. Applications can perform operations such as subscribe, fetching event data etc using this implementation
Example usage:
// Implementation of DataProvider providing event "event"
// Normally application developer dont have to define this class, rather it will be
// generated along with the service proxy code from interface definitions.
// So this definition is only for illustartion purpose.
class EventDataProvider : public DataProvider / *, other inheriting classes * / {
// Implementation
};
// Task definition
Class DataTask : public Task {
// The `run` method will have the implementation for event processing.
// This method will be only called when there are events to process
bool run() {
// Implementation
}
// Other task method implementations
};
// Define a EventElement for the named event "event" using backend `EventDataProvider`
EventElement<EventDataProvider> eventElement{"event"};
// Declaration of task instance which will be triggered for event processing
DataTask dataTask;
// Declare a `DataTriggeredTask`
DataTriggeredTask handler(dataTask, eventElement);
- Parameters
Interface
DataProvider implementation class providing this event.
class nebula::comm::EventElement
class nebula::comm::EventElement
: public nebula::comm::EventElementBase
Helper class for defining individual event elements.
Members
public inline
EventElement
(std::string name, std::string instance)
Construct a new Event Element object.
- Parameters
name
name of the event, it must be a name recognized by the backend DataProvider implementation used.
public inline virtual std::string &
getElementName
()
See also: EventElementBase::getElementName()
public inline virtual void
subscribe
(std::function< void(const std::string &)> notifier)
See also: EventElementBase::subscribe()
public template<>
inline std::vector< EventType >
getEventData
()
Get the cached Event Data.
-
Parameters
EventType
Type of the event data
-
Returns
std::vector<EventType>
container of unprocessed event data.