94 lines
3.2 KiB
C++
Executable File
94 lines
3.2 KiB
C++
Executable File
/**
|
|
* Handler for player data
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by gr, SLSE, 2017-02-20
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <CentralEffectSimulation/logger.h>
|
|
#include <CentralEffectSimulation/dds_handler.h>
|
|
|
|
#include <CentralEffectSimulation/ces_db.h>
|
|
#include <CentralEffectSimulation/ces_fts.h>
|
|
#include <Buildings/bld_dtc.h>
|
|
#include <CentralEffectSimulation/handler_participant.h>
|
|
#include <CentralEffectSimulation/handler_building_data.h>
|
|
|
|
#include <QtCore/QObject>
|
|
|
|
// 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<CentralEffectSimulation::DdsHandler> &ddsHandler,
|
|
const std::shared_ptr<CentralEffectSimulation::HandlerParticipant> &participantHandler,
|
|
const std::shared_ptr<CentralEffectSimulation::HandlerBuildingData> &buildingDataHandler,
|
|
const std::shared_ptr<CentralEffectSimulation::DatabaseInterface> &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<CentralEffectSimulation::DdsHandler> m_ddsHandler; ///< Pointer to DDS handler
|
|
|
|
std::shared_ptr<CentralEffectSimulation::HandlerParticipant> m_handlerParticipant;
|
|
std::shared_ptr<CentralEffectSimulation::HandlerBuildingData> m_handlerBuildingData;
|
|
std::shared_ptr<CentralEffectSimulation::DatabaseInterface> m_db;
|
|
|
|
QHash <int, int> m_participantFloor; // key = ParicipantId, value= FloorId;
|
|
QHash <int, CentralEffectSimulation::BuildingOwnership> m_buildingOwnership; // key BuildingId, Value= Message BuildingOwnership
|
|
|
|
CentralEffectSimulation::LOGGER_T m_logger;
|
|
|
|
};
|
|
} // namespace CesBuildings
|
|
|