From a29b76ac382b5dc637855fb8e912f474f485914d Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Wed, 13 Jan 2016 11:52:39 -0800 Subject: [PATCH] Pull AIS record types out of AISView. --- firmware/application/ais_app.cpp | 6 ++-- firmware/application/ais_app.hpp | 54 ++++++++++++++++---------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/firmware/application/ais_app.cpp b/firmware/application/ais_app.cpp index cd2854dd..9f0de16f 100644 --- a/firmware/application/ais_app.cpp +++ b/firmware/application/ais_app.cpp @@ -144,7 +144,7 @@ void AISView::truncate_entries() { void AISView::on_packet(const ais::Packet& packet) { const auto source_id = packet.source_id(); auto matching_recent = std::find_if(recent.begin(), recent.end(), - [source_id](const AISView::RecentEntry& entry) { return entry.mmsi == source_id; } + [source_id](const AISRecentEntry& entry) { return entry.mmsi == source_id; } ); if( matching_recent != recent.end() ) { // Found within. Move to front of list, increment counter. @@ -211,7 +211,7 @@ bool AISView::on_encoder(const EncoderEvent event) { } void AISView::draw_entry( - const RecentEntry& entry, + const AISRecentEntry& entry, const Rect& target_rect, Painter& painter, const Style& style, @@ -268,7 +268,7 @@ void AISView::paint(Painter& painter) { AISView::RecentEntries::iterator AISView::selected_entry() { const auto key = selected_key; - return std::find_if(std::begin(recent), std::end(recent), [key](const RecentEntry& e) { return e.mmsi == key; }); + return std::find_if(std::begin(recent), std::end(recent), [key](const AISRecentEntry& e) { return e.mmsi == key; }); } void AISView::advance(const int32_t amount) { diff --git a/firmware/application/ais_app.hpp b/firmware/application/ais_app.hpp index a941321c..68ac70d0 100644 --- a/firmware/application/ais_app.hpp +++ b/firmware/application/ais_app.hpp @@ -38,6 +38,31 @@ using namespace lpc43xx; #include +struct AISPosition { + rtc::RTC timestamp { }; + ais::Latitude latitude { 0 }; + ais::Longitude longitude { 0 }; +}; + +struct AISRecentEntry { + ais::MMSI mmsi; + std::string name; + std::string call_sign; + std::string destination; + AISPosition last_position; + size_t received_count; + int8_t navigational_status; + + AISRecentEntry( + const ais::MMSI& mmsi + ) : mmsi { mmsi }, + last_position { }, + received_count { 0 }, + navigational_status { -1 } + { + } +}; + class AISModel { public: AISModel(); @@ -75,38 +100,13 @@ private: bool has_focus = false; - struct Position { - rtc::RTC timestamp { }; - ais::Latitude latitude { 0 }; - ais::Longitude longitude { 0 }; - }; - - struct RecentEntry { - ais::MMSI mmsi; - std::string name; - std::string call_sign; - std::string destination; - Position last_position; - size_t received_count; - int8_t navigational_status; - - RecentEntry( - const ais::MMSI& mmsi - ) : mmsi { mmsi }, - last_position { }, - received_count { 0 }, - navigational_status { -1 } - { - } - }; - - using RecentEntries = std::list; + using RecentEntries = std::list; RecentEntries recent; void on_packet(const ais::Packet& packet); void draw_entry( - const RecentEntry& entry, + const AISRecentEntry& entry, const Rect& target_rect, Painter& painter, const Style& style,