2020-08-28 17:44:10 +02:00
|
|
|
#ifndef EVENTMANAGERIF_H_
|
|
|
|
#define EVENTMANAGERIF_H_
|
|
|
|
|
|
|
|
#include "EventMessage.h"
|
2020-09-05 15:58:53 +02:00
|
|
|
#include "eventmatching/eventmatching.h"
|
2020-08-28 17:44:10 +02:00
|
|
|
#include "../objectmanager/ObjectManagerIF.h"
|
|
|
|
#include "../ipc/MessageQueueSenderIF.h"
|
2020-09-05 15:58:53 +02:00
|
|
|
#include "../ipc/MessageQueueIF.h"
|
2020-08-28 17:44:10 +02:00
|
|
|
|
|
|
|
class EventManagerIF {
|
|
|
|
public:
|
|
|
|
|
|
|
|
static const uint8_t INTERFACE_ID = CLASS_ID::EVENT_MANAGER_IF;
|
|
|
|
static const ReturnValue_t LISTENER_NOT_FOUND = MAKE_RETURN_CODE(1);
|
|
|
|
virtual ~EventManagerIF() {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual MessageQueueId_t getEventReportQueue() = 0;
|
|
|
|
|
2020-09-05 15:58:53 +02:00
|
|
|
virtual ReturnValue_t registerListener(MessageQueueId_t listener,
|
|
|
|
bool forwardAllButSelected = false) = 0;
|
2020-08-28 17:44:10 +02:00
|
|
|
virtual ReturnValue_t subscribeToEvent(MessageQueueId_t listener,
|
|
|
|
EventId_t event) = 0;
|
|
|
|
virtual ReturnValue_t subscribeToAllEventsFrom(MessageQueueId_t listener,
|
|
|
|
object_id_t object) = 0;
|
|
|
|
virtual ReturnValue_t subscribeToEventRange(MessageQueueId_t listener,
|
|
|
|
EventId_t idFrom = 0, EventId_t idTo = 0, bool idInverted = false,
|
|
|
|
object_id_t reporterFrom = 0, object_id_t reporterTo = 0,
|
|
|
|
bool reporterInverted = false) = 0;
|
|
|
|
virtual ReturnValue_t unsubscribeFromEventRange(MessageQueueId_t listener,
|
|
|
|
EventId_t idFrom = 0, EventId_t idTo = 0, bool idInverted = false,
|
|
|
|
object_id_t reporterFrom = 0, object_id_t reporterTo = 0,
|
|
|
|
bool reporterInverted = false) = 0;
|
|
|
|
|
|
|
|
static void triggerEvent(object_id_t reportingObject, Event event,
|
2020-09-05 15:58:53 +02:00
|
|
|
uint32_t parameter1 = 0, uint32_t parameter2 = 0,
|
|
|
|
MessageQueueId_t sentFrom = 0) {
|
2020-08-28 17:44:10 +02:00
|
|
|
EventMessage message(event, reportingObject, parameter1, parameter2);
|
|
|
|
triggerEvent(&message, sentFrom);
|
|
|
|
}
|
2020-09-05 15:58:53 +02:00
|
|
|
|
|
|
|
static void triggerEvent(EventMessage* message,
|
|
|
|
MessageQueueId_t sentFrom = 0) {
|
|
|
|
static MessageQueueId_t eventmanagerQueue = MessageQueueIF::NO_QUEUE;
|
|
|
|
if (eventmanagerQueue == MessageQueueIF::NO_QUEUE) {
|
2020-08-28 17:44:10 +02:00
|
|
|
EventManagerIF *eventmanager = objectManager->get<EventManagerIF>(
|
|
|
|
objects::EVENT_MANAGER);
|
2020-09-05 15:58:53 +02:00
|
|
|
if (eventmanager == nullptr) {
|
|
|
|
return;
|
2020-08-28 17:44:10 +02:00
|
|
|
}
|
2020-09-05 15:58:53 +02:00
|
|
|
eventmanagerQueue = eventmanager->getEventReportQueue();
|
2020-08-28 17:44:10 +02:00
|
|
|
}
|
|
|
|
MessageQueueSenderIF::sendMessage(eventmanagerQueue, message, sentFrom);
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* EVENTMANAGERIF_H_ */
|