Skip to content

Commit

Permalink
remove const property node class
Browse files Browse the repository at this point in the history
  • Loading branch information
phyBrackets committed Jun 21, 2024
1 parent 4f06f9b commit b12adbe
Showing 1 changed file with 0 additions and 58 deletions.
58 changes: 0 additions & 58 deletions src/kdbindings/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,64 +233,6 @@ class PropertyNode : public NodeInterface<PropertyType>
mutable bool m_dirty;
};

template<typename PropertyType>
class ConstPropertyNode : public NodeInterface<PropertyType>
{
public:
explicit ConstPropertyNode(const Property<PropertyType> &property)
: m_parent(nullptr), m_dirty(false), m_property(&property)
{
m_valueChangedHandle = property.valueChanged().connect(&ConstPropertyNode<PropertyType>::markDirty, this);
m_destroyedHandle = property.destroyed().connect(&ConstPropertyNode<PropertyType>::propertyDestroyed, this);
}

// Copy constructor
ConstPropertyNode(const ConstPropertyNode<PropertyType> &other)
: m_parent(nullptr), m_dirty(false), m_property(other.m_property)
{
if (m_property) {
m_valueChangedHandle = m_property->valueChanged().connect(&ConstPropertyNode<PropertyType>::markDirty, this);
m_destroyedHandle = m_property->destroyed().connect(&ConstPropertyNode<PropertyType>::propertyDestroyed, this);
}
}

// Move constructor is deleted to prevent moving a const reference
ConstPropertyNode(ConstPropertyNode<PropertyType> &&) = delete;

virtual ~ConstPropertyNode()
{
m_valueChangedHandle.disconnect();
m_destroyedHandle.disconnect();
}

const PropertyType &evaluate() const override
{
if (!m_property) {
throw PropertyDestroyedError("The Property this node refers to no longer exists!");
}

m_dirty = false;
return m_property->get();
}

void propertyDestroyed()
{
m_property = nullptr;
}

protected:
Dirtyable **parentVariable() override { return &m_parent; }
const bool *dirtyVariable() const override { return &m_dirty; }

private:
const Property<PropertyType> *m_property;
ConnectionHandle m_valueChangedHandle;
ConnectionHandle m_destroyedHandle;

Dirtyable *m_parent;
mutable bool m_dirty;
};

template<typename ResultType, typename Operator, typename... Ts>
class OperatorNode : public NodeInterface<ResultType>
{
Expand Down

0 comments on commit b12adbe

Please sign in to comment.