#line 1 "/user/cvsspst/ees1cg/RAVL/RAVL-0.7/Core/Container/Branch/BGraphEdge.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_BGRAPHEDGE_HEADER #define RAVL_BGRAPHEDGE_HEADER 1 /////////////////////////////////////////////////////////////// //! file="Ravl/Core/Container/Branch/BGraphEdge.hh" //! lib=RavlCore //! author="Charles Galambos" //! date="19/2/1997" //! docentry="Ravl.Core.Branch" //! rcsid="$Id: BGraphEdge.hh,v 1.1 2002/04/05 12:59:07 craftit Exp $" #include "Ravl/BGraphBase.hh" namespace RavlN { template class BGraphNodeC; template class BGraphNodeHC; template class BGraphNodeIterC; template class BGraphEdgeC; template class BGraphAdjIterC; template class BGraphC; //! userlevel=Develop //: BGraph Edge. template class BGraphEdgeC : public BGraphEdgeBaseC { public: BGraphEdgeC(BGraphTypesC::NodeHandleT From,BGraphTypesC::NodeHandleT To,const ET &nDat); // Constructor. inline BGraphTypesC::NodeHandleT Source() const; // Source of edge. // inline const BGraphNodeC &Source() const; // Source of edge. inline BGraphTypesC::NodeHandleT Target() const; // Target of edge. //inline const BGraphNodeC &Target() const ; // Target of edge. ET &Data() { return Dat; } // Access edge data. const ET &Data() const { return Dat; } // Constant access to edge data. NodeHandleT NodeH(Dir Way) const { return BGraphEdgeBaseC::Node(Way); } // Get nodes at ends of edge. bool operator==(const BGraphEdgeC &oth) const { return &oth == this; } // Are they the same edge ? UIntT Hash() const { return BGraphEdgeBaseC::Hash(); } // Get a hash value of this edge private: ET Dat; friend class BGraphC; friend class BGraphAdjIterC; }; //! userlevel=Normal //: BGraph edge handle. template class BGraphEdgeHC { public: BGraphEdgeHC() {} //: Default constructor. BGraphEdgeHC(BGraphEdgeC &anedge) : edge(anedge) {} //: Constructor. bool IsValid() const { return edge.IsValid(); } //: Is handle valid ? BGraphEdgeC & Edge() { return *edge; } //: Get edge. const BGraphEdgeC & Edge() const { return *edge; } //: Get edge. ET &Data() { return edge->Data(); } //: Access data. const ET &Data() const { return edge->Data(); } //: Constant access to data. bool operator==(const BGraphEdgeHC &oth) const { return edge == oth.edge; } //: Comparison. void Invalidate() { edge.SetPtr(0); } //: Invalidate handle. inline BGraphTypesC::NodeHandleT Source() const; //: Get source of link. inline BGraphTypesC::NodeHandleT Target() const; //: Get target of link. inline UIntT Hash() const { return edge->Hash(); } //: Get hash value. private: SmartPtrC > edge; }; } #include "Ravl/BGraphNode.hh" namespace RavlN { //////////////////////////////////////////////////////////////////// template BGraphEdgeC::BGraphEdgeC(BGraphTypesC::NodeHandleT From, BGraphTypesC::NodeHandleT To, const ET &nDat) : BGraphEdgeBaseC(From,To), Dat(nDat) {} template BGraphTypesC::NodeHandleT BGraphEdgeC::Source() const { return Node(Bkw); } template BGraphTypesC::NodeHandleT BGraphEdgeC::Target() const { return Node(Fwd); } ///////////////////////////////////////////////////////// template inline BGraphTypesC::NodeHandleT BGraphEdgeHC::Source() const { return edge->Source(); } template inline BGraphTypesC::NodeHandleT BGraphEdgeHC::Target() const { return edge->Target(); } } #endif