/* 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_CONNECTOR_ADDRESS_HPP
#define NMM_CONNECTOR_ADDRESS_HPP NMM_CONNECTOR_ADDRESS_HPP

#include "nmm/nmm_prefix.hpp"

#include "TSAddress.hpp"
#include "IConnectionManager.hpp"

#include "visibility.hpp"

namespace NMM {
  
  
  /**
   *  @brief Connector address
   *
   *  This address is the default address of a %ConnectorAcceptor. It refers to a remote %IConnectionManager interface
   *  which is used for sending connection requests. The address can be used with any type of transport strategy.
   *  There is no default transport strategy type.
   *
   *  A %ConnectorAddress also contains the NMM reference of the remote transport strategy. This field is used during
   *  address exchange when a connection is initiated through the %ConnectionManager. It is needed for sending reliable
   *  configuration events between the partner transport strategies.
   *
   *  This class should be the base class of all %TSAddress classes of transport strategies that support connection
   *  setup through the %ConnectionManager.
   *
   *  @see ConnectorAcceptor
   *  @see IConnectionManager
   */
  class DLLEXPORT ConnectorAddress
    : public TSAddress
  {
  public:
    /**
     *  @name Constructor & Destructor
     */
    //@{
    /** Constructs a %ConnectorAddress with default values.
     *
     *  This default constructor is only needed for deserialization and should not be used.
     */
    ConnectorAddress();
    
    /** Constructs a %ConnectorAddress.
     *  @param strategy_type Type of transport strategy
     *  @param ref NMM Reference of addressed object
     */
    ConnectorAddress(const string& strategy_type, const NMMReference& ref = 0);
    
    /** Copy constructor.
     *
     * @param other ConnectorAddress to copy
     */
    ConnectorAddress(const ConnectorAddress& other);
    
    /** Virtual destructor.
     */
    ~ConnectorAddress();
    
    /** Virtual copy constructor.
     *
     * @return pointer to copy of this ConnectorAddress
     */
    virtual ConnectorAddress* copy() const;
    
    /** Assignment operator.
     *
     * @param other ConnectorAddress to assign values from
     * @return reference to argument ConnectorAddress
     */
    ConnectorAddress& operator=(const ConnectorAddress& other);
    //@}
    
    
    /**
     *  @name Accessors
     */
    //@{
    /** Sets connection manager interface.
     *
     *  @param icm Connection manager interface to set
     */
    void setConnectionManager(const IConnectionManager& icm);
    
    /** Returns connection manager interface.
     *  @return The connection manager interface
     */
    IConnectionManager* getConnectionManager() const;
    
    /** Returns NMM reference of remote transport strategy.
     *
     *  @return The NMM reference of remote transport strategy
     */
    const NMMReference& getTSReference() const;
    
    /** Sets NMM reference of remote transport strategy.
     *
     *  @param ts_reference The NMM reference of remote transport strategy
     */
    void setTSReference(const NMMReference& ts_reference);
    //@}

  protected:
    /** Constructs a %ConnectorAddress.
     * @param info Type info 
     * @param binding_type type of binding 
     * @param strategy_type type of transport strategy
     * @param ref NMM Reference of addressed object
     *  
     */
    ConnectorAddress(const TypeInfo& info, unsigned int binding_type, const string& strategy_type, const NMMReference& ref);
    
  private:
    TValue<IConnectionManager*> __icm;       ///< Connection manager interface
    TValue<NMMReference> __ts_reference;     ///< NMM reference of transport strategy
  };
  
  
  inline IConnectionManager* ConnectorAddress::getConnectionManager() const {
    return __icm.getRValue();
  }
  
  inline const NMMReference& ConnectorAddress::getTSReference() const {
    return __ts_reference.getRValue();
  }
  
  inline void ConnectorAddress::setTSReference(const NMMReference& ts_reference) {
    __ts_reference.setValue(ts_reference);
  }
  
}

#include "nmm/nmm_suffix.hpp"

#endif
