#ifndef __Service_h__
#define __Service_h__

#include "Object.h"
#include "CommandList.h"

namespace core {

   class TCPServerSocket;

   ///
   /// Service
   ///
   /// The Service object is instantiated as a single object upon construction
   /// of the parent TCPServerSocket and is provided as a parameter whenever
   /// a new Session object is created. It provides server level services to
   /// Command handlers.
   ///
   
   class Service : public Object {
   
    public:

      ///
      /// Use this constructor to create a new Service object. 
      ///
      /// @param server A reference to the parent server creating the object.
      ///
      
      Service();

		virtual void init(TCPServerSocket *server);

      void removeFromSessionList(Session *session);

      virtual void sessionErrorHandler(std::string errorString, Session *session);
      
      ///
      /// The list of sessions that are currently open and being maintained by this object.
      ///
      
      std::vector<Session *> sessions;
      
      ///
      /// The server that is associated to this Service object. This provides access to the
      /// server values and methods through the Service object which behaves as an interface.
      ///
      
      TCPServerSocket *server;
      
      ///
      /// The commands object is a CommandList and is used to store Command objects to be 
      /// parsed and run as data comes into the session.
      ///
      
      CommandList commands;
   
   };
   
}

#endif
