#ifndef CHANNEL_HEADERFILE
#define CHANNEL_HEADERFILE

#include <list>
#include "Message.h"
#include "Module.h"


#define MAX_BUFFER_LENGTH 100
#define OPEN NULL

using namespace std;

class Channel : public Module  {

	private:

		list<Message*> lInputMsgBufferUp;
		list<Message*> lOutputMsgBufferUp;

		list<Message*> lInputMsgBufferDown;
		list<Message*> lOutputMsgBufferDown;

		unsigned int maxBufferLength;
		unsigned int transferRate;

		void init_channel();

		bool add_msgAtBegin (list<Message*>* buffer, Message* message);
		bool del_msgAtBegin (list<Message*>* buffer);

		bool add_msgAtEnd (list<Message*>* buffer, Message* message);
		bool del_msgAtEnd (list<Message*>* buffer);

	public:
		Channel();
		Channel(const char* name);

		bool set_maxBufferLength(unsigned int maxBufferLength);
		unsigned int get_maxBufferLength();
		
		unsigned int get_avlInputBufferUp();
		unsigned int get_avlOutputBufferUp();
		unsigned int get_avlInputBufferDown();
		unsigned int get_avlOutputBufferDown();

		bool set_transferRate(unsigned int transferRate);
		unsigned int get_transferRate();

		bool send_MsgUp(Message* message);
		bool send_MsgUp(float msg);
		bool send_MsgUp(int msg);
		bool get_MsgUp(float* msg);
		bool get_MsgUp(int* msg);
		bool isThereFloatMsgUp();
		bool isThereIntMsgUp();

		bool send_MsgDown(Message* message);
		bool send_MsgDown(float msg);
		bool send_MsgDown(int msg);
		bool get_MsgDown(float* msg);
		bool get_MsgDown(int* msg);
		bool isThereFloatMsgDown();
		bool isThereIntMsgDown();

		bool trigger();
		bool transferMsgs(list<Message*>* dest_buffer, list<Message*>* src_buffer);

};


#endif
