/* 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_UDP_ADDRESS_HPP
#define NMM_UDP_ADDRESS_HPP NMM_UDP_ADDRESS_HPP

#include "nmm/nmm_prefix.hpp"

#include "nmm/comm/ConnectorAddress.hpp"

#include "nmm/utils/net/INetAddr.hpp"

#include "SerializeINetAddr.hpp"

#include "visibility.hpp"

namespace NMM {

  /** Transport strategy address for UDPStrategy.
   * This is the type of address which is used by the UDPStrategy to connect to a partner strategy.
   * It can be used for indirect connection setup.
   *
   * A UDP address consists of an IP address and a port number,
   * both represented by an internet address (INetAddr).
   */
  class DLLEXPORT UDPAddress : public ConnectorAddress {
  public:
    /** @name Constructor & Destructor
     */
    //@{
    /** Default constructor.
     *
     * @param nmm_reference NMM reference of partner object
     */
    UDPAddress(const NMMReference& nmm_reference = 0);

    /** Constructor.
     * This constructor creates a TCP address from a host name or IP address in string form.
     *
     * @param name Host name or string representation of an IP address
     * @param port port number
     * @param nmm_reference NMM reference of partner object
     */
    UDPAddress(const string& name, int port, const NMMReference& nmm_reference = 0);

    /** Copy constructor.
     *
     * @param address Object to copy from
     */
    UDPAddress(const UDPAddress& address);

    /** Virtual copy constructor.
     *
     * @return A copy of this object which has the same type
     */
    UDPAddress* copy()                          const { return new UDPAddress(*this); }
    //@}

    /** @name Attributes
     */
    //@{
    /** Set the port number.
     *
     * @param port Port number
     */
    void setPort(int port);

    /** Set the IP address as a string.
     * This method sets the IP address from a host name or IP address in string form.
     *
     * @param name Host name or string representation of an IP address
     */
    void setHostname(const string& name);

    /** Set the internet address.
     * This method sets the IP address and the port number as an internet address.
     */
    void setINetAddr(const INetAddr& net_addr)        { __net_addr = net_addr; }

    /** Get the internet address.
     *
     * @return The internet address
     */
    const INetAddr& getINetAddr()               const { return __net_addr.getRValue(); }

    /** Get the internet address.
     *
     * @return The internet address
     */
    INetAddr& getINetAddr()                           { return __net_addr.getRValue(); }
    //@}
  private:
    TValue<INetAddr> __net_addr;             ///< The internet tube address
  };
  
}

#include "nmm/nmm_suffix.hpp"

#endif
