/*!
  @header FTEdgeImpl
  @abstract Module of FT
 
  @availability OS X, GNUstep
  @copyright 2004, 2005, 2006 Free Software Foundation, Inc.
  
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA

  <pre>
  -------------------------------------------------------------------------
  Modification history

  31.03.05 ola     initial version
  23.08.06 ola     license changed
  -------------------------------------------------------------------------
  </pre>
*/

#if !defined(__FTEdgeImpl_H)
#define __FTEdgeImpl_H

#include <Foundation/Foundation.h>
#include <FT/FTObject.h>
#include <FT/FTEdge.h>
#include <FT/FTNode.h>

@class FTGraphImpl;

/*!
 * @class FTEdgeImpl
 * @abstract Implementation of the FTEdge protocol
 */
@interface FTEdgeImpl : FTObject <FTEdge, NSCoding> {
  @private
    id <FTId> edgeId;
    id <FTId> targetNodeId;
    id <FTId> sourceNodeId;
    
    /**
     * Dangerous: Here we use a weak reference:
     */
    FTGraphImpl *graph;
}

/*!
 * @method initWithCode
 * @abstract initializer called by deserialization process
 * @param decoder to use
 * @result self
 */
- (id) initWithCoder:(NSCoder *) decoder;


/*!
 * @method initWithEdgeId
 * @param anId id for this edge
 * @param aTargetNode node to point to
 * @param aSourceNode source node
 * @param graph underlying graph instance
 * @result self
 */
- initWithEdgeId: (id <FTId>) anId targetNode: (id <FTNode>) aTargetNode
  sourceNode: (id <FTNode>) aSourceNode forGraph: (FTGraphImpl *) aGraph;
  
- (void) dealloc;


/*!
 * @method description
 * @result information about the state of this object
 */
- (NSString *) description;


/*!
 * @method edgeId
 * @result id of this instance
 */
- (id <FTId>) edgeId;


/*!
 * @method encodeWithCoder
 * @abstract Is being called in order to serialize this instance
 * @param encoder object to be used for serialization
 */
- (void) encodeWithCoder: (NSCoder *) encoder;


/*!
 * @method hash
 * @result Returns an integer that can be used as a table address in a hash 
 * table structure
 */
- (unsigned) hash;


/*!
 * @method isEqual
 * @result Returns YES if the receiver and anObject are equal, NO otherwise
 */
- (BOOL) isEqual: (id)anObject;


/*!
 * @method sourceNode
 * @result source node of this edge
 */
- (id <FTNode>) sourceNode;


/*!
 * @method sourceNodeId
 * @result id of the source node
 */
- (id <FTId>) sourceNodeId;



/*!
 * @method targetNode
 * @result node to which this edge points to
 */
- (id <FTNode>) targetNode;


/*!
 * @method targetNodeId
 * @result id of target node
 */
- (id <FTId>) targetNodeId;

@end
#endif
