/* 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_COMMUNICATION_CHANNEL_HPP
#define NMM_COMMUNICATION_CHANNEL_HPP NMM_COMMUNICATION_CHANNEL_HPP

#include "nmm/nmm_prefix.hpp"

#include "nmm/comm/serialize/SerializedValue.hpp"

#include "BindingException.hpp"

#include "visibility.hpp"

namespace NMM {

  /** This class is base class for all CommunicationChannels. 
   * 
   * A CommunicationChannel represents a connection between two objects 
   * and is a first class object in the RM-ODP manner. 
   * The application can configure the TransportStrategy that should be used and
   * access their interfaces.
   */
  class DLLEXPORT CommunicationChannel : public SerializedValue {
  public:
    /** @name Constructor & Destructor
     */
    //@{
    /** Constructor.
     *
     * @param ti TypeInfo of CommunicationChannel
     */
    CommunicationChannel(const TypeInfo& ti = getStaticTypeInfo()) : SerializedValue(ti) {}

    /** Destructor.
     */
    virtual ~CommunicationChannel() {}

    /** Virtual copy Constructor.
     *
     * @return Null
     */
    virtual CommunicationChannel* copy()                  const { return 0;}
    //@}
    
    /**
     *  @name Configuration
     */
    //@{
    /** Get a list of all TransportStrategies available for the connection.
     *
     * @return list of all TransportStrategies available for the connection
     */
    virtual std::list<std::string> getStrategyList() const = 0;
    
    /** Establishes the binding.
     *  @exception BindingException if the binding could not be established
     *
     *  This method must be called when the configuration of the channel is finished. After calling this method, no more strategies
     *  may be added.
     *
     *  If not all roles have been assigned a %TransportStrategy yet, then this method will complete the configuration automatically.
     *  If any strategies have been added without the @c DISALLOW_REUSE flag, this method will first try to use them for unset roles.
     *  Otherwise default strategies will be added.
     */
    virtual void establishBinding() throw(const BindingException&) = 0;
    
    /** Unsets all transport strategies.
     *
     *  This method destroys all transport strategies and resets the configuration.
     */
    virtual void unsetTransportStrategy() = 0;
    //@}
    
  public:
    /** This method returns the TypeInfo for this class.
     *
     * @return TypeInfo for this class
     */
    static TypeInfo getStaticTypeInfo();
  };
  
  typedef std::auto_ptr<CommunicationChannel> CommunicationChannel_var;
  
}

#include "nmm/nmm_suffix.hpp"

#endif


