Files
EntityLibrary/include/Entities/Tracklist/Tracklist.hpp
2024-03-14 17:48:54 +01:00

64 lines
1.7 KiB
C++

#pragma once
#include "SimCore/Identifier.hpp"
#include "SimCore/IdentifierMaker.hpp"
#include "SimCore/Messages/SensorTrack.hpp"
#include "SimCore/Messages/SimTrack.hpp"
#include "nlohmann/json.hpp"
#include <atomic>
#include <cstddef>
#include <list>
#include <memory>
#include <SimCore/Position.hpp>
#include <SimCore/SafeMap.hpp>
// #include <Entities/Tracklist/TracklistItem.hpp>
#include <string>
#include <thread>
#include <loguru.hpp>
#include <SimCore/CallBackTimer.hpp>
namespace TrackList
{
class 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);
void deleteTrack(std::string ID);
void deleteTrack(SimCore::Identifier);
std::shared_ptr<SimCore::SensorTrack> getTrackBySringID(std::string ID);
size_t getSize();
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_;
};
}