2016-06-15 23:48:41 +02:00
|
|
|
#ifndef EVENTMANAGER_H_
|
|
|
|
#define EVENTMANAGER_H_
|
|
|
|
|
2020-08-13 20:53:35 +02:00
|
|
|
#include "eventmatching/EventMatchTree.h"
|
|
|
|
#include "EventManagerIF.h"
|
|
|
|
#include "../objectmanager/SystemObject.h"
|
|
|
|
#include "../storagemanager/LocalPool.h"
|
|
|
|
#include "../tasks/ExecutableObjectIF.h"
|
|
|
|
#include "../ipc/MessageQueueIF.h"
|
|
|
|
#include "../ipc/MutexIF.h"
|
2016-06-15 23:48:41 +02:00
|
|
|
#include <map>
|
|
|
|
|
2020-08-28 18:10:02 +02:00
|
|
|
#ifdef DEBUG
|
|
|
|
// forward declaration, should be implemented by mission
|
|
|
|
extern const char* translateObject(object_id_t object);
|
|
|
|
extern const char* translateEvents(Event event);
|
|
|
|
#endif
|
|
|
|
|
2016-06-15 23:48:41 +02:00
|
|
|
class EventManager: public EventManagerIF,
|
|
|
|
public ExecutableObjectIF,
|
|
|
|
public SystemObject {
|
|
|
|
public:
|
2018-07-12 16:29:32 +02:00
|
|
|
static const uint16_t MAX_EVENTS_PER_CYCLE = 80;
|
2016-06-15 23:48:41 +02:00
|
|
|
|
|
|
|
EventManager(object_id_t setObjectId);
|
|
|
|
virtual ~EventManager();
|
|
|
|
|
|
|
|
MessageQueueId_t getEventReportQueue();
|
|
|
|
|
|
|
|
ReturnValue_t registerListener(MessageQueueId_t listener, bool forwardAllButSelected = false);
|
|
|
|
ReturnValue_t subscribeToEvent(MessageQueueId_t listener, EventId_t event);
|
|
|
|
ReturnValue_t subscribeToAllEventsFrom(MessageQueueId_t listener,
|
|
|
|
object_id_t object);
|
|
|
|
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);
|
|
|
|
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);
|
2018-07-12 16:29:32 +02:00
|
|
|
ReturnValue_t performOperation(uint8_t opCode);
|
2016-06-15 23:48:41 +02:00
|
|
|
protected:
|
|
|
|
|
2020-08-28 18:10:02 +02:00
|
|
|
MessageQueueIF* eventReportQueue = nullptr;
|
2016-06-15 23:48:41 +02:00
|
|
|
|
|
|
|
std::map<MessageQueueId_t, EventMatchTree> listenerList;
|
|
|
|
|
2020-08-28 18:10:02 +02:00
|
|
|
MutexIF* mutex = nullptr;
|
2016-06-15 23:48:41 +02:00
|
|
|
|
|
|
|
static const uint8_t N_POOLS = 3;
|
|
|
|
LocalPool<N_POOLS> factoryBackend;
|
|
|
|
static const uint16_t POOL_SIZES[N_POOLS];
|
|
|
|
static const uint16_t N_ELEMENTS[N_POOLS];
|
|
|
|
|
|
|
|
void notifyListeners(EventMessage *message);
|
|
|
|
|
2018-07-12 16:29:32 +02:00
|
|
|
#ifdef DEBUG
|
2016-06-15 23:48:41 +02:00
|
|
|
void printEvent(EventMessage *message);
|
2018-07-12 16:29:32 +02:00
|
|
|
#endif
|
2016-06-15 23:48:41 +02:00
|
|
|
|
|
|
|
void lockMutex();
|
|
|
|
|
|
|
|
void unlockMutex();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* EVENTMANAGER_H_ */
|