#ifndef NETWORKLIB_CONNECTION_H
#define NETWORKLIB_CONNECTION_H

class Connection : public NetworkObject {
public:
	Connection();
	Connection( Router & a_ , Router & b_ );
	~Connection();

	void SetRouters( Router & a_ , Router & b_ );

	Router & GetA() const;
	Router & GetB() const; 
	
	int GetCapacity() const;
	int GetLoad() const;
	int GetLoadToA() const;
	int GetLoadToB() const;

	// put packet which will send latter by SendOnePacket
	bool PutOnePacketToA( Packet * ); // return false iff full
	bool PutOnePacketToB( Packet * );
	bool PutOnePacket( Router & dest , Packet * );
	Packet * SendOnePacketToA(); // return the packet which was send or 0 if none
	Packet * SendOnePacketToB();
	void RemoveAllPackets();

	bool operator == ( const Connection & other ) const;
	bool operator != ( const Connection & other ) const;

private:

	Router * a;
	Router * b;

	PacketsBuffer * a_to_b_packets_buufer;
	PacketsBuffer * b_to_a_packets_buufer;

	bool is_last_send_to_a_success;
	bool is_last_send_to_b_success;
};

#endif NETWORKLIB_CONNECTION_H