v2.0.0
Loading...
Searching...
No Matches
eventmanager.h
Go to the documentation of this file.
1//=============================================================================================================
35
36#ifndef EVENTMANAGER_EVENTS_H
37#define EVENTMANAGER_EVENTS_H
38
39//=============================================================================================================
40// INCLUDES
41//=============================================================================================================
42
43#include "events_global.h"
44#include "event.h"
45#include "eventgroup.h"
46
47#ifndef NO_IPC
49#else
50namespace EVENTSLIB{
52}
53#endif
54//=============================================================================================================
55// STD INCLUDES
56//=============================================================================================================
57
58#include <string>
59#include <map>
60#include <unordered_map>
61#include <vector>
62#include <memory>
63
64//=============================================================================================================
65// NAMESPACE EVENTSLIB
66//=============================================================================================================
67
68namespace EVENTSLIB {
69
70//=============================================================================================================
71// EVENTSINTERNAL FORWARD DECLARATIONS
72//=============================================================================================================
73
74namespace EVENTSINTERNAL {
76}
77
78//=============================================================================================================
88{
89public:
90 //=========================================================================================================
95
96 //=========================================================================================================
101 size_t getNumEvents() const;
102
103 //=========================================================================================================
109 Event getEvent(idNum eventId) const;
110
111 //=========================================================================================================
117 std::unique_ptr<std::vector<Event> > getEvents(const std::vector<idNum> eventIds) const ;
118
119 //=========================================================================================================
124 std::unique_ptr<std::vector<Event> > getAllEvents() const ;
125
126 //=========================================================================================================
132 std::unique_ptr<std::vector<Event> > getEventsInSample(int sample) const ;
133
134 //=========================================================================================================
141 std::unique_ptr<std::vector<Event> > getEventsBetween(int sampleStart, int sampleEnd) const ;
142
143 //=========================================================================================================
152 std::unique_ptr<std::vector<Event> > getEventsBetween(int sampleStart, int sampleEnd, idNum groupid) const ;
153
154 //=========================================================================================================
163 std::unique_ptr<std::vector<Event> > getEventsBetween(int sampleStart, int sampleEnd, const std::vector<idNum>& groupIdsList) const ;
164
165 //=========================================================================================================
171 std::unique_ptr<std::vector<Event> > getEventsInGroup(const idNum groupId) const;
172
173 //=========================================================================================================
179 std::unique_ptr<std::vector<Event> > getEventsInGroups(const std::vector<idNum>& groupIdsList) const;
180
181 //=========================================================================================================
187 Event addEvent(int sample);
188
189 //=========================================================================================================
196 Event addEvent(int sample, idNum groupId);
197
198 //=========================================================================================================
205 bool moveEvent(idNum eventId, int newSample);
206
207 //=========================================================================================================
213 bool deleteEvent(idNum eventId) noexcept;
214
215 //=========================================================================================================
221 bool deleteEvents(const std::vector<idNum>& eventIds);
222
223 //=========================================================================================================
229 bool deleteEvents(std::unique_ptr<std::vector<Event> > eventIds);
230
231 //=========================================================================================================
237 bool deleteEventsInGroup(idNum groupId);
238
239 //=========================================================================================================
244 int getNumGroups() const;
245
246 //=========================================================================================================
252 EventGroup getGroup(idNum groupId) const;
253
254 //=========================================================================================================
259 std::unique_ptr<std::vector<EventGroup> > getAllGroups() const ;
260
261 //=========================================================================================================
267 std::unique_ptr<std::vector<EventGroup> > getGroups(const std::vector<idNum>& groupIds) const ;
268
269 //=========================================================================================================
275 EventGroup addGroup(const std::string& sGroupName);
276
277 //=========================================================================================================
284 EventGroup addGroup(const std::string& sGroupName, const RgbColor& color);
285
286 //=========================================================================================================
292 bool deleteGroup(const idNum groupId);
293
294 //=========================================================================================================
300 bool deleteGroups(const std::vector<idNum>& groupIds);
301
302 //=========================================================================================================
308 void renameGroup(const idNum groupId, const std::string& newName);
309
310 //=========================================================================================================
316 void setGroupColor(const idNum groupId, const RgbColor& color);
317
318 //=========================================================================================================
325 EventGroup mergeGroups(const std::vector<idNum>& groupIds, const std::string& newName);
326
327 //=========================================================================================================
334 EventGroup duplicateGroup(const idNum groupId, const std::string& newName);
335
336 //=========================================================================================================
343 bool addEventToGroup(const idNum eventId, const idNum groupId);
344
345 //=========================================================================================================
352 bool addEventsToGroup(const std::vector<idNum>& eventIds, const idNum groupId);
353
354 //=========================================================================================================
359 void initSharedMemory();
360
361 //=========================================================================================================
367
368 //=========================================================================================================
372 void stopSharedMemory();
373
374 //=========================================================================================================
379 bool isSharedMemoryInit();
380
381private:
382 //=========================================================================================================
387 idNum generateNewEventId();
388
389 //=========================================================================================================
394 idNum generateNewGroupId();
395
396 //=========================================================================================================
401 void insertEvent(const EVENTSINTERNAL::EventINT& e);
402
403 //=========================================================================================================
409 bool eraseEvent(idNum eventId);
410
411 //=========================================================================================================
417 std::multimap<int, EVENTSINTERNAL::EventINT>::const_iterator findEventINT(idNum id) const;
418
419 //=========================================================================================================
423 void createDefaultGroupIfNeeded();
424
425 std::multimap<int, EVENTSINTERNAL::EventINT> m_EventsListBySample;
426 std::unordered_map<idNum, int> m_MapIdToSample;
427 std::map<idNum, EVENTSINTERNAL::EventGroupINT> m_GroupsList;
428
429#ifndef NO_IPC
430 std::unique_ptr<EVENTSINTERNAL::EventSharedMemManager> m_pSharedMemManager;
432#endif
433
434 idNum m_iEventIdCounter;
435 idNum m_iGroupIdCounter;
436 bool m_bDefaultGroupNotCreated;
437 idNum m_DefaultGroupId;
438
439};
440
441//=============================================================================================================
445template<typename T>
446inline std::unique_ptr<std::vector<T> > allocateOutputContainer() noexcept
447{
448 return std::make_unique<std::vector<T> >();
449};
450
451//=============================================================================================================
455template<typename T>
456inline std::unique_ptr<std::vector<T> > allocateOutputContainer(size_t size) noexcept
457{
458 auto v = std::make_unique<std::vector<T> >();
459 if(size > 0)
460 {
461 v->reserve(size);
462 }
463
464 return v;
465};
466
467}//namespace EVENTSLIB
468#endif // EVENTS_H
EventSharedMemManager definition.
EventGroup declaration.
unsigned int idNum
Definition eventgroup.h:51
event library export/import macros.
#define EVENTS_EXPORT
Event declaration.
Event annotation management (creation, grouping, shared-memory transport).
Definition event.h:56
std::unique_ptr< std::vector< T > > allocateOutputContainer() noexcept
Public event descriptor holding sample index, group membership, and unique identifier.
Definition event.h:74
Internal event representation with sample position, group link, and unique ID used by EventManager.
Definition event.h:120
Simple RGB triplet for color-coding event groups.
Definition eventgroup.h:77
EventGroup class is designed as a data holder for a group. It is designed towards ease of use for a c...
Definition eventgroup.h:119
std::unique_ptr< std::vector< Event > > getEventsInGroups(const std::vector< idNum > &groupIdsList) const
bool deleteGroup(const idNum groupId)
EventGroup getGroup(idNum groupId) const
EventGroup mergeGroups(const std::vector< idNum > &groupIds, const std::string &newName)
bool moveEvent(idNum eventId, int newSample)
bool addEventToGroup(const idNum eventId, const idNum groupId)
bool deleteEventsInGroup(idNum groupId)
EventGroup duplicateGroup(const idNum groupId, const std::string &newName)
EventGroup addGroup(const std::string &sGroupName)
bool deleteEvent(idNum eventId) noexcept
void renameGroup(const idNum groupId, const std::string &newName)
std::unique_ptr< std::vector< EventGroup > > getAllGroups() const
Event addEvent(int sample)
std::unique_ptr< std::vector< Event > > getEvents(const std::vector< idNum > eventIds) const
size_t getNumEvents() const
std::unique_ptr< std::vector< Event > > getAllEvents() const
bool deleteGroups(const std::vector< idNum > &groupIds)
void setGroupColor(const idNum groupId, const RgbColor &color)
bool deleteEvents(const std::vector< idNum > &eventIds)
Event getEvent(idNum eventId) const
bool addEventsToGroup(const std::vector< idNum > &eventIds, const idNum groupId)
std::unique_ptr< std::vector< EventGroup > > getGroups(const std::vector< idNum > &groupIds) const
std::unique_ptr< std::vector< Event > > getEventsBetween(int sampleStart, int sampleEnd) const
std::unique_ptr< std::vector< Event > > getEventsInSample(int sample) const
std::unique_ptr< std::vector< Event > > getEventsInGroup(const idNum groupId) const
Publishes and receives event change notifications between processes via a shared-memory ring buffer.