##// END OF EJS Templates
Clones variable
Alexandre Leroux -
r651:68fdfccdc238
parent child
Show More
@@ -28,6 +28,11 public:
28 28 explicit Variable(const QString &name, const SqpRange &dateTime,
29 29 const QVariantHash &metadata = {});
30 30
31 /// Copy ctor
32 explicit Variable(const Variable &other);
33
34 std::shared_ptr<Variable> clone() const;
35
31 36 QString name() const noexcept;
32 37 void setName(const QString &name) noexcept;
33 38 SqpRange range() const noexcept;
@@ -20,6 +20,15 struct Variable::VariablePrivate {
20 20 {
21 21 }
22 22
23 VariablePrivate(const VariablePrivate &other)
24 : m_Name{other.m_Name},
25 m_Range{other.m_Range},
26 m_Metadata{other.m_Metadata},
27 m_DataSeries{other.m_DataSeries != nullptr ? other.m_DataSeries->clone() : nullptr},
28 m_RealRange{other.m_RealRange}
29 {
30 }
31
23 32 void lockRead() { m_Lock.lockForRead(); }
24 33 void lockWrite() { m_Lock.lockForWrite(); }
25 34 void unlock() { m_Lock.unlock(); }
@@ -67,6 +76,16 Variable::Variable(const QString &name, const SqpRange &dateTime, const QVariant
67 76 {
68 77 }
69 78
79 Variable::Variable(const Variable &other)
80 : impl{spimpl::make_unique_impl<VariablePrivate>(*other.impl)}
81 {
82 }
83
84 std::shared_ptr<Variable> Variable::clone() const
85 {
86 return std::make_shared<Variable>(*this);
87 }
88
70 89 QString Variable::name() const noexcept
71 90 {
72 91 impl->lockRead();
@@ -191,6 +191,10 void VariableController::setTimeController(TimeController *timeController) noexc
191 191 std::shared_ptr<Variable>
192 192 VariableController::cloneVariable(std::shared_ptr<Variable> variable) noexcept
193 193 {
194 // Clones variable
195 auto duplicate = variable->clone();
196
197 return duplicate;
194 198 }
195 199
196 200 void VariableController::deleteVariable(std::shared_ptr<Variable> variable) noexcept
General Comments 0
You need to be logged in to leave comments. Login now