##// END OF EJS Templates
Creates 'state' objects for variables
Alexandre Leroux -
r806:b772d90b0794
parent child
Show More
@@ -0,0 +1,43
1 #ifndef SCIQLOP_VARIABLESTATES_H
2 #define SCIQLOP_VARIABLESTATES_H
3
4 #include "CoreGlobal.h"
5
6 #include <Common/MetaTypes.h>
7
8 #include <memory>
9 #include <tuple>
10
11 #include <QVariantMap>
12
13 using StateData = QVariantMap;
14 SCIQLOP_REGISTER_META_TYPE(STATEDATA_REGISTRY, StateData)
15
16 /**
17 * @brief The IVariableState class is the representation interface of a state in which a variable
18 * may be. It proposes different methods to represent the variable according to its current state
19 * @sa Variable
20 */
21 struct SCIQLOP_CORE_EXPORT IVariableState {
22 virtual ~IVariableState() noexcept = default;
23
24 virtual std::unique_ptr<IVariableState> clone() const = 0;
25
26 /// @return the data associated with the state
27 virtual StateData data() const = 0;
28 };
29
30 /// Default implementation of @sa IVariableState
31 class AbstractVariableState : public IVariableState {
32 public:
33 /// @sa IVariableState::data()
34 StateData data() const override;
35
36 protected:
37 explicit AbstractVariableState(StateData data);
38
39 private:
40 StateData m_Data;
41 };
42
43 #endif // SCIQLOP_VARIABLESTATES_H
@@ -0,0 +1,10
1 #include "Variable/VariableStates.h"
2
3 AbstractVariableState::AbstractVariableState(StateData data) : m_Data{std::move(data)}
4 {
5 }
6
7 StateData AbstractVariableState::data() const
8 {
9 return m_Data;
10 }
@@ -38,6 +38,7 core_sources = [
38 'src/Variable/VariableAcquisitionWorker.cpp',
38 'src/Variable/VariableAcquisitionWorker.cpp',
39 'src/Variable/VariableSynchronizationGroup.cpp',
39 'src/Variable/VariableSynchronizationGroup.cpp',
40 'src/Variable/VariableModel.cpp',
40 'src/Variable/VariableModel.cpp',
41 'src/Variable/VariableStates.cpp',
41 'src/Visualization/VisualizationController.cpp'
42 'src/Visualization/VisualizationController.cpp'
42 ]
43 ]
43
44
General Comments 0
You need to be logged in to leave comments. Login now