Pull AIS record types out of AISView.

This commit is contained in:
Jared Boone 2016-01-13 11:52:39 -08:00
parent 4b2157a938
commit a29b76ac38
2 changed files with 30 additions and 30 deletions

View File

@ -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) {

View File

@ -38,6 +38,31 @@ using namespace lpc43xx;
#include <iterator>
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<RecentEntry>;
using RecentEntries = std::list<AISRecentEntry>;
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,