Commits

Anonymous committed 42b97f1

minor fixes

  • Participants
  • Parent commits 9b365f4

Comments (0)

Files changed (3)

File Navigation/Navigable.h

  *         the container of children
  *
  * @author ATLAS Collaboration
- * $Id: Navigable.h,v 1.4 2004-02-23 17:45:48 lochp Exp $
+ * $Id: Navigable.h,v 1.5 2004-03-31 22:44:21 lochp Exp $
  **/
 
 // package includes for the template
 
 // services etc.
 // #include "DataModel/DataVector.h"
-#include "DataModel/ElementLink.h"
+// #include "DataModel/ElementLink.h"
 #ifndef DATAMODEL_TOOLS_GENERATEINDEXINGPOLICY_H
 # include "DataModel/tools/GenerateIndexingPolicy.h"
 #endif
 
   // add element to the Navigable: use element pointer (linear search!)
   //  template<typename OBJT>
-  void putElement(const CONT& objectContainer, 
+  void putElement(const CONT* objectContainer, 
 		  const constituent_type* constituentObject,
 		  const RPAR& objectParameter=RPAR());
   // add element to the Navigable: use element index (direct access!)
-  void putElement(const CONT&          objectContainer,
+  void putElement(const CONT*          objectContainer,
 		  external_index_type& theIndex,
 		  const RPAR&          objectParameter=RPAR());
 
-  // add element to the Navigable: use element link direcly!
-  void putElement(const ElementLink<CONT>* objectLink,
-		  const RPAR&              objectParameter=RPAR());
-
   ///////////////////////
   // Data manipulation //
   ///////////////////////
 
   // remove object from the Navigable
   bool remove(const constituent_type* aConstituent);
-  bool remove(const CONT& objectContainer, external_index_type& theIndex);
+  bool remove(const CONT* objectContainer, external_index_type& theIndex);
 
   // check if constituent is already there  
   bool contains(const constituent_type* aConstituent) const;
-  bool contains(const CONT& objectContainer,
+  bool contains(const CONT* objectContainer,
 		external_index_type& theIndex) const;
 
   ////////////////////////////
 
   // public container access: relational parameter retrieval
   RPAR getParameter(const constituent_type* aConstituent) const;
-  RPAR getParameter(const CONT& objectContainer,
+  RPAR getParameter(const CONT* objectContainer,
 		    external_index_type& theIndex) const;
 
-  RPAR getParameter(const ElementLink<CONT>* theLink) const;
+  //  RPAR getParameter(const ElementLink<CONT>* theLink) const;
 
   // public container access: retrieve ElementLink for given object pointer
-  virtual const ElementLink<CONT>* getElementLink(const constituent_type*
-						  aConstituent) const;
+  const CONT* getContainer(const constituent_type* aConstituent) const;
+  const CONT* getContainer(constituent_const_iter anIter)        const;
+  //  const CONT& getContainer(constituent_iter anIter)              const;
 
   ///////////////////////////
   // Protected data access //
 						    iter) const;
   virtual const constituent_type* getConstituentPtr(constituent_const_iter 
 						    iter) const;
-  virtual const 
-  ElementLink<CONT>* getElementPtr(constituent_const_iter iter) const;
-  virtual const 
-  ElementLink<CONT>* getElementPtr(const constituent_type* aChild) const;
 
   // get the parameter associated with the child, if any
   virtual RPAR getConstituentPar(constituent_iter iter)       const;

File Navigation/Navigable.icc

 template <typename CONT, typename RPAR, typename COLL>
 Navigable<CONT,RPAR,COLL>::~Navigable() { }
 
-//////////////////////////////////////////////
-// Navigation query handling w/o parameters //
-//////////////////////////////////////////////
+	    //////////////////////////////////////////////
+	    // Navigation query handling w/o parameters //
+            //////////////////////////////////////////////
 
 template <typename CONT, typename RPAR, typename COLL>
 void 
   this->toKids(navToken);
 }
 
-/////////////////////////////////////////////
-// Navigation query handling w/ parameters //
-/////////////////////////////////////////////
+	    /////////////////////////////////////////////
+	    // Navigation query handling w/ parameters //
+	    /////////////////////////////////////////////
 
 template <typename CONT, typename RPAR, typename COLL>
 void 
   this->toKids(navToken, aParameter);
 }
 
-/////////////////////////
-// Insert Constituents //
-/////////////////////////
+		      /////////////////////////
+		      // Insert Constituents //
+		      /////////////////////////
 
 // insert by object pointer
 template <typename CONT, typename RPAR, typename COLL>
 void
-Navigable<CONT, RPAR, COLL>::putElement(const CONT&          
-					refObjectContainer,
+Navigable<CONT, RPAR, COLL>::putElement(const CONT*     
+					ptrObjectContainer,
 					const constituent_type* 
 					ptrObject,
 					const RPAR&      
   if ( this->contains(ptrObject) ) this->remove(ptrObject);
   NavigationDefaults::DefaultChildColl<CONT, RPAR>::insert(
 						    this->getConstituents(), 
-						    refObjectContainer,
+						    ptrObjectContainer,
 						    ptrObject,
 						    refParameter
 						           );
 // insert by object index
 template <typename CONT, typename RPAR, typename COLL>
 void 
-Navigable<CONT, RPAR, COLL>::putElement(const CONT& 
-					refObjectContainer,
+Navigable<CONT, RPAR, COLL>::putElement(const CONT*
+					ptrObjectContainer,
 					external_index_type& 
 					refIndex,
 					const RPAR& 
 					refParameter) 
 						  
 {
-  if ( this->contains(refObjectContainer,refIndex) ) 
-    this->remove(refObjectContainer,refIndex);
+  if ( this->contains(ptrObjectContainer,refIndex) ) 
+    this->remove(ptrObjectContainer,refIndex);
   NavigationDefaults::DefaultChildColl<CONT, RPAR>::insert(
 						    this->getConstituents(),
-						    refObjectContainer,
+						    ptrObjectContainer,
 						    refIndex,
 						    refParameter
 						          );
 }
 
-// insert ElementLink to object
-template <typename CONT, typename RPAR, typename COLL>
-void
-Navigable<CONT, RPAR, COLL>::putElement(const ElementLink<CONT>* ptrObjectLink,
-					const RPAR&              refParameter)
-{
-  // help compiler
-  const constituent_type* ptrObject = *ptrObjectlink;
-  if ( this->contains(ptrObject) ) this->remove(*ptrObject);
-  NavigationDefaults::DefaultChildColl<CONT, RPAR>::insert(
-						    this->getConstituents(),
-						    ptrObjectLink,
-						    refParameter
-							   );
-}
-////////////////////////////////
-// Object Removal and Finding //
-////////////////////////////////
+		   ////////////////////////////////
+		   // Object Removal and Finding //
+		   ////////////////////////////////
 
 // remove object by pointer
 template<typename CONT, typename RPAR, typename COLL>
 // remove object by collection index
 template<typename CONT, typename RPAR, typename COLL>
 bool
-Navigable<CONT, RPAR, COLL>::remove( const CONT& refObjectContainer,
+Navigable<CONT, RPAR, COLL>::remove( const CONT* ptrObjectContainer,
 				     external_index_type& refIndex)
 {
-  return this->remove(refObjectContainer[refIndex]);
+  return this->remove((*ptrObjectContainer)[refIndex]);
 }
 
 // test if object is in internal container
 // test if object is in internal container using index in external collection
 template<typename CONT, typename RPAR, typename COLL>
 bool
-Navigable<CONT, RPAR, COLL>::contains( const CONT& refObjectContainer,
+Navigable<CONT, RPAR, COLL>::contains( const CONT* ptrObjectContainer,
 				       external_index_type& 
 				       refIndex) const
 {
-  const constituent_type* ptrObject = refObjectContainer[refIndex]; 
+  const constituent_type* ptrObject = (*ptrObjectContainer)[refIndex]; 
   return this->contains(ptrObject);
 }
 
-//////////////////////////
-// Container Operations //
-//////////////////////////
+		      //////////////////////////
+		      // Container Operations //
+		      //////////////////////////
 
 // begin() iterator
 template<typename CONT, typename RPAR, typename COLL>
   return this->getConstituents().size();
 }
 
-// return ElementLink for given object pointer
-template <typename CONT, typename RPAR, typename COLL>
-const ElementLink<CONT>* 
-Navigable<CONT, RPAR, COLL>::getElementPtr( const constituent_type* 
-					    aChild ) const
+// return reference to original data object container
+template<typename CONT, typename RPAR, typename COLL>
+const CONT*
+Navigable<CONT, RPAR, COLL>::getContainer(const constituent_type* 
+					  aConstituent) const
 {
   return 
-    NavigationDefaults::DefaultChildColl<CONT, RPAR>::getElementPtr( 
-      NavigationDefaults::DefaultChildColl<CONT, RPAR>::find(
-					        this->getConstituents(),
-					                         aChild
-                                                            ));
+    NavigationDefaults::DefaultChildColl<CONT,RPAR>::getContPtr(
+						     this->getConstituents(),
+						     aConstituent
+						              );
 }
 
-// return ElementLink for a given object iterator
 template<typename CONT, typename RPAR, typename COLL>
-const ElementLink<CONT>*
-Navigable<CONT, RPAR, COLL>::getElementPtr( constituent_const_iter
-					    anIter) const
+const CONT*
+Navigable<CONT, RPAR, COLL>::getContainer(constituent_const_iter anIter) const
 {
   return 
-    NavigationDefaults::DefaultChildColl<CONT, RPAR>::getElementPtr(anIter);
+    NavigationDefaults::DefaultChildColl<CONT,RPAR>::getContPtr(anIter);
 }
 
-/////////////////////////
-// Retrieve Parameters //
-/////////////////////////
+		      /////////////////////////
+		      // Retrieve Parameters //
+		      /////////////////////////
 
 // by object pointer
 template<typename CONT, typename RPAR, typename COLL>
 // by collection index
 template<typename CONT, typename RPAR, typename COLL>
 RPAR
-Navigable<CONT, RPAR, COLL>::getParameter(const CONT& refObjectContainer,
+Navigable<CONT, RPAR, COLL>::getParameter(const CONT* ptrObjectContainer,
 					  external_index_type& 
 					  refIndex) const
 {
-  const constituent_type* ptrObject = refObjectContainer[refIndex];
+  const constituent_type* ptrObject = (*ptrObjectContainer)[refIndex];
   return this->getParameter(ptrObject);
 }
 
-// by ElementLink pointer
-template<typename CONT, typename RPAR, typename COLL>
-RPAR
-Navigable<CONT, RPAR, COLL>::getParameter(const ElementLink<CONT>* 
-					  ptrLink) const
-{
-  return 
-    getConstituentPar(
-      NavigationDefaults::DefaultChildColl<CONT, RPAR>::find(getConstituents(),
-							     ptrLink)
-                     );
-}
-
 ///////////////////////////////////////////////////////////////////////////////
 //                         Internally Used Methods                           //
 ///////////////////////////////////////////////////////////////////////////////
 
-//////////////////////////
-// Query can be honored //
-//////////////////////////
+		      //////////////////////////
+		      // Query can be honored //
+		      //////////////////////////
 
 // fill token with object pointers (no parameters)
 template <typename CONT, typename RPAR, typename COLL>
     }
 }
 
-//////////////////////
-// Forwarding query //
-//////////////////////
+			//////////////////////
+			// Forwarding query //
+			//////////////////////
 
 // no parameter
 template <typename CONT, typename RPAR, typename COLL>
   }
 }
 
-///////////////////////////////////
-// Internal data object handling //
-///////////////////////////////////
+		 ///////////////////////////////////
+		 // Internal data object handling //
+		 ///////////////////////////////////
 
 // non-const access data objects by iterator
 template <typename CONT, typename RPAR, typename COLL>

File Navigation/NavigationDefaults.h

 	return (*thisIter).first;
       }
 
+      // container access through iterator
+      static const CONT& getContRef(type_const_iterator thisIter)
+      {
+	return ((*thisIter).first)->getStorableObjectRef();
+      }
+
+      // container access through pointer
+      static const CONT& getContRef(const type& cont, const_child_ptr aChild)
+      {
+	return getContRef(find(cont,aChild));
+      }
+
+      // pointer to container access by iterator
+      static const CONT* getContPtr(type_const_iterator thisIter)
+      {
+	return ((*thisIter).first)->getStorableObjectPointer();
+      }
+
+      // pointer to container access by pointer
+      static const CONT* getContPtr(const type& cont, const_child_ptr aChild)
+      {
+	type_const_iterator found = find(cont,aChild);
+	return found != cont.end()
+	  ? getContPtr(found)
+	  : 0;
+      }
+
       ///////////////////////// Insertion /////////////////////////////////////
 
       // insertion of ElementLink by object pointer
       static void insert(type& cont, 
-			 const CONT& aChildContainer,
+			 const CONT* aChildContainer,
 			 const_child_ptr aChild, 
 			 const RPAR& aPar=RPAR()) 
       {
 	ElementLink<CONT>* theLink = new ElementLink<CONT>();
-	theLink->toContainedElement(aChildContainer,
+	theLink->toContainedElement(*aChildContainer,
 				    ( child_ptr ) aChild );
 	value_type theEntry(theLink,aPar);
 	cont.push_back(theEntry); 
       }
 
       // insertion of ElementLink by object index
-      static void insert(type& cont, const CONT& aChildContainer,
+      static void insert(type& cont, const CONT* aChildContainer,
 			 external_index_type& anIndex,
 			 const RPAR& aPar=RPAR())
       {
 	ElementLink<CONT>* theLink = new ElementLink<CONT>();
-	theLink->toIndexedElement(aChildContainer,anIndex);
+	theLink->toIndexedElement((*aChildContainer),anIndex);
 	value_type theEntry(theLink,aPar);
 	cont.push_back(theEntry);
       }
 	return *thisIter;
       }
 
+      // container access by iterator
+      static const CONT& getContRef(type_const_iterator thisIter)
+      {
+	return (*thisIter)->getStorableObjectRef();
+      }
+
+      // container access by pointer
+      static const CONT& getContRef(const type& cont, const_child_ptr aChild)
+      {
+	return getContRef(find(cont,aChild));
+      }
+
+      // pointer to container access by iterator
+      static const CONT* getContPtr(type_const_iterator thisIter)
+      {
+	return (*thisIter)->getStorableObjectPointer();
+      }
+
+      // pointer to container access by pointer
+      static const CONT* getContPtr(const type& cont, const_child_ptr aChild)
+      {
+	type_const_iterator found = find(cont,aChild);
+	return found != cont.end()
+	  ? getContPtr(found)
+	  : 0;
+      }
+
+
       // insertion of ElementLink by object pointer 
-      static void insert(type& cont, const CONT& aChildContainer,
+      static void insert(type& cont, const CONT* aChildContainer,
 			 const_child_ptr aChild, 
 			 const DefaultWeight&) 
       {
 	ElementLink<CONT>* theLink = new ElementLink<CONT>();
 	// ugly fix!
-	theLink->toContainedElement(aChildContainer,
+	theLink->toContainedElement((*aChildContainer),
 				    ( child_ptr ) aPtr);
 	cont.push_back(theLink); 
       }
 
       // insertion of ElementLink by object index
-      static void insert(type& cont, const CONT& aChildConstainer,
+      static void insert(type& cont, const CONT* aChildConstainer,
 			 const external_index_type& anIndex,
 			 const DefaultWeight&)
       {
 	ElementLink<CONT>* theLink = new ElementLink<CONT>();
-	theLink->toIndexedElement(aChildContainer,aChild);
+	theLink->toIndexedElement((*aChildContainer),aChild);
 	cont.push_back(theLink);
       }