diff options
Diffstat (limited to 'configmgr')
-rw-r--r-- | configmgr/source/treemgr/configset.cxx | 6 | ||||
-rw-r--r-- | configmgr/source/treemgr/nodechangeimpl.cxx | 6 | ||||
-rw-r--r-- | configmgr/source/treemgr/noderef.cxx | 17 | ||||
-rw-r--r-- | configmgr/source/treemgr/roottree.cxx | 12 | ||||
-rw-r--r-- | configmgr/source/treemgr/setnodeimpl.cxx | 6 | ||||
-rw-r--r-- | configmgr/source/treemgr/treeimpl.cxx | 47 | ||||
-rw-r--r-- | configmgr/source/treemgr/treeimpl.hxx | 13 |
7 files changed, 64 insertions, 43 deletions
diff --git a/configmgr/source/treemgr/configset.cxx b/configmgr/source/treemgr/configset.cxx index 6c4de41cae9b..56bfe20eba26 100644 --- a/configmgr/source/treemgr/configset.cxx +++ b/configmgr/source/treemgr/configset.cxx @@ -2,9 +2,9 @@ * * $RCSfile: configset.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: jb $ $Date: 2001-06-20 20:34:36 $ + * last change: $Author: jb $ $Date: 2001-06-21 12:02:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -126,7 +126,7 @@ Name ElementRef::getName() const { if (!isValid()) return Name(); - return m_aTreeHolder->name( m_aTreeHolder->root() ); + return m_aTreeHolder->getRootName(); } //----------------------------------------------------------------------------- // class ElementTree diff --git a/configmgr/source/treemgr/nodechangeimpl.cxx b/configmgr/source/treemgr/nodechangeimpl.cxx index abf39174cfe8..f9fad1e51a75 100644 --- a/configmgr/source/treemgr/nodechangeimpl.cxx +++ b/configmgr/source/treemgr/nodechangeimpl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: nodechangeimpl.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: jb $ $Date: 2001-06-20 20:35:59 $ + * last change: $Author: jb $ $Date: 2001-06-21 12:02:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -315,7 +315,7 @@ void ValueChangeImpl::setTarget(TreeHolder const& aAffectedTree, NodeOffset nPar { OSL_ENSURE(false, "ValueChangeTarget is being set without a name"); NodeChangeImpl::setAffected(aAffectedTree,aAffectedTree->parent(nParentNode)); - m_aName = aAffectedTree->name(nParentNode); + m_aName = aAffectedTree->getNodeName(nParentNode); } } //----------------------------------------------------------------------------- diff --git a/configmgr/source/treemgr/noderef.cxx b/configmgr/source/treemgr/noderef.cxx index 2872bda6ed63..df47b48eacb8 100644 --- a/configmgr/source/treemgr/noderef.cxx +++ b/configmgr/source/treemgr/noderef.cxx @@ -2,9 +2,9 @@ * * $RCSfile: noderef.cxx,v $ * - * $Revision: 1.17 $ + * $Revision: 1.18 $ * - * last change: $Author: jb $ $Date: 2001-06-20 20:31:31 $ + * last change: $Author: jb $ $Date: 2001-06-21 12:02:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -467,9 +467,9 @@ Name Tree::getName(NodeRef const& aNode) const OSL_PRECOND( !isEmpty(), "ERROR: Configuration: Tree operation requires valid tree" ); OSL_PRECOND( !aNode.isValid() || isValidNode(aNode), "ERROR: Configuration: NodeRef does not match tree" ); - if (!aNode.isValid()) return Name(); + if (isEmpty()) return Name(); - return aNode.m_pImpl->name(); + return m_pImpl->getNodeName(aNode.m_nPos); } //----------------------------------------------------------------------------- // class ValueRef @@ -713,10 +713,10 @@ Name Tree::getName(AnyNodeRef const& aNode) const OSL_PRECOND( !isEmpty(), "ERROR: Configuration: Tree operation requires valid tree" ); OSL_PRECOND( !aNode.isValid() || isValidNode(aNode), "ERROR: Configuration: NodeRef does not match tree" ); - if (!aNode.isValid()) return Name(); + if (isEmpty() || !aNode.isValid()) return Name(); if (aNode.isNode()) - return aNode.m_pUsedImpl->name(); + return m_pImpl->getNodeName(aNode.m_nUsedPos); else return aNode.m_sNodeName; @@ -1066,8 +1066,7 @@ Name Tree::getRootName() const OSL_PRECOND( !isEmpty(), "ERROR: Configuration: Tree operation requires a valid Tree"); if (isEmpty()) return Name(); - NodeOffset nRoot = m_pImpl->root(); - return m_pImpl->name(nRoot); + return m_pImpl->getRootName(); } //----------------------------------------------------------------------------- @@ -1760,7 +1759,7 @@ void getAllChildrenHelper(NodeID const& aNode, SubNodeIDList& aList) nOffset = pTreeImpl->findNextChild(nParent,nOffset)) { OSL_ASSERT( pTreeImpl->isValidNode(nOffset) ); - aList.push_back( SubNodeID( aNode, pTreeImpl->name(nOffset)) ); + aList.push_back( SubNodeID( aNode, pTreeImpl->getNodeName(nOffset)) ); } } } diff --git a/configmgr/source/treemgr/roottree.cxx b/configmgr/source/treemgr/roottree.cxx index 25eedd1b9fef..bef4a09a61c4 100644 --- a/configmgr/source/treemgr/roottree.cxx +++ b/configmgr/source/treemgr/roottree.cxx @@ -2,9 +2,9 @@ * * $RCSfile: roottree.cxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: jb $ $Date: 2001-06-20 20:31:31 $ + * last change: $Author: jb $ $Date: 2001-06-21 12:02:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -142,7 +142,7 @@ bool CommitHelper::prepareCommit(TreeChangeList& rChangeList) return false; // find the name and path of the change - Name aRootName(m_pTree->name(m_pTree->root())); + Name aRootName(m_pTree->getRootName()); AbsolutePath aPath = m_pTree->getContextPath(); OSL_ENSURE(aRootName.toString() == pTreeChange->getNodeName(), "ERROR in Commit: Change Name Mismatch"); @@ -160,7 +160,7 @@ void CommitHelper::finishCommit(TreeChangeList& rChangeList) OSL_ENSURE(m_pTree,"INTERNAL ERROR: Nothing to finish without a tree"); // find the name and path of the change - Name aRootName(m_pTree->name(m_pTree->root())); + Name aRootName(m_pTree->getRootName()); AbsolutePath aPath = m_pTree->getContextPath(); OSL_ENSURE(rChangeList.pathToRoot.fullName() == aPath.toString(), "ERROR: FinishCommit cannot handle rebased changes trees"); @@ -175,7 +175,7 @@ void CommitHelper::revertCommit(TreeChangeList& rChangeList) { OSL_ENSURE(m_pTree,"INTERNAL ERROR: Nothing to finish without a tree"); - Name aRootName(m_pTree->name(m_pTree->root())); + Name aRootName(m_pTree->getRootName()); AbsolutePath aPath = m_pTree->getContextPath(); OSL_ENSURE(rChangeList.pathToRoot.fullName() == aPath.toString(), "ERROR: cannot handle rebased changes trees"); @@ -190,7 +190,7 @@ void CommitHelper::failedCommit(TreeChangeList& rChangeList) { OSL_ENSURE(m_pTree,"INTERNAL ERROR: Nothing to finish without a tree"); - Name aRootName(m_pTree->name(m_pTree->root())); + Name aRootName(m_pTree->getRootName()); AbsolutePath aPath = m_pTree->getContextPath(); OSL_ENSURE(rChangeList.pathToRoot.fullName() == aPath.toString(), "ERROR: cannot handle rebased changes trees"); diff --git a/configmgr/source/treemgr/setnodeimpl.cxx b/configmgr/source/treemgr/setnodeimpl.cxx index 6c79d183405b..73dbc5a2eba2 100644 --- a/configmgr/source/treemgr/setnodeimpl.cxx +++ b/configmgr/source/treemgr/setnodeimpl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: setnodeimpl.cxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: jb $ $Date: 2001-06-20 20:43:00 $ + * last change: $Author: jb $ $Date: 2001-06-21 12:02:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -166,7 +166,7 @@ namespace OSL_ENSURE(aTree->nodeCount(), "INTERNAL ERROR: Unexpected empty (!) tree constructed in set node"); OSL_ENSURE(aTree->isValidNode(aTree->root()), "INTERNAL ERROR: Corrupt tree constructed in set node"); - return aTree->name( aTree->root() ); + return aTree->getRootName(); } void CollectElementTrees::handle(ValueNode& rValue) { diff --git a/configmgr/source/treemgr/treeimpl.cxx b/configmgr/source/treemgr/treeimpl.cxx index a7f9a69fd906..732a1d7b66b8 100644 --- a/configmgr/source/treemgr/treeimpl.cxx +++ b/configmgr/source/treemgr/treeimpl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: treeimpl.cxx,v $ * - * $Revision: 1.17 $ + * $Revision: 1.18 $ * - * last change: $Author: jb $ $Date: 2001-06-20 20:44:49 $ + * last change: $Author: jb $ $Date: 2001-06-21 12:02:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -473,7 +473,7 @@ void TreeImpl::recoverFailedCommit(SubtreeChange& rRootChange) void TreeImpl::adjustToChanges(NodeChangesInformation& rLocalChanges, SubtreeChange const& aExternalChange) { - OSL_PRECOND( name(root()).toString() == aExternalChange.getNodeName(), "Name of change does not match actual node" ); + OSL_PRECOND( getRootName().toString() == aExternalChange.getNodeName(), "Name of change does not match actual node" ); TreeDepth nDepth = getAvailableDepth(); @@ -484,7 +484,7 @@ void TreeImpl::adjustToChanges(NodeChangesInformation& rLocalChanges, SubtreeCha void TreeImpl::adjustToChanges(NodeChangesInformation& rLocalChanges, NodeOffset nNode, SubtreeChange const& aExternalChange) { OSL_PRECOND( isValidNode(nNode), "ERROR: Valid node required for adjusting to changes" ); - OSL_PRECOND( name(nNode).toString() == aExternalChange.getNodeName(), "Name of change does not match actual node" ); + OSL_PRECOND( getNodeName(nNode).toString() == aExternalChange.getNodeName(), "Name of change does not match actual node" ); TreeDepth nDepth = remainingDepth(getAvailableDepth(),depthTo(nNode)); @@ -531,7 +531,7 @@ void TreeImpl::doFinishCommit(SubtreeChange& rSubtreeChange, NodeOffset nNode) OSL_ASSERT(isValidNode(nNode)); Node* pNode = node(nNode); - OSL_ENSURE(rSubtreeChange.getNodeName() == name(nNode).toString(), "ERROR: Change name does not match node"); + OSL_ENSURE(rSubtreeChange.getNodeName() == getNodeName(nNode).toString(), "ERROR: Change name does not match node"); if (pNode->isSetNode()) { OSL_ENSURE(rSubtreeChange.isSetNodeChange(),"ERROR: Change type GROUP does not match set"); @@ -555,7 +555,7 @@ void TreeImpl::doRevertCommit(SubtreeChange& rSubtreeChange, NodeOffset nNode) OSL_ASSERT(isValidNode(nNode)); Node* pNode = node(nNode); - OSL_ENSURE(rSubtreeChange.getNodeName() == name(nNode).toString(), "ERROR: Change name does not match node"); + OSL_ENSURE(rSubtreeChange.getNodeName() == getNodeName(nNode).toString(), "ERROR: Change name does not match node"); if (pNode->isSetNode()) { OSL_ENSURE(rSubtreeChange.isSetNodeChange(),"ERROR: Change type GROUP does not match set"); @@ -579,7 +579,7 @@ void TreeImpl::doFailedCommit(SubtreeChange& rSubtreeChange, NodeOffset nNode) OSL_ASSERT(isValidNode(nNode)); Node* pNode = node(nNode); - OSL_ENSURE(rSubtreeChange.getNodeName() == name(nNode).toString(), "ERROR: Change name does not match node"); + OSL_ENSURE(rSubtreeChange.getNodeName() == getNodeName(nNode).toString(), "ERROR: Change name does not match node"); if (pNode->isSetNode()) { OSL_ENSURE(rSubtreeChange.isSetNodeChange(),"ERROR: Change type GROUP does not match set"); @@ -603,7 +603,7 @@ void TreeImpl::doAdjustToChanges(NodeChangesInformation& rLocalChanges, SubtreeC OSL_ASSERT(isValidNode(nNode)); Node* pNode = node(nNode); - OSL_ENSURE(rSubtreeChange.getNodeName() == name(nNode).toString(), "ERROR: Change name does not match node"); + OSL_ENSURE(rSubtreeChange.getNodeName() == getNodeName(nNode).toString(), "ERROR: Change name does not match node"); if (pNode->isSetNode()) { @@ -757,10 +757,27 @@ NodeOffset TreeImpl::parent(NodeOffset nNode) const return node(nNode)->parent(); } //----------------------------------------------------------------------------- +inline // is private +Name TreeImpl::implGetOriginalName(NodeOffset nNode) const +{ + OSL_ASSERT(isValidNode(nNode)); + + return node(nNode)->m_aName; +} +//----------------------------------------------------------------------------- + + +Name TreeImpl::getNodeName(NodeOffset nNode) const +{ + if (nNode == root()) return getRootName(); + + return implGetOriginalName(nNode); +} +//----------------------------------------------------------------------------- -Name TreeImpl::name(NodeOffset nNode) const +Name TreeImpl::getRootName() const { - return node(nNode)->name(); + return implGetOriginalName(root()); } //----------------------------------------------------------------------------- @@ -788,7 +805,7 @@ void TreeImpl::appendPathTo(NodeOffset nNode, Path::Components& rNames) for (; nNode != 0; nNode = parent(nNode) ) { OSL_ENSURE( isValidNode(nNode), "ERROR: Configuration: node has invalid parent"); - rNames.push_back( name(nNode) ); + rNames.push_back( getNodeName(nNode) ); } std::reverse(rNames.begin() + nStart, rNames.end()); } @@ -830,7 +847,7 @@ NodeOffset TreeImpl::findChild(NodeOffset nParent, Name const& aName) const NodeOffset const nAfterLast = nodeCount() + root(); while (++nPos < nAfterLast) { - if(parent(nPos) == nParent && name(nPos) == aName) + if(parent(nPos) == nParent && getNodeName(nPos) == aName) return nPos; } return 0; @@ -1022,7 +1039,7 @@ void ElementTreeImpl::attachTo(ISubtree& rOwningSet, Name const& aElementName) if (m_pOwnedNode) { - OSL_ENSURE(this->name(root()) == aElementName,"ElementTree: Attaching with unexpected element name"); + OSL_ENSURE(this->getRootName() == aElementName,"ElementTree: Attaching with unexpected element name"); m_pOwnedNode->setName(aElementName.toString()); std::auto_ptr<INode> aNode(m_pOwnedNode); @@ -1039,7 +1056,7 @@ void ElementTreeImpl::detachFrom(ISubtree& rOwningSet, Name const& aElementName) OSL_ENSURE(!m_pOwnedNode,"ERROR: Cannot detach a already owned node from a subtree"); if (!m_pOwnedNode) { - OSL_ENSURE(this->name(root()) == aElementName,"ElementTree: Detaching with unexpected element name"); + OSL_ENSURE(this->getRootName() == aElementName,"ElementTree: Detaching with unexpected element name"); std::auto_ptr<INode> aNode( rOwningSet.removeChild(aElementName.toString()) ); OSL_ENSURE(aNode.get(),"ERROR: Detached node not found in the given subtree"); @@ -1066,7 +1083,7 @@ void ElementTreeImpl::releaseTo(std::auto_ptr<INode>& rNewOwner) OSL_ENSURE(m_pOwnedNode,"ERROR: Cannot release a non-owned node"); if (m_pOwnedNode) { - Name aNodeName = node(root())->name(); + Name aNodeName = getRootName(); m_pOwnedNode->setName( aNodeName.toString() ); } diff --git a/configmgr/source/treemgr/treeimpl.hxx b/configmgr/source/treemgr/treeimpl.hxx index a69a49c7bfde..59716e3ad591 100644 --- a/configmgr/source/treemgr/treeimpl.hxx +++ b/configmgr/source/treemgr/treeimpl.hxx @@ -2,9 +2,9 @@ * * $RCSfile: treeimpl.hxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: jb $ $Date: 2001-06-20 20:44:49 $ + * last change: $Author: jb $ $Date: 2001-06-21 12:02:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -160,6 +160,7 @@ namespace configmgr NodeImplHolder m_pSpecificNode; NodeOffset m_nParent; + friend class TreeImpl; // can access the name friend class ElementTreeImpl; // can rename root nodes public: Node(NodeImplHolder const& aSpecificNodeImpl, Name const& aName, NodeOffset nParent); @@ -168,7 +169,6 @@ namespace configmgr NodeOffset parent() const { return m_nParent; } NodeType::Enum getNodeType() const { return m_pSpecificNode->getType(); } - Name name() const { return m_aName; } Attributes attributes() const { return m_pSpecificNode->getAttributes(); } // change management @@ -274,7 +274,11 @@ namespace configmgr <p>PRE: <code>isValidNode(nNode)</code> </p> */ - Name name(NodeOffset nNode) const; + Name getNodeName(NodeOffset nNode) const; + + /** gets the <type>Name</type> of the root node (i.e. of the tree) + */ + Name getRootName() const; /** gets the number of hierarchy levels from the root node to node <var>nNode</var> in this tree @@ -408,6 +412,7 @@ namespace configmgr virtual RootTreeImpl const* doCastToRootTree() const = 0; virtual ElementTreeImpl const* doCastToElementTree() const = 0; + Name implGetOriginalName(NodeOffset nNode) const; virtual void doGetPathRoot(Path::Components& rPath) const = 0; mutable OTreeAccessor m_aOwnLock; |