##// END OF EJS Templates
Creates the variable model...
Alexandre Leroux -
r107:60eef9a674fc
parent child
Show More
@@ -0,0 +1,20
1 #ifndef SCIQLOP_VARIABLE_H
2 #define SCIQLOP_VARIABLE_H
3
4 #include <QString>
5
6 /**
7 * @brief The Variable struct represents a variable in SciQlop.
8 */
9 struct Variable {
10 explicit Variable(const QString &name, const QString &unit, const QString &mission)
11 : m_Name{name}, m_Unit{unit}, m_Mission{mission}
12 {
13 }
14
15 QString m_Name;
16 QString m_Unit;
17 QString m_Mission;
18 };
19
20 #endif // SCIQLOP_VARIABLE_H
@@ -0,0 +1,31
1 #ifndef SCIQLOP_VARIABLEMODEL_H
2 #define SCIQLOP_VARIABLEMODEL_H
3
4 #include <Common/spimpl.h>
5
6 #include <QLoggingCategory>
7
8 Q_DECLARE_LOGGING_CATEGORY(LOG_VariableModel)
9
10 class Variable;
11
12 /**
13 * @brief The VariableModel class aims to hold the variables that have been created in SciQlop
14 */
15 class VariableModel {
16 public:
17 explicit VariableModel();
18
19 /**
20 * Creates a new variable in the model
21 * @param name the name of the new variable
22 * @return the variable if it was created successfully, nullptr otherwise
23 */
24 Variable *createVariable(const QString &name) noexcept;
25
26 private:
27 class VariableModelPrivate;
28 spimpl::unique_impl_ptr<VariableModelPrivate> impl;
29 };
30
31 #endif // SCIQLOP_VARIABLEMODEL_H
@@ -0,0 +1,24
1 #include <Variable/VariableModel.h>
2
3 #include <Variable/Variable.h>
4
5 Q_LOGGING_CATEGORY(LOG_VariableModel, "VariableModel")
6
7 struct VariableModel::VariableModelPrivate {
8 /// Variables created in SciQlop
9 std::vector<std::unique_ptr<Variable> > m_Variables;
10 };
11
12 VariableModel::VariableModel() : impl{spimpl::make_unique_impl<VariableModelPrivate>()}
13 {
14 }
15
16 Variable *VariableModel::createVariable(const QString &name) noexcept
17 {
18 /// @todo For the moment, the other data of the variable is initialized with default values
19 auto variable
20 = std::make_unique<Variable>(name, QStringLiteral("unit"), QStringLiteral("mission"));
21 impl->m_Variables.push_back(std::move(variable));
22
23 return impl->m_Variables.back().get();
24 }
General Comments 0
You need to be logged in to leave comments. Login now