MNE-CPP 0.1.9
A Framework for Electrophysiology
Loading...
Searching...
No Matches
eventmanager.h
Go to the documentation of this file.
1//=============================================================================================================
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{
51 enum SharedMemoryMode { READ, WRITE, READWRITE };
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 {
75 class EventSharedMemManager;
76}
77
78//=============================================================================================================
86{
87public:
88 //=========================================================================================================
93
94 //=========================================================================================================
99 size_t getNumEvents() const;
100
101 //=========================================================================================================
107 Event getEvent(idNum eventId) const;
108
109 //=========================================================================================================
115 std::unique_ptr<std::vector<Event> > getEvents(const std::vector<idNum> eventIds) const ;
116
117 //=========================================================================================================
122 std::unique_ptr<std::vector<Event> > getAllEvents() const ;
123
124 //=========================================================================================================
130 std::unique_ptr<std::vector<Event> > getEventsInSample(int sample) const ;
131
132 //=========================================================================================================
139 std::unique_ptr<std::vector<Event> > getEventsBetween(int sampleStart, int sampleEnd) const ;
140
141 //=========================================================================================================
150 std::unique_ptr<std::vector<Event> > getEventsBetween(int sampleStart, int sampleEnd, idNum groupid) const ;
151
152 //=========================================================================================================
161 std::unique_ptr<std::vector<Event> > getEventsBetween(int sampleStart, int sampleEnd, const std::vector<idNum>& groupIdsList) const ;
162
163 //=========================================================================================================
169 std::unique_ptr<std::vector<Event> > getEventsInGroup(const idNum groupId) const;
170
171 //=========================================================================================================
177 std::unique_ptr<std::vector<Event> > getEventsInGroups(const std::vector<idNum>& groupIdsList) const;
178
179 //=========================================================================================================
185 Event addEvent(int sample);
186
187 //=========================================================================================================
194 Event addEvent(int sample, idNum groupId);
195
196 //=========================================================================================================
203 bool moveEvent(idNum eventId, int newSample);
204
205 //=========================================================================================================
211 bool deleteEvent(idNum eventId) noexcept;
212
213 //=========================================================================================================
219 bool deleteEvents(const std::vector<idNum>& eventIds);
220
221 //=========================================================================================================
227 bool deleteEvents(std::unique_ptr<std::vector<Event> > eventIds);
228
229 //=========================================================================================================
235 bool deleteEventsInGroup(idNum groupId);
236
237 //=========================================================================================================
242 int getNumGroups() const;
243
244 //=========================================================================================================
250 EventGroup getGroup(idNum groupId) const;
251
252 //=========================================================================================================
257 std::unique_ptr<std::vector<EventGroup> > getAllGroups() const ;
258
259 //=========================================================================================================
265 std::unique_ptr<std::vector<EventGroup> > getGroups(const std::vector<idNum>& groupIds) const ;
266
267 //=========================================================================================================
273 EventGroup addGroup(const std::string& sGroupName);
274
275 //=========================================================================================================
282 EventGroup addGroup(const std::string& sGroupName, const RgbColor& color);
283
284 //=========================================================================================================
290 bool deleteGroup(const idNum groupId);
291
292 //=========================================================================================================
298 bool deleteGroups(const std::vector<idNum>& groupIds);
299
300 //=========================================================================================================
306 void renameGroup(const idNum groupId, const std::string& newName);
307
308 //=========================================================================================================
314 void setGroupColor(const idNum groupId, const RgbColor& color);
315
316 //=========================================================================================================
323 EventGroup mergeGroups(const std::vector<idNum>& groupIds, const std::string& newName);
324
325 //=========================================================================================================
332 EventGroup duplicateGroup(const idNum groupId, const std::string& newName);
333
334 //=========================================================================================================
341 bool addEventToGroup(const idNum eventId, const idNum groupId);
342
343 //=========================================================================================================
350 bool addEventsToGroup(const std::vector<idNum>& eventIds, const idNum groupId);
351
352 //=========================================================================================================
357 void initSharedMemory();
358
359 //=========================================================================================================
364 void initSharedMemory(SharedMemoryMode mode);
365
366 //=========================================================================================================
370 void stopSharedMemory();
371
372 //=========================================================================================================
377 bool isSharedMemoryInit();
378
379private:
380 //=========================================================================================================
385 idNum generateNewEventId();
386
387 //=========================================================================================================
392 idNum generateNewGroupId();
393
394 //=========================================================================================================
399 void insertEvent(const EVENTSINTERNAL::EventINT& e);
400
401 //=========================================================================================================
407 bool eraseEvent(idNum eventId);
408
409 //=========================================================================================================
415 std::multimap<int, EVENTSINTERNAL::EventINT>::const_iterator findEventINT(idNum id) const;
416
417 //=========================================================================================================
421 void createDefaultGroupIfNeeded();
422
423 std::multimap<int, EVENTSINTERNAL::EventINT> m_EventsListBySample;
424 std::unordered_map<idNum, int> m_MapIdToSample;
425 std::map<idNum, EVENTSINTERNAL::EventGroupINT> m_GroupsList;
427#ifndef NO_IPC
428 std::unique_ptr<EVENTSINTERNAL::EventSharedMemManager> m_pSharedMemManager;
430#endif
431
432 idNum m_iEventIdCounter;
433 idNum m_iGroupIdCounter;
434 bool m_bDefaultGroupNotCreated;
435 idNum m_DefaultGroupId;
437};
438
439//=============================================================================================================
443template<typename T>
444inline std::unique_ptr<std::vector<T> > allocateOutputContainer() noexcept
445{
446 return std::make_unique<std::vector<T> >();
447};
448
449//=============================================================================================================
453template<typename T>
454inline std::unique_ptr<std::vector<T> > allocateOutputContainer(size_t size) noexcept
455{
456 auto v = std::make_unique<std::vector<T> >();
457 if(size > 0)
458 {
459 v->reserve(size);
460 }
461
462 return v;
463};
464
465}//namespace EVENTSLIB
466#endif // EVENTS_H
EventSharedMemManager definition.
EventGroup declaration.
event library export/import macros.
#define EVENTS_EXPORT
std::unique_ptr< std::vector< T > > allocateOutputContainer() noexcept
Event declaration.
EventGroup class is designed as a data holder for a group. It is designed towards ease of use for a c...
Definition eventgroup.h:117