/* 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_IBiDirQueuedNodeImpl_HPP
#define NMM_IBiDirQueuedNodeImpl_HPP

#include "nmm/nmm_prefix.hpp"

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

#include "nmm/comm/IQueuedImpl.hpp"
#include "INodeImpl.hpp"

#include "visibility.hpp"

namespace NMM
{
  /** Bidirectional queue control interface of a node.
   *
   * This interface provides methods for configuring and querying the current state of
   * the queues of a node. Every input stream of a node has a downstream queue, and every
   * output stream of a node has an upstream queue.
   *
   * Maximum downstream queue sizes can be set by number of buffers (size) or duration.
   *
   * @see IQueued, StreamQueue
   */

  class DLLEXPORT IBiDirQueuedNodeImpl  : public virtual NMM::NMMObject { 
  public:
    IBiDirQueuedNodeImpl() { addInterface(new IBiDirQueuedNode(*this)); registerEvents(); };

    virtual ~IBiDirQueuedNodeImpl() {};

  protected:
    /** Get the current size of a downstream queue.
     * This method returns the number of buffers currently queued in a downstream queue.
     *
     * @param id Input stream ID which identifies the queue
     * @return Current size of the queue (in number of buffers)
     */

    virtual nmm_uint32 getDownstreamSize(const string& id = "default") const = 0;
    /** Get the maximum size of a downstream queue.
     * This method returns the maximum number of buffers that may be queued in a downstream queue.
     *
     * @param id Input stream ID which identifies the queue
     * @return Maximum size of the queue (in number of buffers)
     */

    virtual nmm_uint32 getDownstreamMaxSize(const string& id = "default") const = 0;
    /** Get the mode of a downstream queue.
     * This method returns the queue mode of a downstream queue.
     *
     * @param id Input stream ID which identifies the queue
     * @return Queue mode
     */

    virtual IQueued::Mode getDownstreamMode(const string& id = "default") const = 0;
    /** Set the maximum size of a downstream queue.
     * This method sets the maximum number of buffers that may be queued in a downstream queue.
     *
     * @param size Maximum size of the queue (in number of buffers)
     * @param id Input stream ID which identifies the queue
     */

    virtual Result setDownstreamMaxSize(const nmm_uint32& size, const string& id = "default") /* limited(INode::CONSTRUCTED) */ = 0;
    /** Set the maximum duration of a downstream queue.
     *
     * @param duration Maximum duration of the queue
     * @param id Input stream ID which identifies the queue
     */

    virtual Result setDownstreamMaxDuration(const Interval& duration, const string& id = "default") /* limited(INode::CONSTRUCTED) */ = 0;
    /** Set the mode of a downstream queue.
     * This method sets the queue mode of a downstream queue.
     *
     * @param mode Queue mode
     * @param id Input stream ID which identifies the queue
     */

    virtual Result setDownstreamMode(const IQueued::Mode& mode, const string& id = "default") /* limited(INode::CONSTRUCTED) */ = 0;
    /** Instream event set the downstream size to unlimited.
     *
     * @return SUCCESS
     */

    virtual Result unlimitDownstreamSize() /* in-stream */  = 0;
    /** Instream event set the downstream size back to limited.
     *
     * @return SUCCESS
     */

    virtual Result limitDownstreamSize() /* in-stream */  = 0;
    /** Get the current size of an upstream queue.
     * This method returns the number of buffers currently queued in an upstream queue.
     *
     * @param id Output stream ID which identifies the queue
     * @return Current size of the queue (in number of buffers)
     */

    virtual nmm_uint32 getUpstreamSize(const string& id = "default") const = 0;
    /** Get the maximum size of an upstream queue.
     * This method returns the maximum number of buffers that may be queued in an upstream queue.
     *
     * @param id Output stream ID which identifies the queue
     * @return Maximum size of the queue (in number of buffers)
     */

    virtual nmm_uint32 getUpstreamMaxSize(const string& id = "default") const = 0;
    /** Get the mode of an upstream queue.
     * This method returns the queue mode of an upstream queue.
     *
     * @param id Output stream ID which identifies the queue
     * @return Queue mode
     */

    virtual IQueued::Mode getUpstreamMode(const string& id = "default") const = 0;
    /** Set the maximum size of an upstream queue.
     * This method sets the maximum number of buffers that may be queued in an upstream queue.
     *
     * @param size Maximum size of the queue (in number of buffers)
     * @param id Output stream ID which identifies the queue
     */

    virtual Result setUpstreamMaxSize(const nmm_uint32& size, const string& id = "default") /* limited(INode::CONSTRUCTED) */ = 0;
    /** Set the mode of an upstream queue.
     * This method sets the queue mode of an upstream queue.
     *
     * @param mode Queue mode
     * @param id Output stream ID which identifies the queue
     */

    virtual Result setUpstreamMode(const IQueued::Mode& mode, const string& id = "default") /* limited(INode::CONSTRUCTED) */ = 0;
    /** Set the maximum size of a downstream queue.
     * This method sets the maximum number of buffers that may be queued in a downstream queue.
     *
     * @param size Maximum size of the queue (in number of buffers)
     * @param id Input stream ID which identifies the queue
     */

    virtual Result setMaxSize(const nmm_uint32& size, const string& id = "default") /* limited(INode::CONSTRUCTED) */ = 0;
    /** Set the mode of a downstream queue.
     * This method sets the queue mode of a downstream queue.
     *
     * @param mode Queue mode
     * @param id Input stream ID which identifies the queue
     */

    virtual Result setMode(const IQueued::Mode& mode, const string& id = "default") /* limited(INode::CONSTRUCTED) */ = 0;


  private:
    void registerEvents();
  };

}

#include "nmm/nmm_suffix.hpp"

#endif
