Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+135
@@ -0,0 +1,135 @@
|
||||
/**
|
||||
* CnrTvcProfileHandler - reads TetraChannel and TvcConfig data from the database and publishes the data to dds,
|
||||
* reacts to TvcConfig related Function topics
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Gerlinde Rudolphus, SLSE, 2017-10-20
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <logger.h>
|
||||
#include <avm_fts.h>
|
||||
#include <avm_db.h>
|
||||
#include <QObject>
|
||||
#include <QVector>
|
||||
#include <QMap>
|
||||
#include <cstdint>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class CnrHandler;
|
||||
class TvcHandler;
|
||||
|
||||
namespace Interface
|
||||
{
|
||||
class Dts;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* New with REGG-4433 is that global Tvc- and CnrConfigs have to be taken into account.
|
||||
* As a consequence, modifying the isGlobal-flag of a Tvc- or CnrConfig might affect the referencing
|
||||
* CnrTvcProfiles. When the isGlobal-flag changes from global to local the Config has to be removed
|
||||
* from all TvcCnrProfiles that to not belong to the same exercise.
|
||||
*
|
||||
* @author Gerlinde Rudolphus, Christian Fröbel
|
||||
*/
|
||||
class CnrTvcProfileHandler final
|
||||
: public QObject
|
||||
, private Interface::Fts::ModifyCnrTvcProfileRequestHandler
|
||||
, private Interface::Fts::RemoveCnrTvcProfileRequestHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CnrTvcProfileHandler(DatabaseInterface *db, Interface::Dts *dts, Interface::Fts *fts, CnrHandler *cnrHandler, TvcHandler *tvcHandler);
|
||||
~CnrTvcProfileHandler();
|
||||
|
||||
bool init();
|
||||
|
||||
private:
|
||||
struct OperatorExerciseKey;
|
||||
|
||||
void onModifyCnrTvcProfileRequest(const rti::core::SampleIdentity &cookie,
|
||||
const CnrTvcProfile &request) override;
|
||||
void onRemoveCnrTvcProfileRequest(const rti::core::SampleIdentity &cookie,
|
||||
const Core::RemoveElementRequest &request) override;
|
||||
|
||||
bool collectAndPublish(const Database::AvmCnrTvcProfile &circuitContainerDb, bool isReload = false);
|
||||
|
||||
Core::FunctionReplyObject createProfile(const CnrTvcProfile &createRequest);
|
||||
Core::FunctionReplyObject modifyProfile(const CnrTvcProfile &modifyRequest);
|
||||
Core::FunctionReplyObject removeProfile(const Core::RemoveElementRequest &request);
|
||||
|
||||
std::vector<Database::AvmCnrTvcProfileData> insert(const std::vector<AudioVideoManagement::CnrTvcProfileData>& circuitsDds, qint64 setId, bool &status);
|
||||
|
||||
void addProfile(const CnrTvcProfile &profile);
|
||||
void removeProfile(int64_t id);
|
||||
void updateProfile(const CnrTvcProfile &profile);
|
||||
|
||||
private slots:
|
||||
void onCnrConfigChanged(const CnrConfig &cnrConfig);
|
||||
void onTvcConfigChanged(const TvcConfig &tvcConfig);
|
||||
|
||||
/** @name DB-Notifications */
|
||||
///@{
|
||||
void onDbDeletedCnrTvcProfile(const QVariant &id);
|
||||
void onDbDeletedCnrTvcProfileData(const QVariant &containerId);
|
||||
///@}
|
||||
|
||||
private:
|
||||
Core::FunctionReplyObject validateRequest(const CnrTvcProfile &request) const;
|
||||
Core::FunctionReplyObject validateRequest(const Core::RemoveElementRequest &request) const;
|
||||
QVector<Database::AvmCnrTvcProfileData> determineInvalidEntries(const QVector<Database::AvmCnrTvcProfileData> &entries, int64_t exerciseId) const;
|
||||
bool isValidCnr(int32_t cnrConfigId, int64_t exerciseId) const;
|
||||
bool isValidTvc(int32_t tvcConfigId, int64_t exerciseId) const;
|
||||
Core::FunctionReplyObject isValidCnr(int32_t cnrConfigId, int64_t exerciseId, int requestId) const;
|
||||
Core::FunctionReplyObject isValidTvc(int32_t tvcConfigId, int64_t exerciseId, int requestId) const;
|
||||
void onConfigChanged(int32_t configId, RadioSystem type);
|
||||
|
||||
/**
|
||||
* We use this Key to make sure that the combination of operator and exercise is unique in the database.
|
||||
*/
|
||||
struct OperatorExerciseKey
|
||||
{
|
||||
OperatorExerciseKey() = default; // QMap requires this -- Argh!!
|
||||
|
||||
explicit OperatorExerciseKey(const Database::AvmCnrTvcProfile &dbEntry)
|
||||
: operatorId(dbEntry.operatorId)
|
||||
, exerciseId(dbEntry.exerciseId)
|
||||
{}
|
||||
|
||||
explicit OperatorExerciseKey(const CnrTvcProfile &profile)
|
||||
: operatorId(profile.operatorId())
|
||||
, exerciseId(profile.exerciseId())
|
||||
{}
|
||||
|
||||
qint64 operatorId{0};
|
||||
qint64 exerciseId{0};
|
||||
|
||||
bool operator==(const OperatorExerciseKey &other) const
|
||||
{
|
||||
if (operatorId != other.operatorId)
|
||||
return false;
|
||||
if (exerciseId != other.exerciseId)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator!=(const OperatorExerciseKey &other) const { return !(*this == other); }
|
||||
};
|
||||
|
||||
DatabaseInterface *m_db;
|
||||
Interface::Dts *m_dts;
|
||||
Interface::Fts *m_fts;
|
||||
CnrHandler *m_cnrHandler;
|
||||
TvcHandler *m_tvcHandler;
|
||||
QMap<qint64, CnrTvcProfile> m_cache; // db-Id -> CnrTvcProfile
|
||||
QVector<OperatorExerciseKey> m_uniqueKeys;
|
||||
LOGGER_T &m_logger;
|
||||
};
|
||||
|
||||
} // namespace AudioVideoManagement
|
||||
Reference in new issue
Block a user