/*
  SESSIONIMPL.hpp  -  holds the complete session data to be edited by the user
 
  Copyright (C)         Lumiera.org
    2008,               Hermann Vosseler <Ichthyostega@web.de>
 
  This program 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; either version 2 of the
  License, or (at your option) any later version.
 
  This program 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 this program; if not, write to the Free Software
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
*/


/** @file sessionimpl.hpp
 ** Session and SessionManager Implemention classes.
 ** Session and the corresponding Manager are primary Interfaces
 ** to control the behaviour of the editing part of the application.
 ** All all implementaion complexities are hidden behind a "PImpl".
 **
 ** This file contains the implementation classes, it should never
 ** be included by client code.
 **
 */


#ifndef MOBJECT_SESSION_SESSIONIMPL_H
#define MOBJECT_SESSION_SESSIONIMPL_H

#include "proc/mobject/session.hpp"
#include "proc/mobject/session/edl.hpp"
#include "proc/mobject/session/fixture.hpp"

#include <boost/scoped_ptr.hpp>
#include <vector>

using std::vector;



namespace mobject
  {
  namespace session
    {


    /**
     * Implementation class for the Session interface
     */
    class SessionImpl : public mobject::Session
      {
      protected:
        uint focusEDL_;
        vector<EDL> edls;
        PFix fixture;
        
        SessionImpl (DefsManager&)  throw();
        friend class SessManagerImpl;
        
        void clear ();
        
      public:
        virtual bool isValid ();
        virtual void add (PMO& placement);
        virtual bool remove (PMO& placement);
        
        virtual EDL&  currEDL ();
        
        virtual PFix& getFixture ();
        virtual void rebuildFixture ();

      };
      
      
    /**
     * Session manager implementation class holding the
     * actual smart pointer to the current Session impl.
     */
    class SessManagerImpl : public SessManager
      {
        boost::scoped_ptr<DefsManager> pDefs_;
        boost::scoped_ptr<SessionImpl> pImpl_;
        
        SessManagerImpl()  throw();
        friend class lumiera::singleton::StaticCreate<SessManagerImpl>;
        
      public:
        virtual ~SessManagerImpl() {}
        
        virtual void clear () ;
        virtual void reset () ;
        virtual void load ()  ;
        virtual void save ()  ;
        virtual SessionImpl* operator-> ()  throw() ;
      };

      

  } // namespace mobject::session

} // namespace mobject
#endif
