Ghislain Fourny has proposed merging 
lp:~zorba-coders/zorba/collection-claim-tree-ownership into lp:zorba.

Requested reviews:
  Till Westmann (tillw)
  Matthias Brantner (matthias-brantner)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/collection-claim-tree-ownership/+merge/98419

Collections can claim ownership of a node they own but that does not have the 
pointer.
-- 
https://code.launchpad.net/~zorba-coders/zorba/collection-claim-tree-ownership/+merge/98419
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/store/naive/collection.cpp'
--- src/store/naive/collection.cpp	2012-03-01 14:22:17 +0000
+++ src/store/naive/collection.cpp	2012-03-20 14:17:20 +0000
@@ -26,6 +26,11 @@
 namespace zorba {
 namespace simplestore {
 
+void Collection::claimOwnership(zorba::simplestore::XmlTree* aTree)
+{
+  aTree->claimedByCollection(this);
+}
+
 void Collection::getIndexes(
     const store::Item* name,
     std::vector<store::Index*>& indexes)

=== modified file 'src/store/naive/collection.h'
--- src/store/naive/collection.h	2012-03-08 18:51:25 +0000
+++ src/store/naive/collection.h	2012-03-20 14:17:20 +0000
@@ -77,6 +77,10 @@
 
   virtual void adjustTreePositions() = 0;
 
+  /**************************** Claim of ownership ****************************/
+
+  virtual void claimOwnership(zorba::simplestore::XmlTree* aTree);
+  
   /***************************** ID Management ********************************/
 
   virtual ulong getId() const = 0;

=== modified file 'src/store/naive/node_items.cpp'
--- src/store/naive/node_items.cpp	2012-03-14 15:28:15 +0000
+++ src/store/naive/node_items.cpp	2012-03-20 14:17:20 +0000
@@ -105,6 +105,16 @@
 /*******************************************************************************
 
 ********************************************************************************/
+void XmlTree::claimedByCollection(Collection* collection)
+{
+  ZORBA_ASSERT(collection != NULL);
+  theCollection = collection;
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
 void XmlTree::setCollection(Collection* collection, xs_integer pos)
 {
   ZORBA_ASSERT(collection == NULL || theCollection == NULL);

=== modified file 'src/store/naive/node_items.h'
--- src/store/naive/node_items.h	2012-03-15 15:30:19 +0000
+++ src/store/naive/node_items.h	2012-03-20 14:17:20 +0000
@@ -180,7 +180,7 @@
   ulong                     theId;
   xs_integer                thePos;
 
-  Collection        * theCollection;
+  Collection              * theCollection;
 
   XmlNode                 * theRootNode;
 
@@ -223,6 +223,13 @@
 
   const Collection* getCollection() const { return theCollection; }
 
+private:
+friend class zorba::simplestore::Collection;
+  // Allows a collection to claim ownership of a node it already owns, but
+  // which does not have the backpointer yet.
+  void claimedByCollection(Collection* coll);
+  
+public:
   void setCollection(Collection* coll, xs_integer pos);
 
   void setPosition(xs_integer pos) { thePos = pos; }

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to