Commits

lo...@4525493e-7705-40b1-a816-d608a930855b  committed 797602f

first implementation

  • Participants
  • Parent commits 3e20e41

Comments (0)

Files changed (4)

File Navigation/DefaultChildColl.h

 #include <vector>
 
 #include "DataModel/ElementLink.h"
+
 #include "Navigation/DefaultWeight.h"
 
+#ifndef DATAMODEL_TOOLS_GENERATEINDEXINGPOLICY_H
+# include "DataModel/tools/GenerateIndexingPolicy.h"
+#endif
+
 ////////////////////////////////////////////////////
 // Navigation of Relational Trees with Parameters //
 ////////////////////////////////////////////////////
 
-template <typename CHILDCONTAINER, typename CHILDPAR>
-struct DefaultChildColl {
+template <typename CONT, typename RPAR>
+struct DefaultChildColl
+{
+  // default container is a vector of (ElementLink,RPAR) pairs
+  typedef std::pair< ElementLink<CONT>, RPAR > value_type;
+  typedef std::vector< typename data >         type;
 
-  // default container is a map
-  //  typedef std::map<const CHILD*, CHILDPAR > type;
-  typedef std::pair< ElementLink<CHILDCONTAINER>, CHILDPAR > data;
-  typedef std::vector< typename data > type;
-  //  typedef std::map< ElementLink<CHILDCONT, CHILDPAR > type;
   // object pointer (key) access 
-  static const typename CHILDCONTAINER::value_type*
-  getChildPtr(typename type::const_iterator iter) 
-  { return *(iter->first); };
+  static const typename CONT::value_type* getChildPtr(typename 
+						      type::const_iterator 
+						      thisIter) 
+  { return *((*thisIter).first); } // note that * operates on an ElementLink!
+
   // relational parameter (data) access
-  static CHILDPAR 
-  getChildPar(typename type::const_iterator iter) 
-  { return iter->second; };
-  // insertion of (key,data) pair
+  static RPAR getChildPar(typename type::const_iterator thisIter) 
+  { return (*thisIter).second; }
+
+  // insertion of ElementLink by object pointer
   static void
-  insert(type& cont, const CHILDCONTAINER& aChildContainer,
-	 const typename CHILDCONTAINER::value_type* aChild, 
-	 const CHILDPAR& aPar=CHILDPAR()) {
-    ElementLink<CHILDCONTAINER> theLink;
+  insert(type& cont, const CONT& aChildContainer,
+	 const typename CONT::value_type* aChild, 
+	 const RPAR& aPar=RPAR()) 
+  {
+    ElementLink<CONT> theLink;
     theLink.toContainedElement(aChildContainer,aChild);
-    data theEntry(theLink,aPar);
+    value_type theEntry(theLink,aPar);
     cont.push_back(theEntry); 
   }
-  // find method implementation
+
+  // insertion of ELementLink by object index
+  static void
+  insert(type& cont, const CONT& aChildContainer,
+	 const typename SG::GenerateIndexingPolicy<CONT>::type::index anIndex,
+	 const RPAR& aPar=RPAR())
+  {
+    ElementLink<CONT> theLink;
+    theLink.toIndexedElement(aChildContainer,anIndex);
+    value_type theEntry(theLink,aPar);
+    cont.push_back(theEntry);
+  }
+
+  // find method implementation for const_iterator
   static typename type::const_iterator 
-  find(const type& cont, const typename CHILDCONTAINER::value_type* aChild)
+  find(const type& cont, const typename CONT::value_type* aChild)
   {
     type::const_iterator firstEntry = cont.begin();
     type::const_iterator lastEntry  = cont.end();
       }
     return firstEntry;
   }
-  //
-  //  { return cont.find(aChild); }
+
+  // find method for iterator
   static typename type::iterator
-  find(type& cont, const typename CHILDCONTAINER::value_type* aChild)
+  find(type& cont, const typename CONT::value_type* aChild)
   {
     type::iterator firstEntry = cont.begin();
     type::iterator lastEntry  = cont.end();
       }
     return firstEntry;
   }  
-  //
-  //  { return cont.find(aChild); } 
+
+  // removal 
+  static bool
+  remove(type& cont, const typename CONT::value_type* aChild)
+  {
+    type::iterator found = find(cont,aChild);
+    if ( found != cont.end() )
+      {
+	cont.erase(found);
+	return true;
+      }
+    else
+      {
+	return false;
+      }
+  }
+
+  // test on containment
+  static bool
+  contains(type& cont, const typename CONT::value_type* aChild)
+  {
+    return find(cont,aChild) != cont.end();
+  }
+
 };
 
 ///////////////////////////////////////////////////////
 // Navigation of Relational Trees without Parameters //
 ///////////////////////////////////////////////////////
 
-template <typename CHILDCONTAINER>
-struct DefaultChildColl<CHILDCONTAINER,
-			typename CHILDCONTAINER::value_type, 
+template <typename CONT>
+struct DefaultChildColl<CONT,
+			typename CONT::value_type, 
 			DefaultWeight> 
 {
   // default container is a vector
-  typedef std::vector< ElementLink<CHILDCONTAINER> > type;
+  typedef std::vector< ElementLink<CONT> > type;
+
   // object pointer access
-  static const typename CHILDCONTAINER::value_type* 
+  static const typename CONT::value_type* 
   getChildPtr(typename type::const_iterator iter) 
   { return *(*iter); }
-  // dummy relational parameter access (actual behaviour controlled by 
-  // DefaultWeight)
+
+  // default weight is dummy
   static DefaultWeight 
   getChildPar(typename type::const_iterator) { return DefaultWeight(); }
-  // insertion of object pointer 
+
+  // insertion of ElementLink by object pointer 
   static void
-  insert(type& cont, const CHILDCONTAINER& aChildContainer,
-	 const typename CHILDCONTAINER::value_type* aChild, 
-	 const DefaultWeight&) {
-    ElementLink<CHILDCONTAINER> theLink;
+  insert(type& cont, const CONT& aChildContainer,
+	 const typename CONT::value_type* aChild, 
+	 const DefaultWeight&) 
+  {
+    ElementLink<CONT> theLink;
     theLink.toContainedElement(aChildContainer,aChild);
     cont.push_back(theLink); 
   }
+
+  // insertion of ElementLink by object index
+  static void
+  insert(type& cont, const CONT& aChildConstainer,
+	 const typename SG::GenerateIndexingPolicy<CONT>::type::index anIndex,
+	 const DefaultWeight&)
+  {
+    ElementLink<CONT> theLink;
+    theLink.toIndexedElement(aChildContainer,aChild);
+    cont.push_back(theLink);
+  }
+    
   // allocation of object pointer in list
   static typename type::const_iterator 
-  find(const type& cont, const typename CHILDCONTAINER::value_type* aChild) 
+  find(const type& cont, const typename CONT::value_type* aChild) 
   {
     type::const_iterator firstEntry = cont.begin();
     type::const_iterator lastEntry  = cont.end();
 	if ( *(*firstEntry) == aChild ) break;
       }
     return firstEntry;
-    //    return std::find(cont.begin(), cont.end(), aChild); 
   }
+
+  //
   static typename type::iterator
-  find(type& cont, const typename CHILDCONTAINER::value_type* aChild) 
+  find(type& cont, const typename CONT::value_type* aChild) 
   {
     type::iterator firstEntry = cont.begin();
     type::iterator lastEntry  = cont.end();
 	if ( *(*firstEntry) == aChild ) break;
       }
     return firstEntry;
-    //    return std::find(cont.begin(),cont.end(),aChild);
+  }
+
+  // removal 
+  static bool
+  remove(type& cont, const typename CONT::value_type* aChild)
+  {
+    type::iterator found = find(cont,aChild);
+    if ( found != cont.end() )
+      {
+	cont.erase(found);
+	return true;
+      }
+    else
+      {
+	return false;
+      }
+  }
+
+  // test on containment
+  static bool
+  contains(type& cont, const typename CONT::value_type* aChild)
+  {
+    return find(cont,aChild) != cont.end();
   }
 };
 #endif

File Navigation/Navigable.h

 //           client request for a given object type. The actual              //
 //           implementation is in Navigable.icc                              //
 //                                                                           //
+//           Template Parameters:                                            //
+//                                                                           //
+//           CONT - container type for given constituent object type. Needs  //
+//                  to provide a value_type declaration and the usual        //
+//                  container access methods. Defaulted to dummy             //
+//                  NavTerminator for terminal nodes in relational tree.     //
+//           RPAR - parameter describing the relation between constituent    //
+//                  and composite object. Needs to provide +,-,+=,-=,=       //
+//                  operators to manage parameter evolution in the           //
+//                  relational tree. Defaulted to dummy parameter            //
+//                  DefaultWeight for trees without parameters.              //
+//           COLL - allows to specify internal storage container. Needs to   //
+//                  provide typical container management like find(),        //
+//                  insert(), iterators... Defaulted to container type       //
+//                  DefaultChildColl<CONT,RPAR>.                             //
+//                  There should be no need to provide an explicite internal //
+//                  container! Be careful when using this parameter!         //
+//                                                                           //
 // Created:  07-Oct-03  Calafiura/Loch/Rajagopalan                           //
 // Update:   18-Dec-03  Loch                                                 //
 //                      - implement ElementLink -> change of template        //
  *         the container of children
  *
  * @author ATLAS Collaboration
- * $Id: Navigable.h,v 1.1.1.1 2004-02-10 18:11:52 lochp Exp $
+ * $Id: Navigable.h,v 1.2 2004-02-11 00:00:39 lochp Exp $
  **/
 
-// package includes
+// package includes for the template
+#include "Navigation/NavigableIterator.h"
 #include "Navigation/INavigable.h"
+#include "Navigation/DefaultWeight.h"
+#include "Navigation/DefaultChildColl.h"
+
+// navigation token management
 #include "Navigation/INavigationToken.h"
 #include "Navigation/NavigationToken.h"
-#include "Navigation/DefaultWeight.h"
-#include "Navigation/DefaultChildColl.h"
 
 // services etc.
 #ifndef DATAMODEL_TOOLS_GENERATEINDEXINGPOLICY_H
 // do-nothing class for Navigation termination implementation
 class NavTerminator{};
 
-template <typename CHILDCONTAINER=NavTerminator, 
-	  typename CHILDPAR=DefaultWeight,
-          typename CHILDCOLL=typename 
-	  DefaultChildColl<CHILDCONTAINER, CHILDPAR>::type >
+template < typename CONT=NavTerminator,
+	   typename RPAR=DefaultWeight,
+           typename COLL=typename DefaultChildColl<CONT, RPAR>::type >     
 class Navigable : virtual public INavigable 
 {
   public:
   // Type definitions //
   //////////////////////
 
-  typedef CHILDCOLL                           child_coll;
+  // internal collection management helper types
+  typedef COLL                                child_coll;
   typedef typename child_coll::iterator       child_iter;
   typedef typename child_coll::const_iterator const_child_iter;
-  typedef typename CHILDCONTAINER::value_type child_type
+
+  // constituent object type
+  typedef typename CONT::value_type           child_type
 
   /////////////////////////////////
   // Constructors and Destructor //
   ////////////////////////////////////////////////////////////////////
 
   // no relational parameters
-  virtual void fillToken(INavigationToken& rTok) const;
+  virtual void fillToken(INavigationToken& navToken) const;
+
   // forwarding of parameters included
-  virtual void fillToken(INavigationToken& rTok, 
-			 const boost::any& parentParm) const;
+  virtual void fillToken(INavigationToken& navToken, 
+			 const boost::any& parentParameter) const;
 
   //////////////////////////////////
   // Add data objects or elements //
   //////////////////////////////////
 
-  // add data object to the Navigable: replaces existing one (FIXME)
-  //  virtual void putDataObj(const CHILD* aChild, 
-  //			  const CHILDPAR& aPar=CHILDPAR());
   // add element to the Navigable: use element pointer (linear search!)
-  void putElement(const CHILDCONTAINER& objCont, 
-		  const child_type* aChild,
-		  const CHILDPAR& aPar=CHILDPAR());
+  void putElement(const CONT&       objectContainer, 
+		  const child_type* constituentObject,
+		  const RPAR&       objectParameter=RPAR());
   // add element to the Navigable: use element index (direct access!)
-  void putElement(const CHILDCONTAINER& objCont, 
-		  typename SG::GenerateIndexingPolicy<CHILDCONTAINER>::type::index_type index,
-		  const CHILDPAR& aPar=CHILDPAR());
+  void putElement(const CONT& objectContainer, 
+		  typename SG::GenerateIndexingPolicy<CONT>::type::index_type
+		  index,
+		  const RPAR& objectParameter=RPAR());
 
   ///////////////////////
   // Data manipulation //
   // check if child is already there  
   bool contains(const child_type* aChild) const;
 
-  // get the associated parameter if any
-  const CHILDPAR& getParameter(const child_type* aChild) const;
+  ////////////////////////////
+  // Access to Constituents //
+  ////////////////////////////
+
+  // public container access: iterators
+  NavigableIterator<typename child_type, COLL>& begin();    
+  NavigableIterator<typename child_type, COLL>& end();
+
+  // public container access: relational parameter retrieval
+  const RPAR& getParameter(const child_type* aChild) const;
 
   ///////////////////////////
   // Protected data access //
   getChildPtr(const_child_iter iter) const;
 
   // get the parameter associated with the child, if any
-  virtual CHILDPAR getChildPar(const_child_iter iter) const;
+  virtual RPAR getChildPar(const_child_iter iter) const;
 
   /////////////////////////////
   // Internal query handling //
 
   private:
 
-  // honoring the query: filling the token if we match the token type
-  virtual void apply(NavigationToken<typename child_type>& 
-		     rTok) const;    // w/o parameters
-  virtual void apply(NavigationToken<typename child_type, 
-		     CHILDPAR>& rTok, // w/  parameters
-		     const CHILDPAR& aPar) const;
+  // honoring the query: filling token if type matches w/o parameter
+  virtual void apply(NavigationToken<typename child_type>& navToken) const;
 
-  ///forwarding the query to children
-  virtual void toKids(INavigationToken& rTok) const;         // w/o parameters
-  virtual void toKids(INavigationToken& rTok,                // w/ parameters
-		      const boost::any& aPar) const;
+  // honoring the query: filling token if type matches w/ parameter
+  virtual void apply(NavigationToken<typename child_type, RPAR>& navToken,
+		     const RPAR& aParameter) const;
+
+  // forwarding the query to constituents: w/o parameter
+  virtual void toKids(INavigationToken& navToken) const;
+
+  // forwarding the query to constituents: w/ parameter 
+  virtual void toKids(INavigationToken& navToken, 
+		      const boost::any& aParameter) const;
 
   ///////////////////////////
   // Internal data storage //

File Navigation/Navigable.icc

+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+//                          Navigable Implementation                         //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////
+//                               Public Methods                              //
+///////////////////////////////////////////////////////////////////////////////
+
 //////////////////////////////
-// Navigable implementation //
+// Constructor & Destructor //
 //////////////////////////////
 
-// constructor
-template <typename CHILDCONTAINER, typename CHILDPAR, typename CHILDCOLL>
-Navigable<CHILDCONTAINER,CHILDPAR,CHILDCOLL>::Navigable() { }
+template <typename CONT, typename RPAR, typename COLL>
+Navigable<CONT,RPAR,COLL>::Navigable() { }
 
 // destructor
-template <typename CHILDCONTAINER, typename CHILDPAR, typename CHILDCOLL>
-Navigable<CHILDCONTAINER,CHILDPAR,CHILDCOLL>::~Navigable() { }
+template <typename CONT, typename RPAR, typename COLL>
+Navigable<CONT,RPAR,COLL>::~Navigable() { }
 
 //////////////////////////////////////////////
 // Navigation query handling w/o parameters //
 //////////////////////////////////////////////
 
-template <typename CHILDCONTAINER, typename CHILDPAR, typename CHILDCOLL>
+template <typename CONT, typename RPAR, typename COLL>
 void 
-Navigable<CHILDCONTAINER, CHILDPAR, CHILDCOLL>::fillToken(INavigationToken& 
-							  token) const
+Navigable<CONT, RPAR, COLL>::fillToken(INavigationToken& navToken) const 
 {
-  // check on request for CHILD type objects
+  // check on request for child_type type objects
   NavigationToken<typename child_type>* pNoWTok = 
-    dynamic_cast< NavigationToken<typename child_type>* > 
-    (&token);
+    dynamic_cast< NavigationToken<typename child_type>* >(&navToken);
 
   // honored: fill children object pointers into token
   if (0 != pNoWTok) 
   else 
     {
       // check if query formulated with parameter type
-      NavigationToken<typename child_type, CHILDPAR>* pWTok = 
-	dynamic_cast< NavigationToken<typename child_type, CHILDPAR>* > 
-	(&token);
+      NavigationToken<typename child_type, RPAR>* pWTok = 
+	dynamic_cast< NavigationToken<typename child_type, RPAR>* >(&navToken);
 
       // honored: fill children object pointers and parameters into token
       if (0 != pWTok) 
 	{
-	  apply(*pWTok, CHILDPAR());
-
+	  apply(*pWTok, RPAR());
 	}
     }
 
   // forward query
-  toKids(token);
+  toKids(navToken);
 }
 
 /////////////////////////////////////////////
 // Navigation query handling w/ parameters //
 /////////////////////////////////////////////
 
-template <typename CHILD, typename CHILDPAR, typename CHILDCOLL>
+template <typename CONT, typename RPAR, typename COLL>
 void 
-Navigable<CHILD, CHILDPAR, CHILDCOLL>::fillToken(INavigationToken& token,
-						 const boost::any& aPar) const 
+Navigable<CONT, RPAR, COLL>::fillToken(INavigationToken& navToken,
+				       const boost::any& aParameter) const 
 {
-  //  cout << "calling weighted fill token" <<endl;
-
   // first check on object type query alone
-  NavigationToken<CHILD>* pNoWTok =
-    dynamic_cast< NavigationToken<CHILD>* > (&token);
+  NavigationToken<typename child_type>* pNoWTok =
+    dynamic_cast< NavigationToken<typename child_type>* >(&navToken);
 
   // honored
   if (0 != pNoWTok) 
   // not this request, check with parameter
   else 
     {
-      NavigationToken<CHILD, CHILDPAR>* pWTok = 
-	dynamic_cast< NavigationToken<CHILD, CHILDPAR>* > (&token);
+      NavigationToken<typename child_type, RPAR>* pWTok = 
+	dynamic_cast< NavigationToken<typename child_type, RPAR>* >(&navToken);
       if (0 != pWTok) 
 	{
-	  apply(*pWTok, boost::any_cast<CHILDPAR>(aPar));
+	  apply(*pWTok, boost::any_cast<RPAR>(aParameter));
 	}
     }
 
   // forward query in any case
-  toKids(token, aPar);
+  toKids(navToken, aParameter);
 }
 
+/////////////////////////
+// Insert Constituents //
+/////////////////////////
+
+// insert by object pointer
+template <typename CONT, typename RPAR, typename COLL>
+void
+Navigable<CONT, RPAR, COLL>::putElement(const CONT& objectContainer,
+					const child_type* constituentObject,
+					const RPAR& objectParameter)
+{
+  DefaultChildColl<CONT, RPAR>::insert(getChildren(), 
+				       objectContainer,
+				       constituentObject,
+				       objectParameter);
+}
+
+// insert by object index
+template <typename CONT, typename RPAR, typename COLL>
+void 
+Navigable<CONT, RPAR, COLL>::putElement(const CONT& objectContainer,
+					typename 
+					SG::GenerateIndexingPolicy<CONT>::type::index_type constituentIndex,
+					const RPAR& /*aPar=CHILDPAR()*/) 
+						  
+{
+  DefaultChildColl<CONT, RPAR>::insert(getChildren(),
+				       objectContainer,
+				       constituentIndex);
+}
+
+////////////////////////////////
+// Object Removal and Finding //
+////////////////////////////////
+
+// remove object
+template<typename CONT, typename RPAR, typename COLL>
+bool
+Navigable<CONT, RPAR, COLL>::remove(const typename child_type* 
+				    constituentObject)
+{
+  return DefaultChildColl<CONT, RPAR>::remove(getChildren(),constituentObject);
+}
+
+// test if object is in internal container
+template<typename CONT, typename RPAR, typename COLL>
+bool
+Navigable<CONT, RPAR, COLL>::contains(const typename child_type*
+				      constituentObject)
+{
+  return DefaultChildColl<CONT, RPAR>::contains(getChildren(),
+						constituentObject);
+}
+
+//////////////////////////
+// Container Operations //
+//////////////////////////
+
+// begin() iterator
+template<typename CONT, typename RPAR, typename COLL>
+NavigableIterator<typename child_type, COLL>&
+Navigable<CONT, RPAR, COLL>::begin()
+{
+  return NavigableIterator(m_children).begin();
+}
+
+// end() iterator
+template<typename CONT, typename RPAR, typename COLL>
+NavigableIterator<typename child_type, COLL>&
+Navigable<CONT, RPAR, COLL>::end()
+{
+  return NavigableIterator(m_children).end();
+}
+
+/////////////////////////
+// Retrieve Parameters //
+/////////////////////////
+
+template<typename CONT, typename RPAR, typename COLL>
+const RPAR&
+Navigable<CONT, RPAR, COLL>::getParameter(const typename 
+					  child_type* constituentObject) const
+{
+  return getChildPar(DefaultChildColl<CONT, RPAR>::find(getChildren(),
+							constituentObject));
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//                         Internally Used Methods                           //
+///////////////////////////////////////////////////////////////////////////////
+
 //////////////////////////
 // Query can be honored //
 //////////////////////////
 
 // fill token with object pointers (no parameters)
-template <typename CHILD, typename CHILDPAR, typename CHILDCOLL>
+template <typename CONT, typename RPAR, typename COLL>
 void 
-Navigable<CHILD, CHILDPAR, CHILDCOLL>::apply(NavigationToken<CHILD>&
-					     rTok) const 
+Navigable<CONT, RPAR, COLL>::apply(NavigationToken<typename child_type>& 
+				   navToken) const
 {
-  //  cout << "calling apply" <<endl;
-
   // loop on children
-  const_child_iter iter(getChildren().begin());
-  const_child_iter iend(getChildren().end());
-  for (; iter != iend; ++iter) {
-    rTok.setObject(getChildPtr(iter));
-  }
+  const_child_iter iCtr(getChildren().begin());
+  const_child_iter iEnd(getChildren().end());
+  for (; iCtr != iEnd; ++iCtr) 
+    {
+      navToken.setObject(getChildPtr(iCtr));
+    }
 }
 
 // fill with parameter
-template <typename CHILD, typename CHILDPAR, typename CHILDCOLL>
+template <typename CONT, typename RPAR, typename COLL>
 void 
-Navigable<CHILD, CHILDPAR, CHILDCOLL>::apply(NavigationToken<CHILD, CHILDPAR>&
-					     rTok, const CHILDPAR& aPar) const 
+Navigable<CONT, RPAR, COLL>::apply(NavigationToken<CONT, RPAR>&
+				   navToken,
+				   const RPAR& aParameter) const 
 {
-  //  cout << "calling apply" <<endl;
-
   // loop children
-  const_child_iter iter(getChildren().begin());
-  const_child_iter iend(getChildren().end());
-  for (; iter != iend; ++iter) {
-    rTok.setObject(getChildPtr(iter), aPar * getChildPar(iter));
-  }
+  const_child_iter iCtr(getChildren().begin());
+  const_child_iter iEnd(getChildren().end());
+  for (; iCtr != iEnd; ++iCtr) 
+    {
+      navToken.setObject(getChildPtr(iCtr), aParameter * getChildPar(iCtr));
+    }
 }
 
 //////////////////////
 //////////////////////
 
 // no parameter
-template <typename CHILD, typename CHILDPAR, typename CHILDCOLL>
+template <typename CONT, typename RPAR, typename COLL>
 void 
-Navigable<CHILD, CHILDPAR, CHILDCOLL>::toKids(INavigationToken& token) const 
+Navigable<CONT, RPAR,COLL>::toKids(INavigationToken& navToken) const 
 {
-  //  cout << "calling toKids" <<endl;
-
   // loop on children
-  const_child_iter iter(getChildren().begin());
-  const_child_iter iend(getChildren().end());
-  for (; iter != iend; ++iter) {
-    //    if (token.pushQuery(*this, *getChildPtr(iter))) 
-    token.trySetObject(getChildPtr(iter)); // navigating inheritance
-    getChildPtr(iter)->fillToken(token);   // forward query
+  const_child_iter iCtr(getChildren().begin());
+  const_child_iter iEnd(getChildren().end());
+  for (; iCtr != iEnd; ++iCtr) {
+    navToken.trySetObject(getChildPtr(iCtr)); // navigating inheritance
+    getChildPtr(iCtr)->fillToken(navToken);   // forward query
   }
 }
 
 // with parameter
-template <typename CHILD, typename CHILDPAR, typename CHILDCOLL>
+template <typename CONT, typename RPAR, typename COLL>
 void 
-Navigable<CHILD, CHILDPAR, CHILDCOLL>::toKids(INavigationToken& token,
-					      const boost::any& aPar) const 
+Navigable<CONT, RPAR, COLL>::toKids(INavigationToken& navToken,
+				    const boost::any& aParameter) const 
 {
-  //  cout << "calling toKids" <<endl;
-
   // loop on children
-  const_child_iter iter(getChildren().begin());
-  const_child_iter iend(getChildren().end());
+  const_child_iter iCtr(getChildren().begin());
+  const_child_iter iEnd(getChildren().end());
   // catch exception thrown by boost::any_cast 
   try {
     // only identical parameter types can be forwarded!
-    CHILDPAR parentWeight(boost::any_cast<CHILDPAR>(aPar));
-    for (; iter != iend; ++iter) 
+    RPAR parentWeight(boost::any_cast<RPAR>(aParameter));
+    for (; iCtr != iEnd; ++iCtr) 
       {
-      //      if (token.pushQuery(*this, *getChildPtr(iter))) 
-	token.trySetObject(getChildPtr(iter),
-			   boost::any(parentWeight * getChildPar(iter)));
-	getChildPtr(iter)->fillToken(token, 
-				   parentWeight * getChildPar(iter)); 
+	navToken.trySetObject(getChildPtr(iCtr),
+			      boost::any(parentWeight * getChildPar(iCtr)));
+	getChildPtr(iCtr)->fillToken(navToken, 
+				     parentWeight * getChildPar(iCtr)); 
       } 
   } catch(...) {
     // parameter type mismatch: terminate parameter forwarding only
-    for (; iter != iend; ++iter) {
-      //      if (token.pushQuery(*this, *getChildPtr(iter))) 
-      getChildPtr(iter)->fillToken(token, aPar); //FIXME no weight?
+    for (; iCtr != iEnd; ++iCtr) {
+      getChildPtr(iCtr)->fillToken(navToken, aParameter); //FIXME no weight?
     }
   }
 }
 ///////////////////////////////////
 
 // access data objects by iterator
-template <typename CHILD, typename CHILDPAR, typename CHILDCOLL>
-const CHILD*
-Navigable<CHILD, CHILDPAR, CHILDCOLL>::getChildPtr(const_child_iter iter) const
+template <typename CONT, typename RPAR, typename COLL>
+const typename child_type*
+Navigable<CONT, RPAR, COLL>::getChildPtr(const_child_iter iter) const
 { 
-  //  cout << "calling getChildPtr" <<endl;
-  return DefaultChildColl<CHILD, CHILDPAR>::getChildPtr(iter); 
+  return DefaultChildColl<CONT, RPAR>::getChildPtr(iter); 
 }
 
 // access relational parameter by iterator
-template <typename CHILD, typename CHILDPAR, typename CHILDCOLL>
-CHILDPAR
-Navigable<CHILD, CHILDPAR, CHILDCOLL>::getChildPar(const_child_iter iter) const
+template <typename CONT, typename RPAR, typename COLL>
+RPAR
+Navigable<CONT, RPAR, COLL>::getChildPar(const_child_iter iter) const
 { 
-  //  cout << "calling getChildPtr" <<endl;
-  return DefaultChildColl<CHILD, CHILDPAR>::getChildPar(iter); 
+  return DefaultChildColl<CONT, RPAR>::getChildPar(iter); 
 }
-
-// insert data objects
-template <typename CHILD, typename CHILDPAR, typename CHILDCOLL>
-void
-Navigable<CHILD, CHILDPAR, CHILDCOLL>::putDataObj(const CHILD* aChild, 
-						  const CHILDPAR& aPar) 
-{
-  DefaultChildColl<CHILD, CHILDPAR>::insert(getChildren(), aChild, aPar);
-}
-
-// insert data element
-template <typename CHILD, typename CHILDPAR, typename CHILDCOLL>
-template <class DOBJCONTAINER>
-void
-Navigable<CHILD, CHILDPAR, CHILDCOLL>::putElement(const 
-						  DOBJCONTAINER* /*dObj*/, 
-						  const CHILD* aChild, 
-						  const CHILDPAR& aPar) 
-{
-  //  to be fixed: just insert data object for the moment
-  DefaultChildColl<CHILD, CHILDPAR>::insert(getChildren(), aChild, aPar);
-}
-
-template <typename CHILD, typename CHILDPAR, typename CHILDCOLL>
-template <class DOBJCONTAINER>
-void 
-Navigable<CHILD, CHILDPAR, CHILDCOLL>::putElement(const 
-						  DOBJCONTAINER* /*dObj*/, 
-						  typename SG::GenerateIndexingPolicy<DOBJCONTAINER>::type::index_type /*index*/,
-						  const CHILDPAR& 
-						  /*aPar=CHILDPAR()*/)
-{
-  // to be fixed: no action in the moment
-}
-
-template <typename CHILD, typename CHILDPAR, typename CHILDCOLL>
-bool
-Navigable<CHILD, CHILDPAR, CHILDCOLL>::remove(const CHILD* aChild)
-{
-  if ( this->contains(aChild) ) 
-    {
-      Navigable<CHILD,CHILDPAR,CHILDCOLL>::child_coll theCollection =
-	this->getChildren();
-      theCollection.erase(DefaultChildColl<CHILD,CHILDPAR>::find(getChildren(),
-								 aChild));
-      return true;
-    }
-  return false;
-}
-
-template <typename CHILD, typename CHILDPAR, typename CHILDCOLL>
-bool
-Navigable<CHILD, CHILDPAR, CHILDCOLL>::
-contains(const CHILD* aChild) const
-{
-  return DefaultChildColl<CHILD, CHILDPAR>::find(getChildren(),aChild) 
-    != getChildren().end() ;
-}

File Navigation/NavigableIterator.h

+#ifndef NAVIGATION_NAVIGABLEITERATOR_H
+#define NAVIGATION_NAVIGABLEITERATOR_H
+
+template <typename CHILD,
+	  typename CHILDCOLL>
+class NavigableIterator
+{
+ public:
+
+  ////////////////////////////////
+  // Constructor and Destructor //
+  ////////////////////////////////
+
+  NavigableIterator(const CHILDCOLL* theCollection)
+    : m_collection(theCollection)
+    { }
+
+  virtual ~NavigableIterator() { };
+
+  //////////////////////
+  // Iterator Methods //
+  //////////////////////
+
+  NavigableIterator& begin()
+    {
+      m_actual = m_collection->begin();
+      return *this;
+    }
+
+  NavigableIterator& end()
+    {
+      m_actual = m_collection->end();
+      return *this;
+    }
+
+  NavigableIterator& next()
+    {
+      if ( m_actual != m_collection->end() )
+	{
+	  m_actual++;
+	}
+      return *this;
+    }
+
+  NavigableIterator& previous()
+    {
+      if ( m_actual != m_collection->begin() )
+	{
+	  m_actual--;
+	}
+      return *this;
+    }
+
+  // operators for advance, setp back and comparisons
+  NavigableIterator& operator++()    { this->next(); }
+  NavigableIterator  operator++(int) { this->next(); }
+  NavigableIterator& operator--()    { this->previous(); }
+  NavigableIterator  operator--(int) { this->previous(); }
+  bool operator==( NavigableIterator<CHILD,CHILDCOLL>& anOtherIterator) const
+    { return m_actual == anOtherIterator.m_actual; }
+  bool operator!=( NavigableIterator<CHILD,CHILDCOLL>& anOtherIterator) const
+    { return !( *this == anOtherIterator ); }
+
+  // operators for value retrieval
+  const CHILD* operator*() const
+    {
+      return ( m_actual != m_collection->end() )
+	? m_collection->getChildPtr(m_actual)
+	: 0;
+    }
+  const CHILD* operator->() const
+    {
+      return m_actual != m_collection->end() 
+	? m_collection->getChildPtr(m_actual)
+	: 0;
+    }
+
+ protected:
+
+  CHILDCOLL::iterator m_actual;
+  CHILDCOLL* m_collection;
+
+};  
+#endif