/* 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_ISessionImpl_HPP
#define NMM_ISessionImpl_HPP

#include "nmm/nmm_prefix.hpp"

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

#include "nmm/multimedia/sync/interfaces/ISinkSynchronizerImpl.hpp"
#include "nmm/multimedia/sync/interfaces/ISourceSynchronizerImpl.hpp"

#include "visibility.hpp"

namespace NMM
{
  /** Each running flowgraph that was requested by a ClientRegistry using a GraphDescription is represented as a 
   *  Session within the ServerRegistry. The corresponding Session object stores all important information about 
   *  a running Session (e.g. used Synchronizer). Furthermore it provides a reference counter for nodes to determine 
   *  if a node is reused by another Session or can be released. 
   */

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

    virtual ~ISessionImpl() {};

  protected:
    /**
     * Returns the graph description of this sesssion.
     * @return pointer to the GraphDescription of this session. The caller of this method is responsible to delete the returned object.
     */

    virtual GraphDescription* getGraphDescription() const = 0;
    /**
     * Returns interface to the source synchronizer of this sesssion.
     * @return interface to the source synchronizer of this sesssion.
     */

    virtual ISourceSynchronizer* getSourceSynchronizer() const = 0;
    /**
     * Returns interface to the sink synchronizer of this sesssion.
     * @return interface to the sink synchronizer of this sesssion.
     */

    virtual ISinkSynchronizer* getSinkSynchronizer() const = 0;
    /**
     * Sets the sink synchronizer for the session.
     * @param synchronizer interface to the sink synchronizer that should be used. 
     */

    virtual void setSinkSynchronizer(const ISinkSynchronizer& synchronizer) = 0;
    /**
     * Sets the source synchronizer for the session.
     * @param synchronizer interface to the source synchronizer that should be used. 
     */

    virtual void setSourceSynchronizer(const ISourceSynchronizer& synchronizer) = 0;
    /**
     * Sets the graph description for the session.
     * @param gd GraphDescription that is used in this session 
     */

    virtual void setGraphDescription(const GraphDescription& gd) = 0;
    /**
     * Return the MasterGraph of this Session. If a Session reuses nodes that has been allocated by another GraphDescription 
     * (which is called MasterGraph) this GraphDescription can be accessed using this method. If no nodes are reused a NULL pointer is returned.
     * @return pointer to the MasterGraph of this session or NULL-
     */

    virtual GraphDescription* getMasterGraph() = 0;
    /**
     * Set the MasterGraph for this Session. If a Session reuses nodes that has been allocated by another GraphDescription 
     * (which is called MasterGraph) this GraphDescription is set using this method. 
     * @param master_graph reference to the MasterGraph for this Session
     */

    virtual void setMasterGraph(const GraphDescription& master_graph) = 0;
    /** This method invokes realizeGraph on the internal GraphDescription.
     */

    virtual void realizeGraph() = 0;
    /** This method invokes activateGraph on the internal GraphDescription.
     */

    virtual void activateGraph() = 0;
    /** This method invokes startGraph on the internal GraphDescription.
     */

    virtual void startGraph() = 0;
    /** This method invokes stopGraph on the internal GraphDescription.
     */

    virtual void stopGraph() = 0;


  private:
    void registerEvents();
  };

}

#include "nmm/nmm_suffix.hpp"

#endif
