/* 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_IIPControl_HPP
#define NMM_IIPControl_HPP

#include "nmm/nmm_prefix.hpp"

#include "nmm/comm/Interface.hpp"
#include "nmm/comm/messaging/Event.hpp"
#include "nmm/comm/messaging/IllegalStateException.hpp"
#include <memory>

/* Network-Integrated Multimedia Middleware (NMM)
 * http://www.motama.com/nmm.html
 *
 * Copyright (C) 2006-2007
 * Motama GmbH, Saarbruecken, Germany
 * http://www.motama.com
 *
 * See file LICENCE for terms and conditions of usage
 *
 */

#include "nmm/comm/messaging/Message.hpp"
#include "nmm/comm/serialize/SerializeUtilsNet.hpp"

#include "visibility.hpp"

namespace NMM
{
  /** Interface for setting and getting IP options.
   *
   * This interface provides several methods for controlling socket
   * options which relate to the IP protocol in general. For
   * controlling options of specific sub-protocols, use the sub
   * classes of this interface.
   *
   * @see ITCPControl, IUDPControl, IRTPControl
   */

  class DLLEXPORT IIPControl : virtual public NMM::Interface { 
  public:
    IIPControl() : NMM::Interface(IIPControl::IIPControl_type, "NMM") { };

    IIPControl(NMM::NMMObject& parent) : NMM::Interface (parent, IIPControl::IIPControl_type, "NMM") { };

    virtual ~IIPControl() {};

    static const char* IIPControl_type;

    virtual  string getInterfaceType() const { return IIPControl_type; }

    NMM::Interface* copy() const { return new IIPControl(*this); }
    static void used(); 
    static const char* setRecvBufferSize_event;
    static const char* getRecvBufferSize_event;
    static const char* setSendBufferSize_event;
    static NMM::Event* create_setSendBufferSize(const nmm_int32& buffer_size);
    static const char* getSendBufferSize_event;
    static const char* setPriority_event;
    static const char* getPriority_event;
    static const char* setInstreamBufferPriority_event;
    static const char* setInstreamEventPriority_event;
    static const char* setOutOfBandEventPriority_event;
    static const char* getInstreamBufferPriority_event;
    static const char* getInstreamEventPriority_event;
    static const char* getOutOfBandEventPriority_event;
    /** Set the size of the receive buffer.
     *
     * This method sets the size of the internal receive buffer of the socket.
     * This is the maximum amount of data that is queued at the socket after it is received
     * and before it is read.
     *
     * If new data is received, and there is not enough space in the buffer,
     * this data will be lost or delayed, depending on the used protocol.
     *
     * This option corresponds to the SO_RCVBUF socket option on Linux.
     *
     * @param buffer_size Size of the receive buffer in bytes.
     */

    virtual void setRecvBufferSize(const nmm_int32& buffer_size)
      throw(const NMM::SerializedException&);
    /** Get the size of the receive buffer.
     *
     * This method gets the size of the internal receive buffer of the socket.
     * This is the maximum amount of data that is queued at the socket after it is received
     * and before it is read.
     *
     * If new data is received, and there is not enough space in the buffer,
     * this data will be lost or delayed, depending on the used protocol.
     *
     * This option corresponds to the SO_RCVBUF socket option on Linux.
     *
     * @return Size of the receive buffer in bytes.
     */

    virtual nmm_int32 getRecvBufferSize() const
      throw(const NMM::SerializedException&);
  /* instream (protected) and non-instream (public) */        /** Set the size of the send buffer.
     *
     * This method sets the size of the internal send buffer of the socket.
     * This is the maximum amount of data that is queued at the socket after it was written
     * and before it is sent.
     *
     * If data is written to the socket, and there is not enough space in the buffer,
     * the write operation will block.
     *
     * This option corresponds to the SO_SNDBUF socket option on Linux.
     *
     * @param buffer_size Size of the send buffer in bytes.
     */ 

    virtual void setSendBufferSize(const nmm_int32& buffer_size) /* in-stream */ 
      throw(const NMM::SerializedException&);
  /* non-instream (public) */        /** Get the size of the send buffer.
     *
     * This method gets the size of the internal send buffer of the socket.
     * This is the maximum amount of data that is queued at the socket after it was written
     * and before it is sent.
     *
     * If data is written to the socket, and there is not enough space in the buffer,
     * the write operation will block.
     *
     * This option corresponds to the SO_SNDBUF socket option on Linux.
     *
     * @return Size of the send buffer in bytes.
     */ 

    virtual nmm_int32 getSendBufferSize() const
      throw(const NMM::SerializedException&);
    /** This method sets the priority of the data.
     *
     * This option corresponds to the SO_PRIORITY socket option on Linux.
     * It sets the priority of the data and the type-of-service (ToS) field for outgoing IP packets.
     *
     * @deprecated This method is obsolete and should not be used for setting the ToS field
     * @note Not implemented on some platforms
     *
     * @param priority The priority
     */

    virtual void setPriority(const nmm_int32& priority)
      throw(const NMM::SerializedException&);
    /** This method gets the priority of the data.
     *
     * This option corresponds to the SO_PRIORITY socket option on Linux.
     * It sets the priority of the data and the type-of-service (ToS) field for outgoing IP packets.
     *
     * @deprecated This method is obsolete and should not be used for setting the ToS field
     * @note Not implemented on some platforms
     *
     * @return The priority
     */

    virtual nmm_int32 getPriority() const
      throw(const NMM::SerializedException&);
    /** Set the quality-of-service (QoS) tag for instream messages.
     * This method sets the quality-of-service (QoS) tag for instream messages.
     * The default value is STREAMING_DATA.
     *
     * @param qos_tag Quality-of-service (QoS) tag
     */

    virtual void setInstreamBufferPriority(const Sock::QOS_TAG& qos_tag)
      throw(const NMM::SerializedException&);
    /** Set the quality-of-service (QoS) tag for instream events.
     * This method sets the quality-of-service (QoS) tag for instream events.
     * The default value is INBAND_DATA.
     *
     * @param qos_tag Quality-of-service (QoS) tag
     */

    virtual void setInstreamEventPriority(const Sock::QOS_TAG& qos_tag)
      throw(const NMM::SerializedException&);
    /** Set the quality-of-service (QoS) tag for out-of-band events.
     * This method sets the quality-of-service (QoS) tag for out-of-band events.
     * The default value is RMI_DATA.
     *
     * @param qos_tag Quality-of-service (QoS) tag
     */

    virtual void setOutOfBandEventPriority(const Sock::QOS_TAG& qos_tag)
      throw(const NMM::SerializedException&);
    /** Get the quality-of-service (QoS) tag for instream messages.
     * This method gets the quality-of-service (QoS) tag for instream messages.
     * The default value is STREAMING_DATA.
     *
     * @return Quality-of-service (QoS) tag
     */

    virtual Sock::QOS_TAG getInstreamBufferPriority()
      throw(const NMM::SerializedException&);
    /** Get the quality-of-service (QoS) tag for instream events.
     * This method gets the quality-of-service (QoS) tag for instream events.
     * The default value is INBAND_DATA.
     *
     * @return Quality-of-service (QoS) tag
     */

    virtual Sock::QOS_TAG getInstreamEventPriority()
      throw(const NMM::SerializedException&);
    /** Get the quality-of-service (QoS) tag for out-of-band events.
     * This method gets the quality-of-service (QoS) tag for out-of-band events.
     * The default value is RMI_DATA.
     *
     * @return Quality-of-service (QoS) tag
     */

    virtual Sock::QOS_TAG getOutOfBandEventPriority()
      throw(const NMM::SerializedException&);


  };

  typedef auto_ptr<IIPControl> IIPControl_var;




}

#include "nmm/nmm_suffix.hpp"

#endif
