/** * Handler for player data * $Id$ * $HeadURL$ * $Author$ * Created by gr, SLSE, 2017-02-20 */ #pragma once #include #include #include #include #include #include #include #include // AES-Handling for participants within buildings namespace CesBuildings { class HandlerBuildingOwnership final : public QObject , protected CentralEffectSimulation::Interface::Fts::SetOwnershipRequestHandler { Q_OBJECT public: explicit HandlerBuildingOwnership(const std::shared_ptr &ddsHandler, const std::shared_ptr &participantHandler, const std::shared_ptr &buildingDataHandler, const std::shared_ptr &db, QObject *parent = nullptr); ~HandlerBuildingOwnership(); /** * Initialize the handler to manage information from player management */ bool init(); private Q_SLOTS: /** * Handle MainStructureElement from 'ISM' */ void onParticipantPositionChanged(const CentralEffectSimulation::HandlerParticipant::CesParticipantData &partPos); /** * Handle MainStructureElement from 'ISM' */ void onMainStructureElementChanged(const InfrastructureManagement::MainStructureElement &data, DataModification modType); void onParticipantLeavesBuilding(const int participantId); private: // methoden void onSetOwnershipRequest(const rti::core::SampleIdentity &cookie, const CentralEffectSimulation::SetOwnershipRequest &request) override; int calculateOwnershipByParticipantId(const int participantId); int calculateOwnershipByFloorId(const int floorId); void checkAndSendOwnership(const int newOwnership, const int floorId); void saveBuildingOwnership(int floorId, int partyId, int buildingId); void sendBuildingOwnership(int buildingId); int getOwnership(int buildingId, int floorId) const; void updateOwnerships(CentralEffectSimulation::BuildingOwnership *bo); bool loadOwnershipsFromDb(); void removeFromDbBuildingId(const int buildingId); void insertInDb(const CentralEffectSimulation::BuildingOwnership &bo); private: // attributes std::shared_ptr m_ddsHandler; ///< Pointer to DDS handler std::shared_ptr m_handlerParticipant; std::shared_ptr m_handlerBuildingData; std::shared_ptr m_db; QHash m_participantFloor; // key = ParicipantId, value= FloorId; QHash m_buildingOwnership; // key BuildingId, Value= Message BuildingOwnership CentralEffectSimulation::LOGGER_T m_logger; }; } // namespace CesBuildings