RecentEntries: Remove Packet template arg.

This commit is contained in:
Jared Boone 2016-09-03 16:38:44 -07:00
parent 4d781df76c
commit 42d98c3b45
7 changed files with 14 additions and 14 deletions

View File

@ -336,12 +336,13 @@ void AISAppView::on_packet(const ais::Packet& packet) {
logger->on_packet(packet);
}
const auto updated_entry = recent.on_packet(packet.source_id(), packet);
auto& entry = recent.on_packet(packet.source_id());
entry.update(packet);
recent_entries_view.set_dirty();
// TODO: Crude hack, should be a more formal listener arrangement...
if( updated_entry.key() == recent_entry_detail_view.entry().key() ) {
recent_entry_detail_view.set_entry(updated_entry);
if( entry.key() == recent_entry_detail_view.entry().key() ) {
recent_entry_detail_view.set_entry(entry);
}
}

View File

@ -91,7 +91,7 @@ struct AISRecentEntry {
void update(const ais::Packet& packet);
};
using AISRecentEntries = RecentEntries<ais::Packet, AISRecentEntry>;
using AISRecentEntries = RecentEntries<AISRecentEntry>;
class AISLogger {
public:

View File

@ -150,7 +150,8 @@ void ERTAppView::on_packet(const ert::Packet& packet) {
}
if( packet.crc_ok() ) {
recent.on_packet({ packet.id(), packet.commodity_type() }, packet);
auto& entry = recent.on_packet({ packet.id(), packet.commodity_type() });
entry.update(packet);
recent_entries_view.set_dirty();
}
}

View File

@ -100,7 +100,7 @@ private:
LogFile log_file;
};
using ERTRecentEntries = RecentEntries<ert::Packet, ERTRecentEntry>;
using ERTRecentEntries = RecentEntries<ERTRecentEntry>;
namespace ui {

View File

@ -33,7 +33,7 @@
#include <iterator>
#include <algorithm>
template<class Packet, class Entry>
template<class Entry>
class RecentEntries {
public:
using EntryType = Entry;
@ -43,7 +43,7 @@ public:
using const_iterator = typename ContainerType::const_iterator;
using RangeType = std::pair<const_iterator, const_iterator>;
const EntryType& on_packet(const Key key, const Packet& packet) {
EntryType& on_packet(const Key key) {
auto matching_recent = find(key);
if( matching_recent != std::end(entries) ) {
// Found within. Move to front of list, increment counter.
@ -54,10 +54,7 @@ public:
truncate_entries();
}
auto& entry = entries.front();
entry.update(packet);
return entry;
return entries.front();
}
const_reference front() const {

View File

@ -199,7 +199,8 @@ void TPMSAppView::on_packet(const tpms::Packet& packet) {
const auto reading_opt = packet.reading();
if( reading_opt.is_valid() ) {
const auto reading = reading_opt.value();
recent.on_packet({ reading.type(), reading.id() }, reading);
auto& entry = recent.on_packet({ reading.type(), reading.id() });
entry.update(reading);
recent_entries_view.set_dirty();
}
}

View File

@ -72,7 +72,7 @@ struct TPMSRecentEntry {
void update(const tpms::Reading& reading);
};
using TPMSRecentEntries = RecentEntries<tpms::Reading, TPMSRecentEntry>;
using TPMSRecentEntries = RecentEntries<TPMSRecentEntry>;
class TPMSLogger {
public: