diff options
author | André Nusser <andre.nusser@googlemail.com> | 2020-02-17 23:50:35 +0100 |
---|---|---|
committer | André Nusser <andre.nusser@googlemail.com> | 2020-02-23 13:46:28 +0100 |
commit | 95ca5bc0c29d1cb3e7a16904dfe3790513870bc7 (patch) | |
tree | eae40d875c9bac5a8b1174f7d686ef595ad675d1 /src | |
parent | ddc4ee9be5fc63e8a10464d2eaa3bbd3958ee408 (diff) |
Change channel type to channel_t in EventsDS and introduce new assert.
Diffstat (limited to 'src')
-rw-r--r-- | src/events_ds.cc | 2 | ||||
-rw-r--r-- | src/events_ds.h | 17 |
2 files changed, 10 insertions, 9 deletions
diff --git a/src/events_ds.cc b/src/events_ds.cc index 1d86b0a..097ddc1 100644 --- a/src/events_ds.cc +++ b/src/events_ds.cc @@ -56,7 +56,7 @@ void EventsDS::remove(EventID event_id) id_to_info.remove(event_id); } -std::size_t EventsDS::numberOfEvents(int ch) const +std::size_t EventsDS::numberOfEvents(channel_t ch) const { auto& channel_data = channel_data_array[ch]; return channel_data.sample_events.size(); diff --git a/src/events_ds.h b/src/events_ds.h index 6d2959e..dd13ec0 100644 --- a/src/events_ds.h +++ b/src/events_ds.h @@ -62,18 +62,18 @@ class EventsDS public: //! Adds a new event of type T (via emplace syntax) to the data structure. template <typename T, typename... Args> - T& emplace(int ch, Args&&... args); + T& emplace(channel_t ch, Args&&... args); //! Removes the event with id being event_id. void remove(EventID event_id); //! Returns the number of all events of a certain channel. - std::size_t numberOfEvents(int ch) const; + std::size_t numberOfEvents(channel_t ch) const; //! Gives a range that can be used in a range based for loop to iterate over //! all events in channel ch of type T. template <typename T> - ContainerRange<std::vector<T>> iterateOver(int ch); + ContainerRange<std::vector<T>> iterateOver(channel_t ch); //! Returns all the group ids of sample events associated with instrument_id. const EventGroupIDs& getSampleEventGroupIDsOf(InstrumentID instrument_id) const; @@ -98,10 +98,10 @@ private: struct EventInfo { Event::Type type; - int ch; + channel_t ch; ChannelEventIndex channel_event_index; - EventInfo(Event::Type type, int ch, ChannelEventIndex channel_event_index) + EventInfo(Event::Type type, channel_t ch, ChannelEventIndex channel_event_index) : type(type), ch(ch), channel_event_index(channel_event_index) {} }; @@ -132,7 +132,7 @@ private: }; template <typename T, typename... Args> -T& EventsDS::emplace(int ch, Args&&... args) +T& EventsDS::emplace(channel_t ch, Args&&... args) { // add new event types here static_assert(std::is_same<T, SampleEvent>::value); @@ -149,14 +149,15 @@ T& EventsDS::emplace(int ch, Args&&... args) auto& sample_event = sample_events.back(); sample_event.id = event_id; sample_event.group_id = current_group_id; - assert(sample_event.instrument_id == current_groups_instrument_id); + assert(sample_event.instrument_id == current_groups_instrument_id); + assert(sample_event.channel == ch); return sample_event; } } template <typename T> -ContainerRange<std::vector<T>> EventsDS::iterateOver(int ch) +ContainerRange<std::vector<T>> EventsDS::iterateOver(channel_t ch) { // add new event types here static_assert(std::is_same<T, SampleEvent>::value); |