#ifndef SERVER_HPP
#define SERVER_HPP

#include <string>
#include "ServiceFactory.hpp"

namespace mole {
  
  namespace ctx {
    
    /**
     * A generic & abstract server, which only stores informations for
     * the connection into it.
     */
    class Server {
      
    public :
      
      /**
       * Constructs a server, with informations in parameters.
       *
       * @param ip Server ip
       * @param port Server port
       * @param path Entry point in the server
       */
      Server(std::string ip, unsigned int port, std::string path);

      Server();

      ~Server();
      
      /**
       * Accessors (inline)
       */
      std::string getIp(){ return ip; }
      
      std::string getPath(){ return path; }
      
      unsigned int getPort(){ return port; }

      /**
       * Setters.
       */
      void setIp(std::string);
      
      void setPort(unsigned int);
      
      void setPath(std::string);
      
      /**
       * Gets a service from the server. It use the factory member.
       * The service is attributed to a client.
       *
       * @param name Name of the service.
       * @param client The client who ask for the service.
       * @return The requested service.
       */
      mole::serv::Service * getService(std::string name);
      
      /**
       * Gets the service manager. Useful to register services.
       */
      mole::serv::ServiceFactory * getServiceFactory();

      void addService(std::string, mole::serv::Service *);
      
    protected :
      /** A server use a factory, which registers all services that the server
       * can offer. */
      mole::serv::ServiceFactory * serviceFactory;

    private :
      /* Server ip */
      std::string ip;
      /* Server port */
      unsigned int port;
      /* Server path */
      std::string path;
    };
    
  } // end of ctx 
  
} // end of mole

#endif
