/** * Block/unblock topics * $Id$ * $HeadURL$ * $Author$ * Created by Christian Ehrlicher, SLSE, 2018-01-15 */ #pragma once #include #include "logger.h" #include "opm_db.h" #include #include #include #include #include namespace OperatorManagement { class MainHandler; class HandlerLockedTopics final : public QObject { Q_OBJECT public: explicit HandlerLockedTopics(MainHandler &mainHandler, QObject *parent = nullptr); bool init(); void operatorLoggedIn(int operatorId, int workstationId) { operatorLoggedInOut(operatorId, workstationId); } void operatorLoggedOut(int operatorId) { operatorLoggedInOut(operatorId, 0); } private: // we logged out - unlock all still locked topics (workstationId should be zero then) // we logged in again - unlock all still locked topics which are not for current workstation void operatorLoggedInOut(int operatorId, int workstationId); /// Lock void onTryLockEntityRequest(const rti::core::SampleIdentity &cookie, const Core::TryLockEntityRequest &request); Core::TryLockEntityReply tryLock(const Core::TryLockEntityRequest &request); //Core::TryLockEntityReply tryLockModify(const Core::TryLockEntityRequest &request); /// Unlock void onTryUnlockEntityRequest(const rti::core::SampleIdentity &cookie, const Core::TryUnlockEntityRequest &request); Core::FunctionReply tryUnlock(const Core::TryUnlockEntityRequest &request); //bool removeReleaseOutdatedLock(int topicId); void unlockInDb(const Database::OpmLockedTopics &data); static Database::OpmLockedTopics toDb(const Core::LockedEntityBase &request); bool publishLockedEntity(const Core::LockedEntity &entity); bool removeLockedEntity(int64_t id); //Core::key topicIdToKey(long id); void dumpLockedTopics(int line); private: QHash m_lockedTopics; MainHandler &m_mainHandler; std::shared_ptr m_db; std::unique_ptr m_ftsTryLockEntity; std::unique_ptrm_ftsTryUnlockEntity; std::unique_ptr m_dtsLockedEntity; LOGGER_T m_logger; }; } // namespace OperatorManagement