#ifndef CONFIG_CONNECTION_H
#define CONFIG_CONNECTION_H
#include <string>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include "Connection.h"
#include "Message.h"


/**
 * The config connection is a Connection which reads and write XML commands
 * to and from a configurator.
 */
class ConfigConnection: public Connection<char> {
	public:
		/**
		 * ConfigConnection Constructor, fd is a BufferedFile to
		 * read and write from
		 * */
		ConfigConnection(BufferedFile * fd);
		/**
		 * Is there a message from the config connection?
		 * */
		bool isMessage();
		/**
		 * Sends the ConfigConnection a update of current system status.
		 * Depricated: Currently not being used.
		 * */
    		void update();
		/**
		 * Gets the next message on the queue.
		 * */
		Message * getMessage(); // Gets the current message on the message queue.
		/**
		 * write size bytes of data to the Connection
		 * */
		int write(const char * data, int size);
		/**
		 * Destructor
		 * */
		virtual ~ConfigConnection();
		/**
		 * Is the Connection ready to read w/o blocking?
		 * */
		virtual bool readReady();
		/**
		 * Is the Connection ready to write w/o blocking?
		 * */
		virtual bool writeReady();
		/**
		 * retrieves the current file handle
		 * */
		int getFileHandle();
		/**
		 * returns a string represntation of the type
		 * */
		string getType();
		/**
		 * sets the type of connection.
		 * */
		void setType(string type);
	protected:
		char * buffer; //temp work space.
};
#endif
