mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
[tracks] Safe GpsTrackCollection requests during recording.
Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
This commit is contained in:
committed by
Konstantin Pastbin
parent
fb62982000
commit
b7b87f5530
@@ -50,15 +50,20 @@ void GpsTrack::AddPoints(vector<location::GpsInfo> const & points)
|
|||||||
ScheduleTask();
|
ScheduleTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackStatistics GpsTrack::GetTrackStatistics() const
|
/// @note These functions are called during recording, so should be synchronized with Collection writer thread.
|
||||||
|
/// @{
|
||||||
|
TrackStatistics GpsTrack::GetTrackStatistics()
|
||||||
{
|
{
|
||||||
|
lock_guard<mutex> lg(m_threadGuard);
|
||||||
return m_collection ? m_collection->GetTrackStatistics() : TrackStatistics();
|
return m_collection ? m_collection->GetTrackStatistics() : TrackStatistics();
|
||||||
}
|
}
|
||||||
|
|
||||||
ElevationInfo const & GpsTrack::GetElevationInfo() const
|
ElevationInfo const & GpsTrack::GetElevationInfo()
|
||||||
{
|
{
|
||||||
|
lock_guard<mutex> lg(m_threadGuard);
|
||||||
return m_collection->UpdateAndGetElevationInfo();
|
return m_collection->UpdateAndGetElevationInfo();
|
||||||
}
|
}
|
||||||
|
/// @}
|
||||||
|
|
||||||
void GpsTrack::Clear()
|
void GpsTrack::Clear()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ public:
|
|||||||
void AddPoints(std::vector<location::GpsInfo> const & points);
|
void AddPoints(std::vector<location::GpsInfo> const & points);
|
||||||
|
|
||||||
/// Returns track statistics
|
/// Returns track statistics
|
||||||
TrackStatistics GetTrackStatistics() const;
|
TrackStatistics GetTrackStatistics();
|
||||||
ElevationInfo const & GetElevationInfo() const;
|
ElevationInfo const & GetElevationInfo();
|
||||||
|
|
||||||
/// Clears any previous tracking info
|
/// Clears any previous tracking info
|
||||||
/// @note Callback is called with 'toRemove' points, if some points were removed.
|
/// @note Callback is called with 'toRemove' points, if some points were removed.
|
||||||
|
|||||||
@@ -68,12 +68,12 @@ bool GpsTracker::IsEmpty() const
|
|||||||
return m_track.IsEmpty();
|
return m_track.IsEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackStatistics GpsTracker::GetTrackStatistics() const
|
TrackStatistics GpsTracker::GetTrackStatistics()
|
||||||
{
|
{
|
||||||
return m_track.GetTrackStatistics();
|
return m_track.GetTrackStatistics();
|
||||||
}
|
}
|
||||||
|
|
||||||
ElevationInfo const & GpsTracker::GetElevationInfo() const
|
ElevationInfo const & GpsTracker::GetElevationInfo()
|
||||||
{
|
{
|
||||||
return m_track.GetElevationInfo();
|
return m_track.GetElevationInfo();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ public:
|
|||||||
|
|
||||||
bool IsEmpty() const;
|
bool IsEmpty() const;
|
||||||
|
|
||||||
TrackStatistics GetTrackStatistics() const;
|
TrackStatistics GetTrackStatistics();
|
||||||
ElevationInfo const & GetElevationInfo() const;
|
ElevationInfo const & GetElevationInfo();
|
||||||
|
|
||||||
using TGpsTrackDiffCallback =
|
using TGpsTrackDiffCallback =
|
||||||
std::function<void(std::vector<std::pair<size_t, location::GpsInfo>> && toAdd,
|
std::function<void(std::vector<std::pair<size_t, location::GpsInfo>> && toAdd,
|
||||||
|
|||||||
Reference in New Issue
Block a user