/* 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_IInstreamCompositeStrategyImpl_HPP
#define NMM_IInstreamCompositeStrategyImpl_HPP

#include "nmm/nmm_prefix.hpp"

#include "nmm/comm/NMMObject.hpp"
#include "IInstreamCompositeStrategy.hpp"

#include "ICompositeStrategyImpl.hpp"

#include "visibility.hpp"

namespace NMM
{
  /** Instream composite transport strategy.  
   *
   * This is an interface for the %InstreamCompositeStrategy. 
   * It provides access to child transport strategies and the 
   * multiplexer/demultiplexer unit. 
   * It also defines internal configuration events.
   */

  class DLLEXPORT IInstreamCompositeStrategyImpl  : virtual public ICompositeStrategyImpl { 
  public:
    IInstreamCompositeStrategyImpl() { addInterface(new IInstreamCompositeStrategy(*this)); registerEvents(); };

    virtual ~IInstreamCompositeStrategyImpl() {};

  protected:
    /** Returns child strategy for receiving one-way Buffers.
     *
     * @return Interface to child strategy for receiving one-way Buffers.
     */

    virtual ITransportStrategy* getOneWayBufferReceiverStrategy() const = 0;
    /** Returns child strategy for receiving one-way CEvents.
     *
     * @return Interface to child strategy for receiving one-way CEvents.
     */

    virtual ITransportStrategy* getOneWayCEventReceiverStrategy() const = 0;
    /** Returns child strategy for sending one-way Buffers.
     *
     * @return Interface to child strategy for sending one-way Buffers.
     */

    virtual ITransportStrategy* getOneWayBufferSenderStrategy() const = 0;
    /** Returns child strategy for sending one-way CEvents.
     *
     * @return Interface to child strategy for sending one-way CEvents.
     */

    virtual ITransportStrategy* getOneWayCEventSenderStrategy() const = 0;
    /** @name Internal Events
     */
//@{
    /** Event acknowledgement.  This event is sent reliably to the
     * partner strategy that sent an instream event. It is used for
     * synchronization of a reliable event sub-binding and an
     * unreliable buffer sub-binding which doesn't preserve message
     * headers.
     *
     * @param stream_counter Sequence number of the event
     */

    virtual void notifyEventReceived(const nmm_int32& stream_counter) /* in-stream */  = 0;
    /** Sets message multiplexing strategy.  
     *
     * This method sets the strategy for multiplexing messages 
     * from sub-bindings. Normally, the strategy is chosen automatically 
     * after the composite strategy has been configured. 
     * This method should only be used for debuggung and benchmark purposes.
     *
     * @param strategy Multiplexing strategy
     */

    virtual void setInstreamMuxStrategy(const IInstreamCompositeStrategy::MuxDemuxStrategy& strategy) = 0;
    /** Sets message demultiplexing strategy.  
     *
     * This method sets the strategy for demultiplexing messages from
     * sub-bindings. Normally, the strategy is chosen automatically
     * after the composite strategy has been configured. This method
     * should only be used for debuggung and benchmark purposes.
     *
     * @param strategy Demultiplexing strategy
     */

    virtual void setInstreamDemuxStrategy(const IInstreamCompositeStrategy::MuxDemuxStrategy& strategy) = 0;
    /** Sets interval for data loss simulation.  
     *
     * This method sets the interval for simulating data loss. 
     * If the interval is not 0, it specifies the interval of buffers 
     * that should be dropped to simulate an unreliable buffer sub-binding. 
     * Only use this method for debugging and benchmark purposes.
     * 
     * @param loss_interval set interval to drop Buffers
     */

    virtual void setBufferLossInterval(const nmm_uint32& loss_interval) = 0;

//@}

  private:
    void registerEvents();
  };

}

#include "nmm/nmm_suffix.hpp"

#endif
