/* 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_ITCPControlImpl_HPP
#define NMM_ITCPControlImpl_HPP

#include "nmm/nmm_prefix.hpp"

#include "nmm/comm/NMMObject.hpp"
#include "ITCPControl.hpp"

#include "IIPControlImpl.hpp"

#include "visibility.hpp"

namespace NMM
{
  /** TCP control interface.
   * This interface provides method for getting and setting options
   * for the Transport Control Protocol (TCP).
   */

  class DLLEXPORT ITCPControlImpl  : virtual public IIPControlImpl { 
  public:
    ITCPControlImpl() { addInterface(new ITCPControl(*this)); registerEvents(); };

    virtual ~ITCPControlImpl() {};

  protected:
    /** Enable or disable no-delay option for TCP .
     * This method enables or disables the no-delay option for TCP.
     *
     * If the no-delay option is enabled, Nagle's algorithm is turned off.
     * This means that packets are always sent as soon as possible,
     * and no additional delays are introduced.
     * This comes at the cost of more packets sent over the network.
     * The no-delay option is disabled by default.
     *
     * This option corresponds to the TCP_NODELAY option under Linux.
     *
     * @param value @c true to enable the no-delay option, @c false to disable the no-delay option
     */

    virtual void enableNoDelay(const nmm_bool& value) = 0;
    /** Check if the no-delay option for TCP is enabled.
     * This method returns a flag which indicates whether the no-delay option for TCP is enabled.
     *
     * If the no-delay option is enabled, Nagle's algorithm is turned off.
     * This means that packets are always sent as soon as possible,
     * and no additional delays are introduced.
     * This comes at the cost of more packets sent over the network.
     * The no-delay option is disabled by default.
     *
     * This option corresponds to the TCP_NODELAY option under Linux.
     *
     * @note This method should be called isNoDelayEnabled(). Don't be confused by its name!
     *
     * @return @c true if the no-delay option is enabled, @c false otherwise
     */

    virtual nmm_bool isDelayEnabled() const = 0;
    /** Set maximum TCP segment size.
     * This method sets the maximum segment size (MSS) used by TCP.
     *
     * This option corresponds to the TCP_MAXSEG option under Linux.
     *
     * @param mss Maximum segment size (in bytes)
     */

    virtual void setMaxSegment(const nmm_int32& mss) = 0;
    /** Get maximum TCP segment size.
     * This method gets the maximum segment size (MSS) used by TCP.
     *
     * This option corresponds to the TCP_MAXSEG option under Linux.
     *
     * @return Maximum segment size (in bytes)
     */

    virtual nmm_int32 getMaxSegment() const = 0;
    /** Disable or enable sending of partial TCP frames.
     * This method disables or enables sending of partial TCP frames. If sending of partial frames.
     *
     * @note This method should be called disablePartialFrames. Don't be confused by its name!
     *
     * @param enable @c true to disable sending of partial frames, @c false to enable sending of partial frames
     */

    virtual void enablePartialFrames(const nmm_bool& enable) = 0;
    /** Check if sending of partial frames is disabled.
     * This method returns a flag which indicates whether sending of partial frames is disabled.
     *
     * @note This method should be called isPartialFramesDisabled. Don't be confused by its name!
     *
     * @return @c true if sending of partial frames is disabled, @c false otherwise
     */

    virtual nmm_bool isPartialFramesEnabled() = 0;
    /** Get unread queue count.
     *
     * @return Unread queue count
     *
     * @deprecated This method is obsolete and has undefined behaviour
     */

    virtual nmm_int32 getUnreadQueueCount() const = 0;
    /** Check if all urgent data send.
     *
     * @return @c true if all urgent data send, @c false otherwise
     *
     * @deprecated This method is so obsolete, we don't even know if the spelling mistake in its name was intentional
     */

    virtual nmm_bool allUrgentDataSend() const = 0;
    /** Get unsend queue count.
     *
     * @return Unsend queue count
     *
     * @deprecated This method is obsolete and has undefined behaviour
     */

    virtual nmm_int32 getUnsendQueueCount() const = 0;
    /** Enable or disable sending of TCP keep-alive packets.
     * This method enables or disables sending of TCP keep-alive packets.
     *
     * This option corresponds to the SO_KEEPALIVE option under Linux.
     *
     * @param enable @c true to enable, @c false to disable sending of keep-alive messages
     */

    virtual void enableKeepAlive(const nmm_bool& enable) = 0;
    /** Check if TCP keep-alive packets are enabled.
     * This method returns a flag which indicates whether sending of TCP keep-alive packets is enabled.
     *
     * This option corresponds to the SO_KEEPALIVE option under Linux.
     *
     * @return @c true if keep-alive packets are enabled, @c false otherwise
     */

    virtual bool getKeepAlive() const = 0;


  private:
    void registerEvents();
  };

}

#include "nmm/nmm_suffix.hpp"

#endif
