ADD: added automatic delete of lost tracks

This commit is contained in:
Henry Winkel
2024-03-14 17:48:54 +01:00
parent d56df03ed4
commit 87368640e2
5 changed files with 128 additions and 72 deletions

View File

@@ -17,6 +17,7 @@
#include <string>
#include <thread>
#include <loguru.hpp>
#include <SimCore/CallBackTimer.hpp>
namespace TrackList
{
@@ -25,6 +26,10 @@ namespace TrackList
{
public:
TrackList();
~TrackList();
TrackList(const TrackList &other);
TrackList& operator=(const TrackList & oter);
void addTrack(std::shared_ptr<SimCore::SensorTrack> Track);
std::shared_ptr<SimCore::SensorTrack> getTrack(SimCore::Identifier);
@@ -36,12 +41,22 @@ namespace TrackList
void getJsonTRackList(nlohmann::json &message);
std::map<std::string, std::shared_ptr<SimCore::SensorTrack>> getTrackStore();
/**
* @brief cheks the trackstore for old tracks to delete
*
*/
void checkTrackStore();
private:
mutable std::mutex mx_;
std::map<std::string, std::shared_ptr<SimCore::SensorTrack>> TrackStore_;
/// seconds after the last updated a track gets deleted
const int trackNoUpdateTime = 10;
CallBackTimer timer_;
};