// ************************************************************************** // // (C) Copyright 2009 Swiss SIMTEC AG // // ************************************************************************** // // $HeadURL$ // $LastChangedBy$ // $LastChangedDate$ // $LastChangedRevision$ // // ************************************************************************** // manual class headers #include "GeoPairingImplAirTargetUpdater.hpp" #include "../logger.h" namespace N_GeoPairingImpl { GeoPairingImplAirTargetUpdater::~GeoPairingImplAirTargetUpdater() { INFO_LOG(m_logger) << "Number of updated air targets : " << m_UpdateCount; } // --------------------------------------------------------------- // Constructor // --------------------------------------------------------------- GeoPairingImplAirTargetUpdater::GeoPairingImplAirTargetUpdater(std::vector *a_listTargets) : m_List(a_listTargets) , m_logger(CesGeoPairing::getLogger("Plugin.GeoPairing.GeoPairingImplAirTargetUpdater")) { INFO_LOG(m_logger) << "Construct Updater for " << a_listTargets->size() << " air targets"; } // --------------------------------------------------------------- // update position of a particular air target // --------------------------------------------------------------- void GeoPairingImplAirTargetUpdater::update(SInt32 a_playerID, Float64 a_positionLat, Float64 a_positionLon, Float64 a_positionAlt, UInt32 a_positionTime, SInt32 a_state) { GeoPairingImplAirTarget *l_PlayerAirTarget = nullptr; // iterate throught list to find if a air target with this player ID exists already for (const auto l_AirTarget : *m_List) { if (l_AirTarget->m_PlayerID == a_playerID) { l_PlayerAirTarget = l_AirTarget; break; } } // create new air target if (l_PlayerAirTarget == nullptr) { INFO_LOG(m_logger) << "Creating a new air target object for Player " << a_playerID; l_PlayerAirTarget = new GeoPairingImplAirTarget(a_playerID); m_List->push_back(l_PlayerAirTarget); } // update the air target if (l_PlayerAirTarget->updatePosition(a_positionLat, a_positionLon, a_positionAlt, a_positionTime)) m_UpdateCount++; l_PlayerAirTarget->updateState(a_state); } } // namespace N_GeoPairingImpl