/**************************************************************************

	Link.h													   JJS 11/09/95
	
		part of CONICAL, the Computational Neuroscience Class Library
	
	A Link is a Current between a VSource and a VSink.  Links are
	uni-directional; to create a two-way "Link", use two Links.
	Each Link belongs to the VSink it connects to ; when that VSink
	dies, it destroys all its Links too.

	Unlike a normal Current, a Link's equilibrium potential (E) is
	actually the voltage of the VSource it's linked from.  This is
	implemented by mapping GetE(), SetE(), and GetEG() to the
	appropriate VSource functions.

	Requires:
		Current			-- base class
		VSource.h		-- header file for the VSource class
		
**************************************************************************/

#ifndef LINK_H
#define LINK_H

#include "Current.h"

class Link : public Current
{
  public:
  
	Link( VSource *pFrom, VSink *pTo, real pG=1 )			// constructor
	: Current( pTo, pG ), itsFrom(pFrom) { }

	virtual void SetE( real pV ) { itsFrom->SetV(pV); }

	virtual real GetE(void) const { return itsFrom->GetV(); }	// inspectors
	virtual real GetEG(void) const { return itsFrom->GetV() * G; }

  protected:	
	VSource *itsFrom;
	// note: inherited variable E is neither used nor accessible in a Link
};

#endif
