mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-01-26 06:26:17 -05:00
RecentEntries: Remove Packet template arg.
This commit is contained in:
parent
4d781df76c
commit
42d98c3b45
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ private:
|
||||
LogFile log_file;
|
||||
};
|
||||
|
||||
using ERTRecentEntries = RecentEntries<ert::Packet, ERTRecentEntry>;
|
||||
using ERTRecentEntries = RecentEntries<ERTRecentEntry>;
|
||||
|
||||
namespace ui {
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user