From 95ca5bc0c29d1cb3e7a16904dfe3790513870bc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Nusser?= Date: Mon, 17 Feb 2020 23:50:35 +0100 Subject: Change channel type to channel_t in EventsDS and introduce new assert. --- src/events_ds.cc | 2 +- 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 - 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 - ContainerRange> iterateOver(int ch); + ContainerRange> 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 -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::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 -ContainerRange> EventsDS::iterateOver(int ch) +ContainerRange> EventsDS::iterateOver(channel_t ch) { // add new event types here static_assert(std::is_same::value); -- cgit v1.2.3