/* 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_I_TS_ONE_WAY_BUFFER_SENDER_HPP
#define NMM_I_TS_ONE_WAY_BUFFER_SENDER_HPP NMM_I_TS_ONE_WAY_BUFFER_SENDER_HPP

#include "nmm/nmm_prefix.hpp"

#include "ISignalReceiver.hpp"
#include "FormatNotSupportedException.hpp"

#include "visibility.hpp"

namespace NMM {
  
  class ITSOneWayBufferReceiver;
  class IExternalBufferManager;
  class Format;
  
  /** One-way buffer sender transport strategy interface.
   *
   * Interface for a %TransportStrategy which sends Buffers one-way to
   * a one-way %Buffer receiver. The %TransportStrategy also handles
   * signals from its receiver that control the flow of messages.
   */  
  class DLLEXPORT ITSOneWayBufferSender
    : virtual public ISignalReceiver
  {
  public:
    /** Default constructor.
     *
     * No receiver and no buffer manager are set.
     */
    ITSOneWayBufferSender() throw();
    
    /** Set one-way %Buffer receiver.
     *
     * This method sets the object which receives Buffers one-way from
     * this %TransportStrategy.
     *
     * @param receiver Pointer to the one-way %Buffer receiver
     */
    void setOneWayBufferReceiver(ITSOneWayBufferReceiver* receiver);
    
    /** Set the buffer manager.
     *
     * This method sets the buffer manager which is used to allocate
     * buffers sent by this %TransportStrategy.
     *
     * @param buffer_manager The buffer manager to use
     */
    void setBufferManager(IExternalBufferManager* buffer_manager);
    
    /** Get one-way %Buffer receiver.
     *
     * This method returns the object which receives Buffers one-way
     * from this %TransportStrategy.
     *
     * @return Pointer to the one-way %Buffer receiver
     */
    ITSOneWayBufferReceiver* getOneWayBufferReceiver() const;

    /** Get the buffer manager.
     *
     * This method returns the buffer manager which is used to
     * allocate buffers sent by this %TransportStrategy.
     *
     * @return The buffer manager used by this %TransportStrategy
     */
    IExternalBufferManager* getBufferManager() const;
    
    /** Configure the %TransportStrategy for the given instream
     * format.
     *
     * @param format The instream format
     * @exception FormatNotSupportedException if configuration fails or the format is not supported
     */
    virtual void configure(const Format& format)
      throw(const FormatNotSupportedException&) = 0;
    
  private:
    ITSOneWayBufferReceiver* __one_way_buffer_receiver; ///< Receiver.
    IExternalBufferManager* __buffer_manager;           ///< Buffer manager.
  };
  
  
   /** Set OneWayBufferReceiver.
     *
     * @param receiver pointer to  ITSOneWayBufferReceiver
     */
  inline void ITSOneWayBufferSender::setOneWayBufferReceiver(ITSOneWayBufferReceiver* receiver) {
    __one_way_buffer_receiver = receiver;
  }
  
  /** Set buffermanager.
     *
     * @param buffer_manager pointer to IExternalBufferManager
     */
  inline void ITSOneWayBufferSender::setBufferManager(IExternalBufferManager* buffer_manager) {
    __buffer_manager = buffer_manager;
  }
  
  /** Get OneWayBufferReceiver.
     *
     * @return pointer to ITSOneWayBufferReceiver
     */
  inline ITSOneWayBufferReceiver* ITSOneWayBufferSender::getOneWayBufferReceiver() const {
    return __one_way_buffer_receiver;
  }
  
  /** Get buffermanager.
     *
     * @return pointer to IExternalBufferManager
     */
  inline IExternalBufferManager* ITSOneWayBufferSender::getBufferManager() const {
    return __buffer_manager;
  }
  
}

#include "nmm/nmm_suffix.hpp"

#endif
