summaryrefslogtreecommitdiff
path: root/configmgr/source/treecache/cacheline.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'configmgr/source/treecache/cacheline.cxx')
-rw-r--r--configmgr/source/treecache/cacheline.cxx223
1 files changed, 2 insertions, 221 deletions
diff --git a/configmgr/source/treecache/cacheline.cxx b/configmgr/source/treecache/cacheline.cxx
index cfe1ffdc33..044ed13532 100644
--- a/configmgr/source/treecache/cacheline.cxx
+++ b/configmgr/source/treecache/cacheline.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: cacheline.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: ssmith $ $Date: 2002-12-16 12:49:26 $
+ * last change: $Author: hr $ $Date: 2003-03-19 16:19:42 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -90,225 +90,6 @@
namespace configmgr
{
-/* using namespace configuration;
- // =========================================================================
- struct ONodeIdCollector : public NodeAction
- {
- typedef std::set< rtl::OUString, UStringLess > NodeIdSet;
- NodeIdSet ids;
-
- ONodeIdCollector() : ids() { }
-
- virtual void handle(ValueNode const& _rValueNode) { /* not interested in value nodes * / }
- virtual void handle(ISubtree const& _rSubtree) { ids.insert(_rSubtree.getId()); applyToChildren(_rSubtree); }
- };
-
- //==========================================================================
- static
- inline
- INode* findExistingChild(ISubtree* pCurrentParent, Path::Component const & _aName)
- {
- OSL_ASSERT(pCurrentParent);
-
- INode * pChild = pCurrentParent->getChild(_aName.getName().toString());
-
- if (!pChild && !_aName.isSimpleName())
- {
- pChild = pCurrentParent->getChild(_aName.toPathString());
- OSL_ENSURE(!pChild, "TreeData trouble: Existing node found only by composite name");
- }
-
- return pChild;
- }
- //==========================================================================
- static
- inline
- INode* findExistingChild(ISubtree* pCurrentParent, OUString const & _aName)
- {
- OSL_ASSERT(pCurrentParent);
-
- INode * pChild = pCurrentParent->getChild(_aName );
-
- return pChild;
- }
- //==========================================================================
-
- static sal_Int16 childLevel(sal_Int16 _nLevel)
- {
- OSL_ASSERT(0 > ITreeProvider::ALL_LEVELS);
- return (_nLevel > 0) ? _nLevel-1 : _nLevel;
- }
-
- //==========================================================================
- static bool deeper(sal_Int16 lhs, sal_Int16 rhs)
- {
- if (rhs == ITreeProvider::ALL_LEVELS) return false;
- if (lhs == ITreeProvider::ALL_LEVELS) return true;
- return lhs > rhs;
- }
- */
- //==========================================================================
- //= OCompleteTree
- //==========================================================================
- /** completes the cache with missing subelements
- */
-/* class OCompleteTree : private NodeModification
- {
- public:
- typedef sal_Int16 Level;
-
- static bool complete(ISubtree& _rExistingSubtree, ISubtree& _rNewSubtree,
- Level _nNewDepth, Level _nDefaultDepth);
- private:
- OCompleteTree(ISubtree* pSubtree, Level _nParentLevel, Level _nParentDefaultLevel)
- :m_pCacheSubtree(pSubtree)
- ,m_nChildLevel( childLevel(_nParentLevel) )
- ,m_nDefaultLevel( childLevel(_nParentDefaultLevel) )
- {
- OSL_ENSURE(m_pCacheSubtree,"OCompleteTree: Need a tree to complete");
-
- OSL_ENSURE(m_pCacheSubtree->hasId(), "WARNING: Completing subtree without ID");
- }
-
- virtual void handle(ValueNode& _rNode);
- virtual void handle(ISubtree& _rSubtree);
-
- private:
- ISubtree* m_pCacheSubtree;
- sal_Int16 m_nChildLevel;
- sal_Int16 m_nDefaultLevel;
- };
- //----------------------------------------------------------------------
- void OCompleteTree::handle(ValueNode& _rNode)
- {
- OSL_ASSERT(m_pCacheSubtree);
-
- OUString aNodeName = _rNode.getName();
- INode* pChild = m_pCacheSubtree->getChild(aNodeName);
- // only not existing nodes are interesting other should be in the cache
- if (!pChild)
- {
- std::auto_ptr<INode> pNewChild( _rNode.clone() );
-
- pChild = m_pCacheSubtree->addChild(pNewChild);
- }
- else
- {
- OSL_ENSURE(pChild->ISA(ValueNode), "OCompleteTree: Node type mismatch");
- if (ValueNode* pValue = pChild->asValueNode())
- {
- if (m_nDefaultLevel != 0)
- pValue->changeDefault(_rNode.getDefault());
-
- OSL_ENSURE(!m_nChildLevel || pValue->getValue() == _rNode.getValue(),
- "WARNING: Cached value differs from data being spliced");
- }
- }
- }
- //----------------------------------------------------------------------
-
- void OCompleteTree::handle(ISubtree& _rSubtree)
- {
- OSL_ASSERT(m_pCacheSubtree);
-
- OUString aNodeName = _rSubtree.getName();
- INode* pChild = m_pCacheSubtree->getChild(aNodeName);
-
- // now we have different possibilites
- // a.) the node does not exist than clone the subtree and add it to the cache tree
- if (!pChild)
- {
- std::auto_ptr<INode> pNewChild( _rSubtree.clone() );
-
- ISubtree* pChildTree = pNewChild->asISubtree();
-
- OSL_ASSERT(pChildTree);
- OSL_ASSERT(!pChildTree->hasId()); // should be cleared by cloning a subtree
-
- OSL_ENSURE(_rSubtree.hasId() || m_pCacheSubtree->hasId(), "WARNING: OCompleteTree: completing a tree without ID");
- OUString const aTreeId = _rSubtree.hasId() ? _rSubtree.getId() : m_pCacheSubtree->getId();
-
- OIdPropagator::propagateIdToTree(aTreeId, *pChildTree);
-
- pChild = m_pCacheSubtree->addChild(pNewChild);
-
- OSL_ASSERT(pChild && pChild->asISubtree());
- OSL_ENSURE(pChild->asISubtree()->getId()== aTreeId, "OCompleteTree: Tree lost ID while being added");
- }
- else
- {
- ISubtree* pSubTree = pChild->asISubtree();
- OSL_ENSURE(pSubTree, "OCompleteTree::handle : node must be a inner node!");
-
- // b.) the node does exist with level all or greater level -> nothing to do
- // c.) the node does exist but with smaller level
- if (pSubTree)
- {
- complete(*pSubTree, _rSubtree, m_nChildLevel, m_nDefaultLevel);
-
- OSL_ENSURE(pSubTree->hasId(), "OCompleteTree: Completed Tree has no ID");
- }
- // else throw something (?)
- }
- }
- //----------------------------------------------------------------------
- bool OCompleteTree::complete(ISubtree& _rExistingSubtree, ISubtree& _rNewSubtree,
- Level _nNewDepth, Level _nDefaultDepth)
- {
-
- OSL_ENSURE(_rNewSubtree.hasId(),"WARNING: Completing subtree without providing an ID");
-
- Level const nExistingLevels = _rExistingSubtree.getLevel();
- Level const nExistingDefaults = _rExistingSubtree.getDefaultsLevel();
- if (!_rExistingSubtree.hasId())
- {
- // if it has levels, it surely was really loaded (and therefore has an ID)
- OSL_ENSURE(nExistingLevels == 0,"ERROR: Dummy subtree has nonzero levels");
- OSL_ENSURE(nExistingDefaults == 0,"ERROR: Dummy subtree has nonzero default levels");
- OSL_ENSURE(_nNewDepth != 0,"ERROR: Merging default for data that isn't loaded");
-
- // the tree wasn't loaded before
- OSL_ENSURE(!_rExistingSubtree.getElementTemplateName().getLength(),
- "WARNING: Dummy tree has child template");
- OSL_ENSURE(!_rExistingSubtree.getElementTemplateName().getLength() || _rNewSubtree.getElementTemplateName().getLength(),
- "ERROR: Dummy tree with child template replaced by node without child template");
- OSL_ENSURE(_rExistingSubtree.getName() == _rNewSubtree.getName(),
- "ERROR: Dummy tree renamed by completion (?!)");
-
- // bad hack: abuse of assignment operator to update a slice of _rExistingSubtree
- _rExistingSubtree = _rNewSubtree;
-
- // id is copied by assignment (but not by copy ctor)
- OSL_ASSERT(_rExistingSubtree.getId() == _rNewSubtree.getId());
- // _rExistingSubtree.setId(_rNewSubtree.getId();
- }
- else
- {
- OSL_ENSURE(_rExistingSubtree.getName() == _rNewSubtree.getName(),
- "ERROR: Existing tree replaced by node with different name");
-
- OSL_ENSURE(_rExistingSubtree.getElementTemplateName() == _rNewSubtree.getElementTemplateName(),
- "ERROR: Existing tree replaced by node with different child template");
- }
-
- bool bAddingData = deeper(_nNewDepth,nExistingLevels);
- bool bAddingDefaults = deeper(_nDefaultDepth,nExistingDefaults);
- bool bAdding = bAddingData || bAddingDefaults;
-
- if (bAdding)
- {
- // now do it
- OCompleteTree aCompleter(&_rExistingSubtree, _nNewDepth, _nDefaultDepth);
- aCompleter.applyToChildren(_rNewSubtree);
- //_rExistingSubtree.setLevel(_nNewDepth); // don't do it here, as this is recursive
- }
- // else nothing to do (well, we should check/refresh - at least in DEBUG)
-
- OSL_ENSURE(_rExistingSubtree.hasId(), "OCompleteTree: Completed Tree lost ID");
-
- return bAdding; // true only if we actually did something
- }
-*/
// -----------------------------------------------------------------------------
static inline CacheLine::Name implExtractModuleName(CacheLine::Path const& _aConfigPath)
{