2009-06-06 06:18:37 +02:00
|
|
|
/*
|
|
|
|
|
SessManagerImpl - global session access and lifecycle
|
|
|
|
|
|
|
|
|
|
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 sess-manager-impl.cpp
|
|
|
|
|
** Implementation of the Session management functions.
|
|
|
|
|
** The Class SessManager is declared alongside with mobject::Session,
|
|
|
|
|
** because it serves as smart ptr-to-Impl at the same time. Effectively,
|
|
|
|
|
** the session manager owns the current session object and only grants
|
|
|
|
|
** access via his overloaded operator->() . Because there is no operator*(),
|
|
|
|
|
** no one can get at the address of the current session object. (correct?)
|
|
|
|
|
**
|
|
|
|
|
** @see session-impl.hpp
|
|
|
|
|
** @see mobject::Session#current
|
|
|
|
|
** @see mobject::session::SessionManager_test
|
|
|
|
|
**
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "proc/mobject/session.hpp"
|
2009-11-11 06:01:25 +01:00
|
|
|
#include "proc/mobject/session/sess-manager-impl.hpp"
|
2009-06-06 06:18:37 +02:00
|
|
|
#include "proc/mobject/session/defsmanager.hpp"
|
2010-10-23 05:58:14 +02:00
|
|
|
#include "proc/mobject/session/lifecycle-advisor.hpp"
|
2009-06-06 06:18:37 +02:00
|
|
|
#include "lib/error.hpp"
|
|
|
|
|
|
|
|
|
|
using boost::scoped_ptr;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace mobject {
|
|
|
|
|
namespace session {
|
|
|
|
|
|
|
|
|
|
LUMIERA_ERROR_DEFINE (CREATE_SESSION, "unable to create basic session");
|
|
|
|
|
|
|
|
|
|
/** Access to the "current session", which actually is
|
|
|
|
|
* an SessionImpl instance. This session object is created
|
|
|
|
|
* either by loading an existing session, or on demand by
|
|
|
|
|
* this accessor function here (when no session was loaded
|
|
|
|
|
* or created)
|
|
|
|
|
* @note any exceptions arising while building the basic
|
|
|
|
|
* session object(s) will halt the system.
|
|
|
|
|
*/
|
2009-11-09 07:35:08 +01:00
|
|
|
SessionImplAPI*
|
2009-06-06 06:18:37 +02:00
|
|
|
SessManagerImpl::operator-> () throw()
|
|
|
|
|
{
|
|
|
|
|
if (!pImpl_)
|
|
|
|
|
try
|
|
|
|
|
{ // create empty default configured session
|
|
|
|
|
this->reset();
|
|
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
|
|
|
|
ERROR (progress, "Unrecoverable Failure while creating the empty default session.");
|
|
|
|
|
throw lumiera::error::Fatal ( "Failure while creating the basic session object. System halted."
|
|
|
|
|
, LUMIERA_ERROR_CREATE_SESSION );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return pImpl_.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Initially (at static init time), only the single system-wide
|
|
|
|
|
* Session manger instance is created. It can be used to load an
|
2010-10-23 05:58:14 +02:00
|
|
|
* existing session; otherwise an empty default Session, together
|
|
|
|
|
* with the core facilities (PlacementIndex, AssetManager, Query
|
|
|
|
|
* subsystem and the Defaults manager) is created on first
|
2009-06-06 06:18:37 +02:00
|
|
|
* \link #operator-> access \endlink to the session object.
|
|
|
|
|
*/
|
|
|
|
|
SessManagerImpl::SessManagerImpl () throw()
|
2009-11-09 07:35:08 +01:00
|
|
|
: pImpl_ (0)
|
2010-10-23 05:58:14 +02:00
|
|
|
, lifecycle_(new LifecycleAdvisor)
|
2010-01-10 00:04:58 +01:00
|
|
|
{
|
|
|
|
|
Session::initFlag = true; //////////////////////////////////////// TICKET #518 instead of this hack, implement basic-init of the session manager for real
|
|
|
|
|
}
|
2009-06-06 06:18:37 +02:00
|
|
|
|
|
|
|
|
|
2010-10-23 05:58:14 +02:00
|
|
|
SessManagerImpl::~SessManagerImpl ()
|
|
|
|
|
{
|
|
|
|
|
TODO ("verify sane lifecycle");
|
|
|
|
|
Session::initFlag = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-12-13 04:27:57 +01:00
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
SessManagerImpl::isUp ()
|
|
|
|
|
{
|
|
|
|
|
return bool(pImpl_);
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-23 05:58:14 +02:00
|
|
|
/** @note no transactional behaviour. may succeed partially.
|
|
|
|
|
* @todo clarify relation to command processing/undo /////////// TICKET #697
|
2009-06-06 06:18:37 +02:00
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
SessManagerImpl::clear ()
|
|
|
|
|
{
|
|
|
|
|
pImpl_->clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-10-23 05:58:14 +02:00
|
|
|
/** Shut down the current session together with all associated services.
|
|
|
|
|
* @todo avoid blocking when aborting render processes ///////////// TICKET #201
|
|
|
|
|
* @todo well defined transactional behaviour ///////////////////// TICKET #698
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
SessManagerImpl::close ()
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED("clean session shutdown");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-06-06 06:18:37 +02:00
|
|
|
/** @note this operation is atomic and either succeeds or
|
|
|
|
|
* fails completely, in which case the current session
|
|
|
|
|
* remains unaltered.
|
|
|
|
|
* @todo for this to work, we need to change the implementation of
|
|
|
|
|
* AssetManager so support this kind of transactional switch!
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
SessManagerImpl::reset ()
|
|
|
|
|
{
|
2009-11-09 07:35:08 +01:00
|
|
|
scoped_ptr<SessionImplAPI> tmpS (new SessionImplAPI);
|
2009-06-06 06:18:37 +02:00
|
|
|
|
|
|
|
|
TODO ("reset the assets registered with AssetManager");
|
2009-11-07 02:49:55 +01:00
|
|
|
/////////////////////////////////////////////////////////////////// TICKET #154
|
2009-06-06 06:18:37 +02:00
|
|
|
|
|
|
|
|
TODO ("thread lock");
|
|
|
|
|
pImpl_.swap (tmpS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
SessManagerImpl::load ()
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED ("load serialised session");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** \par Implementation details
|
|
|
|
|
* We intend to have several switchable object serialisers.
|
|
|
|
|
* One of these serialisers should generate a comprehensible
|
|
|
|
|
* text based representation suitable for checking into
|
|
|
|
|
* SCM systems.
|
|
|
|
|
* Sessions can be saved into one single file or be split
|
|
|
|
|
* to several files (master file and edl files)
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
SessManagerImpl::save ()
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED ("save session (serialised)");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}} // namespace mobject::session
|