diff --git a/core/include/Variable/VariableStates.h b/core/include/Variable/VariableStates.h new file mode 100644 index 0000000..53c4d48 --- /dev/null +++ b/core/include/Variable/VariableStates.h @@ -0,0 +1,43 @@ +#ifndef SCIQLOP_VARIABLESTATES_H +#define SCIQLOP_VARIABLESTATES_H + +#include "CoreGlobal.h" + +#include + +#include +#include + +#include + +using StateData = QVariantMap; +SCIQLOP_REGISTER_META_TYPE(STATEDATA_REGISTRY, StateData) + +/** + * @brief The IVariableState class is the representation interface of a state in which a variable + * may be. It proposes different methods to represent the variable according to its current state + * @sa Variable + */ +struct SCIQLOP_CORE_EXPORT IVariableState { + virtual ~IVariableState() noexcept = default; + + virtual std::unique_ptr clone() const = 0; + + /// @return the data associated with the state + virtual StateData data() const = 0; +}; + +/// Default implementation of @sa IVariableState +class AbstractVariableState : public IVariableState { +public: + /// @sa IVariableState::data() + StateData data() const override; + +protected: + explicit AbstractVariableState(StateData data); + +private: + StateData m_Data; +}; + +#endif // SCIQLOP_VARIABLESTATES_H diff --git a/core/meson.build b/core/meson.build index ea30383..915fcb6 100644 --- a/core/meson.build +++ b/core/meson.build @@ -38,6 +38,7 @@ core_sources = [ 'src/Variable/VariableAcquisitionWorker.cpp', 'src/Variable/VariableSynchronizationGroup.cpp', 'src/Variable/VariableModel.cpp', + 'src/Variable/VariableStates.cpp', 'src/Visualization/VisualizationController.cpp' ] diff --git a/core/src/Variable/VariableStates.cpp b/core/src/Variable/VariableStates.cpp new file mode 100644 index 0000000..bf967c1 --- /dev/null +++ b/core/src/Variable/VariableStates.cpp @@ -0,0 +1,10 @@ +#include "Variable/VariableStates.h" + +AbstractVariableState::AbstractVariableState(StateData data) : m_Data{std::move(data)} +{ +} + +StateData AbstractVariableState::data() const +{ + return m_Data; +}