/* 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_ISession_HPP
#define NMM_ISession_HPP

#include "nmm/nmm_prefix.hpp"

#include "nmm/comm/Interface.hpp"
#include "nmm/comm/messaging/Event.hpp"
#include "nmm/comm/messaging/IllegalStateException.hpp"
#include <memory>

/* Network-Integrated Multimedia Middleware (NMM)
 * http://www.motama.com/nmm.html
 *
 * Copyright (C) 2006-2007
 * Motama GmbH, Saarbruecken, Germany
 * http://www.motama.com
 *
 * See file LICENCE for terms and conditions of usage
 *
 */

namespace NMM {

  class ICompositeNode;
  class GraphDescription;

}
#include "nmm/multimedia/sync/interfaces/ISinkSynchronizer.hpp"
#include "nmm/multimedia/sync/interfaces/ISourceSynchronizer.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 ISession : virtual public NMM::Interface { 
  public:
    ISession() : NMM::Interface(ISession::ISession_type, "NMM") { };

    ISession(NMM::NMMObject& parent) : NMM::Interface (parent, ISession::ISession_type, "NMM") { };

    virtual ~ISession() {};

    static const char* ISession_type;

    virtual  string getInterfaceType() const { return ISession_type; }

    NMM::Interface* copy() const { return new ISession(*this); }
    static void used(); 
    static const char* getGraphDescription_event;
    static const char* getSourceSynchronizer_event;
    static const char* getSinkSynchronizer_event;
    static const char* setSinkSynchronizer_event;
    static const char* setSourceSynchronizer_event;
    static const char* setGraphDescription_event;
    static const char* getMasterGraph_event;
    static const char* setMasterGraph_event;
    static const char* realizeGraph_event;
    static const char* activateGraph_event;
    static const char* startGraph_event;
    static const char* stopGraph_event;
    /**
     * 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
      throw(const NMM::SerializedException&);
    /**
     * Returns interface to the source synchronizer of this sesssion.
     * @return interface to the source synchronizer of this sesssion.
     */

    virtual ISourceSynchronizer* getSourceSynchronizer() const
      throw(const NMM::SerializedException&);
    /**
     * Returns interface to the sink synchronizer of this sesssion.
     * @return interface to the sink synchronizer of this sesssion.
     */

    virtual ISinkSynchronizer* getSinkSynchronizer() const
      throw(const NMM::SerializedException&);
    /**
     * Sets the sink synchronizer for the session.
     * @param synchronizer interface to the sink synchronizer that should be used. 
     */

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

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

    virtual void setGraphDescription(const GraphDescription& gd)
      throw(const NMM::SerializedException&);
    /**
     * 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()
      throw(const NMM::SerializedException&);
    /**
     * 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)
      throw(const NMM::SerializedException&);
    /** This method invokes realizeGraph on the internal GraphDescription.
     */

    virtual void realizeGraph()
      throw(const NMM::SerializedException&);
    /** This method invokes activateGraph on the internal GraphDescription.
     */

    virtual void activateGraph()
      throw(const NMM::SerializedException&);
    /** This method invokes startGraph on the internal GraphDescription.
     */

    virtual void startGraph()
      throw(const NMM::SerializedException&);
    /** This method invokes stopGraph on the internal GraphDescription.
     */

    virtual void stopGraph()
      throw(const NMM::SerializedException&);


  };

  typedef auto_ptr<ISession> ISession_var;




}

#include "nmm/nmm_suffix.hpp"

#endif
