Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+103
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
* TrainingVoiceCommunicationHandler - 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 Hannes Baeuerle, SLSE, 2017-07-25
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <avm_fts.h>
|
||||
#include <avm_db.h>
|
||||
#include "logger.h"
|
||||
#include <QtCore/QObject>
|
||||
#include <QVector>
|
||||
#include <QMap>
|
||||
#include <boost/optional.hpp>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
namespace Interface
|
||||
{
|
||||
class Dts;
|
||||
class Fts;
|
||||
}
|
||||
|
||||
class ExerciseContext;
|
||||
class ActiveExercises;
|
||||
|
||||
class TvcHandler final
|
||||
: public QObject
|
||||
, protected Interface::Fts::ModifyTvcConfigRequestHandler
|
||||
, protected Interface::Fts::RemoveTvcConfigRequestHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TvcHandler(Interface::Dts *dts, Interface::Fts *fts, DatabaseInterface *db, ActiveExercises *activeExercises);
|
||||
~TvcHandler();
|
||||
|
||||
bool init();
|
||||
|
||||
bool hasConfig(int32_t id) const;
|
||||
const TvcConfig &config(int32_t id) const;
|
||||
|
||||
signals:
|
||||
/** Signalled after device_config modifications. */
|
||||
void avDbReloadNeeded();
|
||||
|
||||
/** Only emitted on change, i.e. not on create or remove. */
|
||||
void tvcConfigChanged(const TvcConfig &tvcConfig);
|
||||
|
||||
protected:
|
||||
void onModifyTvcConfigRequest(const rti::core::SampleIdentity &cookie,
|
||||
const ModifyTvcConfigRequest &request) override;
|
||||
void onRemoveTvcConfigRequest(const rti::core::SampleIdentity &cookie,
|
||||
const Core::RemoveElementRequest &request) override;
|
||||
|
||||
private:
|
||||
Database::AvmDeviceConfig toDeviceConfig(const TvcConfig &tvcConfig) const;
|
||||
|
||||
bool isValidChannel(int64_t channelId) const;
|
||||
bool isFreeChannel(const ModifyTvcConfigRequest &request) const;
|
||||
bool isFreeChannel(int32_t channelId, const boost::optional<int> &exerciseId, const boost::optional<int32_t> &excludeId = boost::none) const;
|
||||
|
||||
bool isNameUnique(const ModifyTvcConfigRequest &request) const;
|
||||
bool isNameUnique(const std::string &name, const boost::optional<int> &exerciseId, const boost::optional<int32_t> &excludeId = boost::none) const;
|
||||
|
||||
Core::FunctionReplyObject createTvcConfig(const ModifyTvcConfigRequest &request, const boost::optional<int32_t> &dbId = boost::none);
|
||||
Core::FunctionReplyObject modifyTvcConfig(const ModifyTvcConfigRequest &request);
|
||||
Core::FunctionReplyObject removeTvcConfig(const Core::RemoveElementRequest &request);
|
||||
|
||||
Database::AvmTvcChannel channelById(int32_t id) const;
|
||||
|
||||
private slots:
|
||||
void onContextActivated(const ExerciseContext &context);
|
||||
void onContextDeactivated(const ExerciseContext &context);
|
||||
|
||||
void onDbDeleteAvmTvcConfig(const QVariant &id);
|
||||
|
||||
private:
|
||||
bool isActiveExercise(int exerciseId) const;
|
||||
Core::FunctionReplyObject validateRequest(const ModifyTvcConfigRequest &request);
|
||||
bool checkConstraint(const std::function<bool (const TvcConfig &)> &constraint, const boost::optional<int> &exerciseId, const boost::optional<int32_t> &excludeId) const;
|
||||
QString exerciseList(const TvcConfig &config) const;
|
||||
bool needDeviceConfig(const TvcConfig &config) const;
|
||||
|
||||
class DeviceConfig;
|
||||
|
||||
Interface::Dts *m_dts;
|
||||
Interface::Fts *m_fts;
|
||||
DatabaseInterface *m_db;
|
||||
ActiveExercises *m_activeExercises;
|
||||
QMap<int32_t, TvcConfig> m_cache; // <TvcConfig::id, TvcConfig>
|
||||
QVector<Database::AvmTvcChannel> m_channels;
|
||||
LOGGER_T &m_logger;
|
||||
std::unique_ptr<DeviceConfig> m_deviceConfig;
|
||||
};
|
||||
|
||||
} // namespace AudioVideoManagement
|
||||
Reference in new issue
Block a user