summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörg Barfurth <jb@openoffice.org>2000-11-09 14:11:17 +0000
committerJörg Barfurth <jb@openoffice.org>2000-11-09 14:11:17 +0000
commit38bb28053c8e13d18b5b96ecdc7f3a162b81cd7e (patch)
treea2056aad1e3caf36e1d1e6ce5e139cb6aeec6264
parent6de6a93606cb52ee4f0f9428ec48a5b6dd0d058f (diff)
Fixed problem with TreeImpl lock initialization
-rw-r--r--configmgr/source/treemgr/roottreeimpl.hxx14
-rw-r--r--configmgr/source/treemgr/treeimpl.cxx107
-rw-r--r--configmgr/source/treemgr/treeimpl.hxx35
3 files changed, 69 insertions, 87 deletions
diff --git a/configmgr/source/treemgr/roottreeimpl.hxx b/configmgr/source/treemgr/roottreeimpl.hxx
index 7bc7446ec486..91d17142ddd7 100644
--- a/configmgr/source/treemgr/roottreeimpl.hxx
+++ b/configmgr/source/treemgr/roottreeimpl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: roottreeimpl.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: jb $ $Date: 2000-11-07 14:35:59 $
+ * last change: $Author: jb $ $Date: 2000-11-09 15:11:17 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -64,7 +64,6 @@
#include "treeimpl.hxx"
-#include "treeaccess.hxx"
#include "synchronize.hxx"
namespace configmgr
@@ -90,18 +89,9 @@ namespace configmgr
ISubtree& rCacheTree, TreeDepth nDepth,
NodeOffset nRoot = 1);
- // ISynchronizedData
- void acquireReadAccess() const;
- void releaseReadAccess() const;
- void acquireWriteAccess();
- void releaseWriteAccess();
-
- ISynchronizedData* getRootLock();
private:
virtual RootTreeImpl const* doCastToRootTree() const;
virtual ElementTreeImpl const* doCastToElementTree() const;
- private:
- mutable OTreeAccessor m_aTreeLock;
};
//-----------------------------------------------------------------------------
}
diff --git a/configmgr/source/treemgr/treeimpl.cxx b/configmgr/source/treemgr/treeimpl.cxx
index 209d782d8946..8d59ac72c0ba 100644
--- a/configmgr/source/treemgr/treeimpl.cxx
+++ b/configmgr/source/treemgr/treeimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: treeimpl.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: jb $ $Date: 2000-11-07 14:35:59 $
+ * last change: $Author: jb $ $Date: 2000-11-09 15:11:17 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -518,8 +518,49 @@ NodeOffset TreeImpl::findChild(NodeOffset nParent, Name const& aName) const
}
return 0;
}
+
+//-----------------------------------------------------------------------------
+// locking
+//-----------------------------------------------------------------------------
+ISynchronizedData* TreeImpl::getRootLock()
+{
+ if ( m_pParentTree )
+ return m_pParentTree->getRootLock();
+ else
+ return this;
+}
+
+ISynchronizedData const* TreeImpl::getRootLock() const
+{
+ if ( m_pParentTree )
+ return m_pParentTree->getRootLock();
+ else
+ return this;
+}
+
//-----------------------------------------------------------------------------
+void TreeImpl::acquireReadAccess() const
+{
+ m_aOwnLock.acquireReadAccess();
+}
+//-----------------------------------------------------------------------------
+void TreeImpl::releaseReadAccess() const
+{
+ m_aOwnLock.releaseReadAccess();
+}
+//-----------------------------------------------------------------------------
+void TreeImpl::acquireWriteAccess()
+{
+ m_aOwnLock.acquireWriteAccess();
+}
+//-----------------------------------------------------------------------------
+void TreeImpl::releaseWriteAccess()
+{
+ m_aOwnLock.releaseWriteAccess();
+}
+
+//-----------------------------------------------------------------------------
// dynamic-casting
//-----------------------------------------------------------------------------
@@ -590,38 +631,10 @@ RootTreeImpl::RootTreeImpl( NodeFactory& rNodeFactory,
ISubtree& rCacheNode, TreeDepth nDepth,
NodeOffset nRoot)
: TreeImpl(aContextPath,nRoot)
-, m_aTreeLock()
{
TreeImpl::build(rNodeFactory,rCacheNode,nDepth);
}
//-----------------------------------------------------------------------------
-
-void RootTreeImpl::acquireReadAccess() const
-{
- m_aTreeLock.acquireReadAccess();
-}
-//-----------------------------------------------------------------------------
-void RootTreeImpl::releaseReadAccess() const
-{
- m_aTreeLock.releaseReadAccess();
-}
-//-----------------------------------------------------------------------------
-void RootTreeImpl::acquireWriteAccess()
-{
- m_aTreeLock.acquireWriteAccess();
-}
-//-----------------------------------------------------------------------------
-void RootTreeImpl::releaseWriteAccess()
-{
- m_aTreeLock.releaseWriteAccess();
-}
-//-----------------------------------------------------------------------------
-ISynchronizedData* RootTreeImpl::getRootLock()
-{
- return this;
-}
-
-//-----------------------------------------------------------------------------
// class ElementTreeImpl
//-----------------------------------------------------------------------------
@@ -736,10 +749,6 @@ void ElementTreeImpl::renameTree(Name const& aNewName)
void ElementTreeImpl::moveTree(TreeImpl* pParentTree, NodeOffset nParentNode)
{
TreeImpl::setContext(pParentTree,nParentNode);
- if (pParentTree)
- {
- m_pLockImpl = pParentTree->getRootLock();
- }
}
//-----------------------------------------------------------------------------
@@ -748,36 +757,6 @@ void ElementTreeImpl::detachTree()
TreeImpl::clearContext();
}
//-----------------------------------------------------------------------------
-void ElementTreeImpl::acquireReadAccess() const
-{
- m_pLockImpl->acquireReadAccess();
-}
-//-----------------------------------------------------------------------------
-void ElementTreeImpl::releaseReadAccess() const
-{
- m_pLockImpl->releaseReadAccess();
-}
-//-----------------------------------------------------------------------------
-void ElementTreeImpl::acquireWriteAccess()
-{
- m_pLockImpl->acquireWriteAccess();
-}
-//-----------------------------------------------------------------------------
-void ElementTreeImpl::releaseWriteAccess()
-{
- m_pLockImpl->releaseWriteAccess();
-}
-//-----------------------------------------------------------------------------
-
-//-----------------------------------------------------------------------------
-ISynchronizedData* ElementTreeImpl::getRootLock()
-{
- return m_pLockImpl;
-}
-//void ElementTreeImpl::commit()
-//{
-//}
-//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
} // namespace configuration
diff --git a/configmgr/source/treemgr/treeimpl.hxx b/configmgr/source/treemgr/treeimpl.hxx
index 479024c70df0..82cb36c853fa 100644
--- a/configmgr/source/treemgr/treeimpl.hxx
+++ b/configmgr/source/treemgr/treeimpl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: treeimpl.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: jb $ $Date: 2000-11-07 14:35:59 $
+ * last change: $Author: jb $ $Date: 2000-11-09 15:11:17 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -68,6 +68,7 @@
#include "nodefactory.hxx"
#include "configpath.hxx"
#include "template.hxx"
+#include "treeaccess.hxx"
#include <vos/ref.hxx>
#include <vos/refernce.hxx>
@@ -96,6 +97,7 @@ namespace configmgr
class Node;
class NodeRef;
+ class NodeID;
class Tree;
class TreeImpl;
struct NodeFactory;
@@ -174,7 +176,7 @@ namespace configmgr
<p> Also provides for navigation to the context this tree is located in
</p>
*/
- class TreeImpl : public vos::OReference , public ISynchronizedData
+ class TreeImpl : public vos::OReference, private ISynchronizedData
{
public:
/// the type of the internal list of <type>Node</type>
@@ -306,7 +308,17 @@ namespace configmgr
ElementTreeImpl * asElementTree();
ElementTreeImpl const* asElementTree() const;
- virtual ISynchronizedData* getRootLock() = 0;
+
+ // synchronization
+ ISynchronizedData* getRootLock();
+ ISynchronizedData const* getRootLock() const;
+
+ private:
+ // ISynchronizedData
+ void acquireReadAccess() const;
+ void releaseReadAccess() const;
+ void acquireWriteAccess();
+ void releaseWriteAccess();
private:
virtual RootTreeImpl const* doCastToRootTree() const = 0;
virtual ElementTreeImpl const* doCastToElementTree() const = 0;
@@ -320,6 +332,8 @@ namespace configmgr
void implCollectChangesFrom(NodeOffset nNode, NodeChanges& rChanges) const;
void implCommitChangesFrom(NodeOffset nNode);
+ mutable OTreeAccessor m_aOwnLock;
+
NodeList m_aNodes;
AbsolutePath m_aContextPath;
TreeImpl* m_pParentTree;
@@ -384,19 +398,12 @@ namespace configmgr
/// set no-parent context for this tree
void detachTree();
- // ISynchronizedData
- void acquireReadAccess() const;
- void releaseReadAccess() const;
- void acquireWriteAccess();
- void releaseWriteAccess();
- ISynchronizedData* getRootLock();
private:
virtual RootTreeImpl const* doCastToRootTree() const;
virtual ElementTreeImpl const* doCastToElementTree() const;
private:
TemplateHolder const m_aInstanceInfo;
INode* m_pOwnedNode;
- ISynchronizedData* m_pLockImpl;
};
//-----------------------------------------------------------------------------
inline
@@ -477,6 +484,12 @@ namespace configmgr
static
NodeOffset offset(NodeRef const& aNode);
+ static
+ TreeImpl* tree(NodeID const& aNodeID);
+
+ static
+ NodeOffset offset(NodeID const& aNodeID);
+
};
//-----------------------------------------------------------------------------
}