summaryrefslogtreecommitdiff
path: root/configmgr
diff options
context:
space:
mode:
authorIvo Hinkelmann <ihi@openoffice.org>2007-11-23 13:32:25 +0000
committerIvo Hinkelmann <ihi@openoffice.org>2007-11-23 13:32:25 +0000
commite84f086bc8fdad1034469c836645ed4db09ff3ec (patch)
treee6c55f7a1f11486a696c46d90187c07372a9d7b3 /configmgr
parentb37c6a5241ac0669c59a320e1e0ed235d215a955 (diff)
INTEGRATION: CWS configrefactor01 (1.4.24); FILE MERGED
2007/10/05 14:14:06 mmeeks 1.4.24.3: Issue number: i#82311 Submitted by: mmeeks Reviewed by: mmeeks Cleanups from patch re-review. Improvements to unit-testing framework. 2007/01/11 10:35:34 mmeeks 1.4.24.2: Submitted by: mmeeks Large scale re-factoring, remove fine-grained locking in favor of a simple, single global lock (still in progress). Identify and fix various hot-spots. Remove otherwise empty / non-compiled files. Kill UpdateAccessor 2007/01/08 20:49:00 mmeeks 1.4.24.1: Issue number: Submitted by: mmeeks Substantial configmgr re-factoring #1 ... + remove endless typedef chains + remove custom allocator & associated complexity + remove Pointer, and 'Address' classes
Diffstat (limited to 'configmgr')
-rw-r--r--configmgr/source/tree/nodeaccess.cxx148
1 files changed, 97 insertions, 51 deletions
diff --git a/configmgr/source/tree/nodeaccess.cxx b/configmgr/source/tree/nodeaccess.cxx
index db83445d5f10..e5b2c58bbc71 100644
--- a/configmgr/source/tree/nodeaccess.cxx
+++ b/configmgr/source/tree/nodeaccess.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: nodeaccess.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: obo $ $Date: 2006-09-16 15:21:45 $
+ * last change: $Author: ihi $ $Date: 2007-11-23 14:32:25 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -38,10 +38,6 @@
#include "nodeaccess.hxx"
-#ifndef CONFIGMGR_UPDATEACCESSOR_HXX
-#include "updateaccessor.hxx"
-#endif
-
#ifndef CONFIGMGR_TREEACCESSOR_HXX
#include "treeaccessor.hxx"
#endif
@@ -66,88 +62,138 @@ namespace configmgr
// -----------------------------------------------------------------------------
namespace data
{
- // -------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
- NodeAddress::DataType* NodeAccess::access(NodeAddressType const& _aNodeRef, memory::UpdateAccessor& _rUpdateAccess)
- {
- return static_cast<NodeAddress::DataType*>(_rUpdateAccess.access(_aNodeRef.m_pData));
- }
- // -------------------------------------------------------------------------
-
- NodeAccess getSubnode(NodeAccessRef const & _aParent, NodeAccess::Name const & _aName)
+ NodeAccess getSubnode(NodeAccess const & _aParent, configuration::Name const & _aName)
{
if (GroupNodeAccess::isInstance(_aParent))
{
- return GroupNodeAccess(_aParent).getChildNode(_aName).toNodeAccess();
+ return GroupNodeAccess(_aParent).getChildNode(_aName);
}
else if (SetNodeAccess::isInstance(_aParent))
{
TreeAccessor aElement = SetNodeAccess(_aParent).getElementTree(_aName);
- return aElement.isValid() ? aElement.getRootNode().toNodeAccess() : NodeAccess::emptyNode();
+ return aElement != NULL ? aElement.getRootNode() : NodeAccess(NULL);
}
else
{
OSL_ENSURE( ValueNodeAccess::isInstance(_aParent),"ERROR: Unknown node type");
OSL_ENSURE(!ValueNodeAccess::isInstance(_aParent),"ERROR: Trying to access child of value node");
- return NodeAccess::emptyNode();
+ return NULL;
}
}
- // -------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
- NodeAddress getSubnodeAddress(memory::Accessor const& _aAccess, NodeAddress const & _aNodeAddress, NodeAccess::Name const & _aName)
+ NodeAddress getSubnodeAddress(NodeAddress const & _aNodeAddress, configuration::Name const & _aName)
{
- return getSubnode( NodeAccessRef(&_aAccess,_aNodeAddress), _aName ).address();
+ return getSubnode( NodeAccess(_aNodeAddress), _aName );
}
- // -------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
- NodeAddress getSubnodeAddress(memory::UpdateAccessor& _aAccess, NodeAddress const & _aNodeAddress, NodeAccess::Name const & _aName)
+ SetNodeAddress toSetNodeAddress(NodeAddress const & _aNodeAddr)
{
- memory::Accessor aAccess = _aAccess.accessor();
- return getSubnode( NodeAccessRef(&aAccess,_aNodeAddress), _aName ).address();
+ SetNodeAccess aNodeAccess(_aNodeAddr);
+ return aNodeAccess;
}
- // -------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
- SetNodeAddress toSetNodeAddress(memory::Accessor const & _aAccess, NodeAddress const & _aNodeAddr)
+ GroupNodeAddress toGroupNodeAddress(NodeAddress const & _aNodeAddr)
{
- SetNodeAccess aNodeAccess( NodeAccessRef(&_aAccess,_aNodeAddr) );
- return aNodeAccess.address();
+ GroupNodeAccess aNodeAccess( _aNodeAddr );
+ return aNodeAccess;
}
- // -------------------------------------------------------------------------
- SetNodeAddress toSetNodeAddress(memory::UpdateAccessor & _aAccess, NodeAddress const & _aNodeAddr)
- {
- SetNodeAccess aNodeAccess( NodeAccess(_aAccess.accessor(),_aNodeAddr) );
- return aNodeAccess.address();
- }
- // -------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
+ // GroupNodeAccess ...
+ // -------------------------------------------------------------------------
- GroupNodeAddress toGroupNodeAddress(memory::Accessor const & _aAccess, NodeAddress const & _aNodeAddr)
+ NodeAddress GroupNodeAccess::implGetChild(configuration::Name const& _aName) const
{
- GroupNodeAccess aNodeAccess( NodeAccess(_aAccess,_aNodeAddr) );
- return aNodeAccess.address();
+ using namespace sharable;
+ rtl::OUString aNodeName = _aName.toString();
+
+ GroupNode const & aNode = data();
+ for (Node const * pChild = aNode.getFirstChild();
+ pChild != NULL;
+ pChild = aNode.getNextChild(pChild))
+ {
+ if (pChild->isNamed(aNodeName))
+ {
+ NodeAccess aChildNode(pChild);
+ return aChildNode;
+ }
+ }
+ return NodeAddress();
}
- // -------------------------------------------------------------------------
- GroupNodeAddress toGroupNodeAddress(memory::UpdateAccessor & _aAccess, NodeAddress const & _aNodeAddr)
+ // -------------------------------------------------------------------------
+ // SetNodeAccess ...
+ // -------------------------------------------------------------------------
+
+ TreeAddress SetNodeAccess::implGetElement(configuration::Name const& _aName) const
{
- GroupNodeAccess aNodeAccess( NodeAccess(_aAccess.accessor(),_aNodeAddr) );
- return aNodeAccess.address();
+ using namespace sharable;
+ SetNode const & aNode = data();
+ for (TreeFragment const * pElement = aNode.getFirstElement();
+ pElement != NULL;
+ pElement = aNode.getNextElement(pElement))
+ {
+ if (pElement->isNamed(_aName.toString()))
+ return (TreeAddress)pElement;
+ }
+ return NULL;
}
- // -------------------------------------------------------------------------
+ // -------------------------------------------------------------------------*/
- ValueNodeAddress toValueNodeAddress(memory::Accessor const & _aAccess, NodeAddress const & _aNodeAddr)
+ void SetNodeAccess::addElement(SetNodeAddress _aSetAddress,
+ ElementAddress _aNewElement)
{
- ValueNodeAccess aNodeAccess( NodeAccess(_aAccess,_aNodeAddr) );
- return aNodeAccess.address();
+ using namespace sharable;
+
+ SetNode * pNode = _aSetAddress;
+ OSL_ENSURE(pNode, "ERROR: Trying to add an element to a NULL set node");
+
+ // to do(?): insert sorted - find location here
+ TreeFragment * pElement = _aNewElement;
+ OSL_ENSURE(pElement, "ERROR: Trying to add a NULL element to a set node");
+
+ pElement->header.next = pNode->elements;
+ pElement->header.parent = reinterpret_cast<Node *>(pNode);
+
+ pNode->elements = _aNewElement;
}
- // -------------------------------------------------------------------------
+ // -------------------------------------------------------------------------*/
- ValueNodeAddress toValueNodeAddress(memory::UpdateAccessor & _aAccess, NodeAddress const & _aNodeAddr)
+ TreeAddress SetNodeAccess::removeElement(SetNodeAddress _aSetAddress,
+ configuration::Name const & _aName)
{
- ValueNodeAccess aNodeAccess( NodeAccess(_aAccess.accessor(),_aNodeAddr) );
- return aNodeAccess.address();
+ using namespace sharable;
+
+ SetNode * pNode = _aSetAddress;
+ OSL_ENSURE(pNode, "ERROR: Trying to add an element to a NULL set node");
+
+ TreeAddress aRemoved = NULL;
+
+ List * pLink = & pNode->elements;
+ while( TreeFragment * pElement = reinterpret_cast<TreeFragment *>(*pLink) )
+ {
+ if (pElement->isNamed(_aName.toString()))
+ {
+ aRemoved = *pLink;
+
+ *pLink = pElement->header.next;
+ pElement->header.next = 0;
+ pElement->header.parent = 0;
+
+ break;
+ }
+
+ pLink = & pElement->header.next;
+ }
+
+ return aRemoved;
}
- // -------------------------------------------------------------------------
+
}
// -----------------------------------------------------------------------------
} // namespace configmgr