Mercurial > hg > svcore
comparison base/EventSeries.h @ 1632:0890c10e5129 single-point
Add some more handy methods
author | Chris Cannam |
---|---|
date | Tue, 12 Mar 2019 14:52:11 +0000 |
parents | b2048f350906 |
children | 6ac92836cd86 |
comparison
equal
deleted
inserted
replaced
1631:b2048f350906 | 1632:0890c10e5129 |
---|---|
32 * simultaneous events changes (i.e. an event of non-zero duration | 32 * simultaneous events changes (i.e. an event of non-zero duration |
33 * starts or ends) associated with a set of the events that are active | 33 * starts or ends) associated with a set of the events that are active |
34 * at or from that position. These are updated when an event is added | 34 * at or from that position. These are updated when an event is added |
35 * or removed. | 35 * or removed. |
36 * | 36 * |
37 * Performance is highly dependent on the extent of overlapping events | 37 * This class is highly optimised for inserting events in increasing |
38 * and the order in which events are added. Each event (with duration) | 38 * order of start frame. Inserting (or deleting) events in the middle |
39 * that is added requires updating all the seams within the extent of | 39 * does work, and should be acceptable in interactive use, but it is |
40 * that event, taking a number of ordered-set updates proportional to | 40 * very slow in bulk. |
41 * the number of events already existing within its extent. Add events | |
42 * in order of start frame if possible. | |
43 */ | 41 */ |
44 class EventSeries : public XmlExportable | 42 class EventSeries : public XmlExportable |
45 { | 43 { |
46 public: | 44 public: |
47 EventSeries() { } | 45 EventSeries() { } |
54 bool operator==(const EventSeries &other) const { | 52 bool operator==(const EventSeries &other) const { |
55 return m_events == other.m_events; | 53 return m_events == other.m_events; |
56 } | 54 } |
57 | 55 |
58 void clear(); | 56 void clear(); |
59 void add(const Event &p); | 57 void add(const Event &e); |
60 void remove(const Event &p); | 58 void remove(const Event &e); |
61 bool contains(const Event &p) const; | 59 bool contains(const Event &e) const; |
62 bool isEmpty() const; | 60 bool isEmpty() const; |
63 int count() const; | 61 int count() const; |
64 | 62 |
65 /** | 63 /** |
66 * Retrieve all events any part of which falls within the span in | 64 * Retrieve all events any part of which falls within the span in |
90 * than it. | 88 * than it. |
91 */ | 89 */ |
92 EventVector getEventsCovering(sv_frame_t frame) const; | 90 EventVector getEventsCovering(sv_frame_t frame) const; |
93 | 91 |
94 /** | 92 /** |
93 * If e is in the series and is not the first event in it, set | |
94 * preceding to the event immediate preceding it according to the | |
95 * standard event ordering and return true. Otherwise leave | |
96 * preceding unchanged and return false. | |
97 * | |
98 * If there are multiple events identical to e in the series, | |
99 * assume that the event passed in is the first one (i.e. never | |
100 * set preceding equal to e). | |
101 */ | |
102 bool getEventPreceding(const Event &e, Event &preceding) const; | |
103 | |
104 /** | |
105 * If e is in the series and is not the final event in it, set | |
106 * following to the event immediate following it according to the | |
107 * standard event ordering and return true. Otherwise leave | |
108 * following unchanged and return false. | |
109 * | |
110 * If there are multiple events identical to e in the series, | |
111 * assume that the event passed in is the last one (i.e. never set | |
112 * following equal to e). | |
113 */ | |
114 bool getEventFollowing(const Event &e, Event &following) const; | |
115 | |
116 /** | |
117 * Return the event at the given numerical index in the series, | |
118 * where 0 = the first event and count()-1 = the last. | |
119 */ | |
120 Event getEventByIndex(int index) const; | |
121 | |
122 /** | |
95 * Emit to XML as a dataset element. | 123 * Emit to XML as a dataset element. |
96 */ | 124 */ |
97 void toXml(QTextStream &out, | 125 void toXml(QTextStream &out, |
98 QString indent, | 126 QString indent, |
99 QString extraAttributes) const override; | 127 QString extraAttributes) const override; |