From 5819b451fd5cb119ab3193aabce51be509d1d947 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Mon, 9 Dec 2019 23:48:25 +1100 Subject: [PATCH] enforce read-only/stateless structure of new rendering system Most if not all Node references are const now, so their state is entirely held in the renderers rather than the Nodes themselves. --- app/node/dependency.cpp | 6 +++--- app/node/dependency.h | 8 ++++---- app/node/input.cpp | 28 +++++++++------------------- app/node/input.h | 30 +++++++++--------------------- 4 files changed, 25 insertions(+), 47 deletions(-) diff --git a/app/node/dependency.cpp b/app/node/dependency.cpp index a8e98fa31..2a33660f0 100644 --- a/app/node/dependency.cpp +++ b/app/node/dependency.cpp @@ -27,19 +27,19 @@ NodeDependency::NodeDependency() : { } -NodeDependency::NodeDependency(Node *node, const TimeRange &range) : +NodeDependency::NodeDependency(const Node *node, const TimeRange &range) : node_(node), range_(range) { } -NodeDependency::NodeDependency(Node *node, const rational &in, const rational &out) : +NodeDependency::NodeDependency(const Node *node, const rational &in, const rational &out) : node_(node), range_(in, out) { } -Node *NodeDependency::node() const +const Node *NodeDependency::node() const { return node_; } diff --git a/app/node/dependency.h b/app/node/dependency.h index eccce1d1f..ab6dbdd28 100644 --- a/app/node/dependency.h +++ b/app/node/dependency.h @@ -30,16 +30,16 @@ class Node; class NodeDependency { public: NodeDependency(); - NodeDependency(Node* node, const TimeRange& range); - NodeDependency(Node* node, const rational& in, const rational &out); + NodeDependency(const Node* node, const TimeRange& range); + NodeDependency(const Node* node, const rational& in, const rational &out); - Node* node() const; + const Node* node() const; const rational& in() const; const rational& out() const; const TimeRange& range() const; private: - Node* node_; + const Node* node_; TimeRange range_; }; diff --git a/app/node/input.cpp b/app/node/input.cpp index 1c7ed085d..0eec3baaf 100644 --- a/app/node/input.cpp +++ b/app/node/input.cpp @@ -55,7 +55,7 @@ QString NodeInput::name() return NodeParam::name(); } -const NodeParam::DataType &NodeInput::data_type() +const NodeParam::DataType &NodeInput::data_type() const { return data_type_; } @@ -65,7 +65,7 @@ void NodeInput::set_data_type(const NodeParam::DataType &type) data_type_ = type; } -NodeOutput *NodeInput::get_connected_output() +NodeOutput *NodeInput::get_connected_output() const { if (!edges_.isEmpty()) { return edges_.first()->output(); @@ -74,7 +74,7 @@ NodeOutput *NodeInput::get_connected_output() return nullptr; } -Node *NodeInput::get_connected_node() +Node *NodeInput::get_connected_node() const { NodeOutput* output = get_connected_output(); @@ -85,7 +85,7 @@ Node *NodeInput::get_connected_node() return nullptr; } -QVariant NodeInput::get_value_at_time(const rational &time) +QVariant NodeInput::get_value_at_time(const rational &time) const { if (is_keyframing()) { if (keyframes_.first().time() >= time) { @@ -231,7 +231,7 @@ void NodeInput::set_value_at_time(const rational &time, const QVariant &value) emit ValueChanged(signal_vc_range.in(), signal_vc_range.out()); } -bool NodeInput::is_keyframing() +bool NodeInput::is_keyframing() const { return keyframing_; } @@ -241,22 +241,12 @@ void NodeInput::set_is_keyframing(bool k) keyframing_ = k; } -bool NodeInput::dependent() -{ - return dependent_; -} - -void NodeInput::set_dependent(bool d) -{ - dependent_ = d; -} - -const QVariant &NodeInput::minimum() +const QVariant &NodeInput::minimum() const { return minimum_; } -bool NodeInput::has_minimum() +bool NodeInput::has_minimum() const { return has_minimum_; } @@ -267,12 +257,12 @@ void NodeInput::set_minimum(const QVariant &min) has_minimum_ = true; } -const QVariant &NodeInput::maximum() +const QVariant &NodeInput::maximum() const { return maximum_; } -bool NodeInput::has_maximum() +bool NodeInput::has_maximum() const { return has_maximum_; } diff --git a/app/node/input.h b/app/node/input.h index 4885833a4..60dafc870 100644 --- a/app/node/input.h +++ b/app/node/input.h @@ -57,7 +57,7 @@ public: * This can be used in conjunction with NodeInput::can_accept_type() to determine whether this parameter can be * connected to it. */ - const DataType& data_type(); + const DataType& data_type() const; void set_data_type(const DataType& type); /** @@ -67,7 +67,7 @@ public: * * The output parameter if connected or nullptr if not */ - NodeOutput* get_connected_output(); + NodeOutput* get_connected_output() const; /** * @brief If this input is connected to an output, retrieve the Node whose output is connected @@ -76,12 +76,12 @@ public: * * The connected Node if connected or nullptr if not */ - Node* get_connected_node(); + Node* get_connected_node() const; /** * @brief Calculate what the stored value should be at a certain time */ - QVariant get_value_at_time(const rational& time); + QVariant get_value_at_time(const rational& time) const; /** * @brief Sets what value should be seen at a specific time @@ -91,31 +91,19 @@ public: /** * @brief Return whether keyframing is enabled on this input or not */ - bool is_keyframing(); + bool is_keyframing() const; /** * @brief Set whether keyframing is enabled on this input or not */ void set_is_keyframing(bool k); - /** - * @brief Return whether the Node is dependent on this input or not - * - * \see set_dependent() - */ - bool dependent(); - - /** - * @brief Set whether the Node is dependent on this input - */ - void set_dependent(bool d); - - const QVariant& minimum(); - bool has_minimum(); + const QVariant& minimum() const; + bool has_minimum() const; void set_minimum(const QVariant& min); - const QVariant& maximum(); - bool has_maximum(); + const QVariant& maximum() const; + bool has_maximum() const; void set_maximum(const QVariant& max); /**