#ifndef SERVICE_HPP
#define SERVICE_HPP

#include "Response.hpp"
#include "Request.hpp"

namespace mole {
    namespace ctx {
	class Client;
    }
}

namespace mole {

    namespace serv {

	/**
	 * A service is an action that a client can ask to a server.
	 * A request is used to communicate between client & server, into the
	 * service.
	 * It is possible to have for one service many kinds of requests
	 * available.
	 * Notice that input arguments are stored into the service, and output
	 * args are into the request, after the execution.
	 */
	class Service {

	    public :

		/**
		 * Constructs a service with a specific request.
		 *
		 * @param req The request to use into the service.
		 */
		Service(mole::ctx::Request *);

		Service();

		~Service();

		/**
		 * Execute the service. There is no return value, cause the
		 * service has to treat argument with the help of the request.
		 */
		virtual bool execute(mole::ctx::Client *);

		/**
		 * Returns the response as an object.
		 */
		Response * getResponse();

		/**
		 * Affects a response to the service.
		 */
		void setResponse(Response * r){ response = r;};
		
		/*
		 * Returns the request associated to the client.
		 * Useful to parameter the service invocation.
		 */
		mole::ctx::Request * getRequest();

		virtual Service * newInvocableService(mole::ctx::Request * r);

	    protected :
		/* The request linked to the service. */
		mole::ctx::Request * request;

		/* The response filled after the request execution */
		Response * response;

	    private :

	};

    }; // end of namespace mole

}; // end of namespace serv

#endif

