Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+77
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* Calculate the focal point for units based on it's superiors
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2017-09-05
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QFutureWatcher>
|
||||
#include <Core/core.hpp>
|
||||
#include <unordered_map>
|
||||
#include "participant_handler.h"
|
||||
|
||||
class QTimer;
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
|
||||
namespace ParticipantHandling
|
||||
{
|
||||
class UnitPositionCalculator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit UnitPositionCalculator(ParticipantHandler *participantHandler, QObject *parent = nullptr);
|
||||
~UnitPositionCalculator();
|
||||
|
||||
void startCalculation();
|
||||
void stopCalculation(); // also clear all participants
|
||||
void waitForCalculationFinished();
|
||||
|
||||
void onParticipantDeleted(int participantId);
|
||||
void onPositionChanged(int participantId, int64_t positionTime, const Core::GeoPosition &pos);
|
||||
void onSuperiorChanged(int participantId, int superiorId);
|
||||
void onInferiorChanged(int participantId, const std::vector<int> &inferiorIds);
|
||||
|
||||
private:
|
||||
struct CalculatedUnitPosition : public ParticipantManagement::UnitPosition
|
||||
{
|
||||
int superiorId = 0;
|
||||
std::vector<int> inferiorIds;
|
||||
};
|
||||
|
||||
private:
|
||||
CalculatedUnitPosition &getParticipant(int participantId);
|
||||
void calculate();
|
||||
// no const ref - must be a copy since this is running in a different thread
|
||||
using Result = std::vector<CalculatedUnitPosition>;
|
||||
static Result doCalculation(std::unordered_map<int, CalculatedUnitPosition> &participantData,
|
||||
qint64 currentTime,
|
||||
NGL::INGLLogger &logger);
|
||||
static void calculatePosition(int participantId,
|
||||
std::unordered_map<int, CalculatedUnitPosition> &participantData,
|
||||
qint64 currentTime,
|
||||
int level,
|
||||
NGL::INGLLogger &logger,
|
||||
Result &result);
|
||||
|
||||
private Q_SLOTS:
|
||||
void onCalculationDone();
|
||||
|
||||
private:
|
||||
std::unordered_map<int, CalculatedUnitPosition> m_participantData;
|
||||
std::unordered_map<int, CalculatedUnitPosition> m_publishedPositionData;
|
||||
|
||||
QFutureWatcher<Result> m_calculationWatcher;
|
||||
|
||||
ParticipantHandler *m_participantHandler;
|
||||
bool m_bSomethingChangedSinceLastCalculation;
|
||||
QTimer *m_timer;
|
||||
bool m_bRunning;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
} // namespace ParticipantHandling
|
||||
} // namespace ParticipantManagement
|
||||
Reference in new issue
Block a user