#line 1 "/user/cvsspst/ees1cg/RAVL/RAVL-0.7/Core/Container/Branch/BGraphNode.hh" // This file is part of RAVL, Recognition And Vision Library // Copyright (C) 2001, University of Surrey // This code may be redistributed under the terms of the GNU Lesser // General Public License (LGPL). See the lgpl.licence file for details or // see http://www.gnu.org/copyleft/lesser.html // file-header-ends-here #ifndef RAVL_BGRAPHNODE_HEADER #define RAVL_BGRAPHNODE_HEADER 1 /////////////////////////////////////////////////////////////// //! file="Ravl/Core/Container/Branch/BGraphNode.hh" //! lib=RavlCore //! author="Charles Galambos" //! date="19/2/1997" //! docentry="Ravl.Core.Branch" //! rcsid="$Id: BGraphNode.hh,v 1.1 2002/04/05 12:59:07 craftit Exp $" #include "Ravl/BGraphBase.hh" namespace RavlN { template class BGraphNodeC; template class BGraphEdgeC; template class BGraphC; template class BGraphAdjIterC; //! userlevel=Develop //: BGraph node template class BGraphNodeC : public BGraphNodeBaseC { public: BGraphNodeC(const NT &nData) : BGraphNodeBaseC(), Dat(nData) {} //: Constructor. inline NT &Data() { return Dat; } //: Access data. inline const NT &Data() const { return Dat; } //: Constant access to data. inline IndexC ID() const { return BGraphNodeBaseC::ID(); } //: Get ID of node. inline bool operator==(const BGraphNodeC &oth) const { return oth.ID() == ID(); } //: Are they the same node ? inline BGraphAdjIterC Out(BGraphC &G); //: Get links leaving node. inline BGraphAdjIterC In(BGraphC &G); //: Get links entering node. inline UIntT Hash() const { return ID().V(); } //: Get hash value. private: NT Dat; friend class BGraphC; friend class BGraphEdgeC; friend class BGraphAdjIterC; }; //! userlevel=Normal //: BGraph node handle template class BGraphNodeHC : public BGraphTypesC { public: inline BGraphNodeHC() {} //: Default constructor. inline BGraphNodeHC(BGraphNodeC &annode) : node(annode) {} //: Default constructor. inline BGraphNodeHC(BGraphC &g,BGraphTypesC::NodeHandleT nd) : node(g.NodeObj(nd)) {} //: Default constructor. inline const BGraphNodeHC &operator=(const BGraphNodeHC &oth) { node=oth.node; return *this; } //: Assignment. inline bool IsValid() const { return node.IsValid(); } //: Is handle valid ? inline BGraphNodeC & Node() { return *node; } //: Get Node. inline const BGraphNodeC & Node() const { return *node; } //: Get Node. inline NT &Data() { return node->Data(); } //: Access data. inline const NT &Data() const { return node->Data(); } //: Constant access to data. inline bool operator==(const BGraphNodeHC &oth) const { return node == oth.node; } //: Comparison. inline bool operator==(BGraphTypesC::NodeHandleT oth) const { return node->ID() == oth; } //: Comparison. inline BGraphAdjIterC Out(BGraphC &G); //: Get links leaving node. inline BGraphAdjIterC In(BGraphC &G); //: Get links entering node. inline void Invalidate() { node = 0; } //: Invalidate handle. inline UIntT Hash() const { return (UIntT) node->ID().V(); } //: Get hash value. inline IndexC ID() const { return node->ID(); } //: Get nodes ID. private: SmartPtrC > node; }; } #include "Ravl/BGraph.hh" #include "Ravl/BGraphEdgeIter.hh" namespace RavlN { //////////////////////////////////////////////////////////////////// template inline BGraphAdjIterC BGraphNodeC::Out(BGraphC &G) { return BGraphAdjIterC(G.NodeObj(ID()),Bkw); } template inline BGraphAdjIterC BGraphNodeC::In(BGraphC &G) { return BGraphAdjIterC(G.NodeObj(ID()),Fwd); } //////////////////////////////////////////////////////////////////// template inline BGraphAdjIterC BGraphNodeHC::Out(BGraphC &G) { return BGraphAdjIterC(G.NodeObj(ID()),Bkw); } template inline BGraphAdjIterC BGraphNodeHC::In(BGraphC &G) { return BGraphAdjIterC(G.NodeObj(ID()),Fwd); } } #endif