/* Network-Integrated Multimedia Middleware (NMM)
 * http://www.motama.com/nmm.html
 *  
 * Copyright (C) 2006-2007
 * Motama GmbH, Saarbruecken, Germany
 * http://www.motama.com
 *  
 * This file is part of NMM. 
 * 
 * NMM is free software; you can redistribute it and/or modify it    
 * under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; only version 2 of the License.      
 * 
 * NMM is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 
 * License for more details.  
 * 
 * You should have received a copy of the GNU General Public License 
 * along with NMM; if not, write to the Free Software Foundation,    
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */
#ifndef NMM_NETHANDLER_HPP
#define NMM_NETHANDLER_HPP NMM_NETHANDLER_HPP

#include "nmm/nmm_prefix.hpp"

#include "SocketHandle.hpp"

// XXX: fw: needed because windows clutters the name space with many useless symbols
#undef VOID

namespace NMM {

  /** \class NetHandler
   * This is the abstract base class for all NetHandler. The NetReactor calls the receiveEvent method
   * with the events occured on the socket.
   */
  class NetHandler {
  public:
    enum NetResult { VOID, RECHECK, REMOVE };
    /** Destructor 
     */
    virtual ~NetHandler(){};
  
    /** @name Handler methods
     */
    //@{
    /** This method is called by the NetReactor and must be implement by all sub classes
     * \param socket The socket on which an event occurs.
     * \param events The events which have been registered.
     * \param revents The events which have been occured on the socket
     * \return VOID if nothing should be done with the socket, RECHECK if the socket should be checked for new events, 
     *         or REMOVE if the Socket should be no longer handled
     */
    virtual NetResult receiveEvent(SocketHandle socket, short events, short revents) = 0;

    /** This method returns true, if the NetHandler requires an own thread. 
     * \return true it the NetHandler requires an own thread, otherwise false
     */
    virtual bool requireThread() const = 0;
    //@}
  };



}

#include "nmm/nmm_suffix.hpp"

#endif
