#pragma once

#include <WHISPER/whisper.hpp>
#include <WHISPER/Messages/Message.hpp>

#include "SimCore/Messages/Protos/SimTrack.pb.h"
#include <SimCore/Identifier.hpp>
#include <SimCore/Position.hpp>
#include <SimCore/data.hpp>

#include <SimCore/Messages/Emission.hpp>
#include <memory>

namespace SimCore
{
    class SimTrack
    {

    public:
        SimTrack();

        SimTrack(WHISPER::SourceType sourcetype, SimCore::EntityKind entityKind);

        SimTrack(SimCore::Identifier id, WHISPER::SourceType sourcetype, SimCore::EntityKind entityKind);

        ~SimTrack();

        /// @brief
        /// @param pos
        void setPosition(SimCore::Position pos);

        /// @brief
        /// @param x
        /// @param y
        /// @param z
        void setPosition(double x, double y, double z);
        SimCore::Position getPosition();
        
        const SimCore::Identifier getIdentifier();
        
        /// @brief
        /// @param emission
        void addEmission(Emission emission);

        /// @brief
        /// @param id
        /// @return
        std::shared_ptr<Emission> getEmission(SimCore::Identifier id);

        /// @brief couts the stored emissions
        /// @return returns the amout of emission
        size_t coutEmissions();

        /// @brief return a WHISPER Message out of a simtrack object
        /// @param parentID 
        /// @return WHISPER::Message
        WHISPER::Message buildMessage();

        /// @brief creates a SimTrack out of a whisper message
        /// @param msg 
        /// @return SimTrack Oject
        static SimTrack unpack(WHISPER::Message msg);

        /// @brief creates a SimTrack out of a string message
        /// @param msg 
        /// @return SimTrack Oject
        static std::unique_ptr<SimCore::SimTrack> unpack(std::string msgString);

    public:
        Data<double> Speed;
        Data<double> Course;
        Data<double> Pitch;
        Data<double> RCS;

        Data<SimCore::EntityKind> EntityKind;

    private:
        const SimCore::Identifier ID_;

        const WHISPER::SourceType SourceType_;

        Position position_;

        std::vector<std::shared_ptr<SimCore::Emission>> EmissionList;
    };

}