|
|
#ifndef SCIQLOP_VARIABLESYNCHRONIZER_H
|
|
|
#define SCIQLOP_VARIABLESYNCHRONIZER_H
|
|
|
|
|
|
#include "CoreGlobal.h"
|
|
|
|
|
|
#include <Common/spimpl.h>
|
|
|
|
|
|
#include <QLoggingCategory>
|
|
|
#include <QUuid>
|
|
|
|
|
|
#include <memory>
|
|
|
#include <set>
|
|
|
|
|
|
Q_DECLARE_LOGGING_CATEGORY(LOG_VariableSynchronizer)
|
|
|
|
|
|
class Variable;
|
|
|
|
|
|
/**
|
|
|
* @brief The VariableAcquisitionWorker class handles synchronization between variables
|
|
|
*/
|
|
|
class SCIQLOP_CORE_EXPORT VariableSynchronizer : public QObject {
|
|
|
Q_OBJECT
|
|
|
public:
|
|
|
using GroupId = QUuid;
|
|
|
|
|
|
explicit VariableSynchronizer(QObject *parent = 0);
|
|
|
|
|
|
/**
|
|
|
* Adds a synchronization group under the identifier passed as a parameter. If a group with this
|
|
|
* identifier already exists, the method does nothing.
|
|
|
* @param groupId the group identifier
|
|
|
*/
|
|
|
void addGroup(GroupId groupId) noexcept;
|
|
|
|
|
|
/**
|
|
|
* Adds a variable to a synchronization group. If the variable is already registered under
|
|
|
* another group, or the synchronization doesn't exist, the method does nothing
|
|
|
* @param variable the variable to synchronize
|
|
|
* @param groupId the synchronization group identifier
|
|
|
*/
|
|
|
void addVariable(std::shared_ptr<Variable> variable, GroupId groupId) noexcept;
|
|
|
|
|
|
/**
|
|
|
* Removes the synchronization group under the identifier passed as a parameter. If no group
|
|
|
* exists with this identifier, the method does nothing.
|
|
|
* @param groupId the group identifier
|
|
|
*/
|
|
|
void removeGroup(GroupId groupId) noexcept;
|
|
|
|
|
|
/**
|
|
|
* Removes a variable from its synchronization group. If the variable isn't in a synchronization
|
|
|
* group, the method does nothing
|
|
|
* @param variable the variable to desynchronize
|
|
|
*/
|
|
|
void removeVariable(std::shared_ptr<Variable> variable) noexcept;
|
|
|
|
|
|
/// @return the variables in the same group than the variable passed as a parameter (including
|
|
|
/// the variable)
|
|
|
std::set<std::shared_ptr<Variable> >
|
|
|
synchronizedVariables(std::shared_ptr<Variable> variable) const noexcept;
|
|
|
|
|
|
private:
|
|
|
class VariableSynchronizerPrivate;
|
|
|
spimpl::unique_impl_ptr<VariableSynchronizerPrivate> impl;
|
|
|
};
|
|
|
|
|
|
#endif // SCIQLOP_VARIABLESYNCHRONIZER_H
|
|
|
|