1 // Copyright (c) 2016 The SigViewer Development Team 2 // Licensed under the GNU General Public License (GPL) 3 // https://www.gnu.org/licenses/gpl 4 5 6 #ifndef EVENT_TABLE_FILE_READER 7 #define EVENT_TABLE_FILE_READER 8 9 #include "base/sigviewer_user_types.h" 10 #include "biosig.h" 11 12 #include <QStringList> 13 #include <QMap> 14 #include <QList> 15 16 #include <set> 17 18 class QTextStream; 19 20 namespace sigviewer 21 { 22 23 24 //----------------------------------------------------------------------------- 25 /// 26 /// EventTableFileReader 27 /// 28 /// responsible for mapping of EventType to String (name of event) 29 class EventTableFileReader 30 { 31 public: 32 typedef QList<uint16>::const_iterator IntIterator; 33 typedef QStringList::const_iterator StringIterator; 34 35 EventTableFileReader(); 36 ~EventTableFileReader(); 37 38 StringIterator getGroupIdBegin() const; 39 StringIterator getGroupIdEnd() const; 40 QString getEventGroupName(const QString& group_id) const; 41 42 IntIterator eventTypesBegin(); 43 IntIterator eventTypesEnd(); 44 QString getEventName (EventType event_type_id) const; 45 void setEventName (EventType event_type_id, QString const& name); 46 void restoreEventNames (); 47 std::set<EventType> getEventsOfGroup (QString const& group_id) const; 48 QString getEventGroupId (EventType event_type_id) const; 49 50 //--------------------------------------------------------------------------------------------- 51 /// @return true if an the eventtablefilereader has an entry of this type; 52 /// false if not 53 bool entryExists (EventType type) const; 54 55 //--------------------------------------------------------------------------------------------- 56 void addEntry (EventType type, QString const& name = "", QString group_id = ""); 57 58 std::set<uint16> getAllEventTypes () const; 59 private: 60 bool load(); 61 62 static QString const UNKNOWN_GROUP_ID; 63 64 struct EventItem 65 { 66 QString name; 67 QString group_id; 68 }; 69 70 typedef QMap<EventType, EventItem> Int2EventItemMap; 71 typedef QMap<QString, QString> String2StringMap; 72 73 Q_DISABLE_COPY(EventTableFileReader) 74 75 QList<EventType> event_types_; 76 QStringList event_group_ids_; 77 Int2EventItemMap event_type2name_; 78 String2StringMap group_id2name_; 79 }; 80 81 } 82 83 #endif 84