From 456c977ed6a09ac1a9cc93f8b4e73ea43be88ed7 Mon Sep 17 00:00:00 2001 From: mental Date: Tue, 1 Jul 2008 23:08:09 +0000 Subject: [PATCH] remove "public private" virtual methods from XML::Node --- src/xml/node.h | 9 --------- src/xml/simple-node.cpp | 11 +++++------ src/xml/simple-node.h | 14 +++----------- 3 files changed, 8 insertions(+), 26 deletions(-) diff --git a/src/xml/node.h b/src/xml/node.h index 1b3f18a91..aac2db191 100644 --- a/src/xml/node.h +++ b/src/xml/node.h @@ -103,15 +103,6 @@ public: protected: Node(Node const &) : Anchored() {} - -public: // ideally these should be protected too somehow... - virtual NodeObserver &_subtreeObservers()=0; - virtual void _setParent(Node *parent)=0; - virtual void _setNext(Node *next)=0; - - virtual unsigned _childPosition(Node const &child) const=0; - virtual unsigned _cachedPosition() const=0; - virtual void _setCachedPosition(unsigned position) const=0; }; } diff --git a/src/xml/simple-node.cpp b/src/xml/simple-node.cpp index 3d82eed01..a229c33fe 100644 --- a/src/xml/simple-node.cpp +++ b/src/xml/simple-node.cpp @@ -240,18 +240,18 @@ unsigned SimpleNode::position() const { return _parent->_childPosition(*this); } -unsigned SimpleNode::_childPosition(Node const &child) const { +unsigned SimpleNode::_childPosition(SimpleNode const &child) const { if (!_cached_positions_valid) { unsigned position=0; for ( SimpleNode *sibling = _first_child ; sibling ; sibling = sibling->_next ) { - sibling->_setCachedPosition(position); + sibling->_cached_position = position; position++; } _cached_positions_valid = true; } - return child._cachedPosition(); + return child._cached_position; } Node *SimpleNode::nthChild(unsigned index) { @@ -277,10 +277,9 @@ bool SimpleNode::matchAttributeName(gchar const *partial_name) const { return false; } -void SimpleNode::_setParent(Node *generic_parent) { - SimpleNode *parent = dynamic_cast(generic_parent); +void SimpleNode::_setParent(SimpleNode *parent) { if (_parent) { - _subtree_observers.remove(dynamic_cast(_parent)->_subtree_observers); + _subtree_observers.remove(_parent->_subtree_observers); } _parent = parent; if (parent) { diff --git a/src/xml/simple-node.h b/src/xml/simple-node.h index 1d87c6db1..98d363f34 100644 --- a/src/xml/simple-node.h +++ b/src/xml/simple-node.h @@ -118,20 +118,12 @@ protected: virtual SimpleNode *_duplicate(Document *doc) const=0; -public: // ideally these should be protected somehow... - NodeObserver &_subtreeObservers() { return _subtree_observers; } - void _setParent(Node *parent); - void _setNext(Node *next) { _next = dynamic_cast(next); } - - unsigned _childPosition(Node const &child) const; - unsigned _cachedPosition() const { return _cached_position; } - void _setCachedPosition(unsigned position) const { - _cached_position = position; - } - private: void operator=(Node const &); // no assign + void _setParent(SimpleNode *parent); + unsigned _childPosition(SimpleNode const &child) const; + SimpleNode *_parent; SimpleNode *_next; Document *_document; -- 2.30.2