2009-06-06 06:18:37 +02:00
|
|
|
/*
|
|
|
|
|
SessionImpl - holds the complete session data to be edited by the user
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2009-06-06 06:18:37 +02:00
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2008, Hermann Vosseler <Ichthyostega@web.de>
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2009-06-06 06:18:37 +02:00
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
2010-12-17 23:28:49 +01:00
|
|
|
published by the Free Software Foundation; either version 2 of
|
|
|
|
|
the License, or (at your option) any later version.
|
|
|
|
|
|
2009-06-06 06:18:37 +02:00
|
|
|
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.
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2009-06-06 06:18:37 +02:00
|
|
|
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.
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2009-06-06 06:18:37 +02:00
|
|
|
* *****************************************************/
|
|
|
|
|
|
|
|
|
|
|
2016-11-03 18:22:31 +01:00
|
|
|
/** @file session-impl.cpp
|
2016-11-09 22:22:55 +01:00
|
|
|
** Implementation of the global session datastructure
|
|
|
|
|
** @todo WIP implementation of session core from 2010
|
|
|
|
|
** @todo as of 2016, this effort is considered stalled but basically valid
|
2016-11-03 18:20:10 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2018-11-15 23:42:43 +01:00
|
|
|
#include "steam/mobject/session/session-impl.hpp"
|
|
|
|
|
#include "steam/mobject/session/mobjectfactory.hpp"
|
|
|
|
|
#include "steam/mobject/session/query-focus.hpp"
|
|
|
|
|
#include "steam/mobject/placement.hpp"
|
|
|
|
|
#include "steam/mobject/mobject.hpp"
|
2009-06-06 06:18:37 +02:00
|
|
|
#include "lib/error.hpp"
|
|
|
|
|
|
2010-10-26 05:37:14 +02:00
|
|
|
|
2018-11-15 23:55:13 +01:00
|
|
|
namespace steam {
|
2009-06-06 06:18:37 +02:00
|
|
|
namespace mobject {
|
|
|
|
|
namespace session {
|
|
|
|
|
|
2009-11-09 07:35:08 +01:00
|
|
|
|
|
|
|
|
|
2009-06-06 06:18:37 +02:00
|
|
|
/** create a new empty session with default values.
|
|
|
|
|
* @note any exception arising while creating this
|
|
|
|
|
* default session will inevitably halt the
|
|
|
|
|
* system (and this is desirable)
|
|
|
|
|
*/
|
2009-11-09 07:35:08 +01:00
|
|
|
SessionImpl::SessionImpl ()
|
2010-03-09 06:31:07 +01:00
|
|
|
: SessionInterfaceModules()
|
|
|
|
|
, Session( defaultsManager_
|
2010-06-20 04:30:42 +02:00
|
|
|
, elementQueryAPI_
|
2010-03-09 06:31:07 +01:00
|
|
|
, timelineRegistry_
|
|
|
|
|
, sequenceRegistry_ )
|
|
|
|
|
, contents_( MObject::create (defaultsManager_))
|
2023-04-25 18:27:16 +02:00
|
|
|
, fixture_(new fixture::Fixture)
|
2009-06-06 06:18:37 +02:00
|
|
|
{
|
2010-01-07 08:28:54 +01:00
|
|
|
INFO (session, "new Session created.");
|
2009-06-06 06:18:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @internal used by SessionManager#clear
|
2010-02-22 03:52:52 +01:00
|
|
|
* discard all Session content,
|
|
|
|
|
* without touching global configuration.
|
2009-06-06 06:18:37 +02:00
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
SessionImpl::clear ()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2010-02-22 03:52:52 +01:00
|
|
|
//////////////////////////////////////////////////////////////////////////TICKET #496
|
2009-06-06 06:18:37 +02:00
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
2010-10-26 05:37:14 +02:00
|
|
|
throw error::Fatal ("unexpected exception while clearing the session"); ///////////TODO still required??
|
2009-06-06 06:18:37 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
SessionImpl::isValid ()
|
|
|
|
|
{
|
2010-10-20 05:12:13 +02:00
|
|
|
return true; //////////////////////////////////////////////////////////////////////////TICKET #694
|
2009-06-06 06:18:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-10-26 05:37:14 +02:00
|
|
|
|
|
|
|
|
/** attach a copy within the scope
|
|
|
|
|
* of the current QueryFocus point
|
|
|
|
|
* @return reference to the newly created
|
|
|
|
|
* instance (placement) which was attached
|
|
|
|
|
* below the position given by current focus
|
|
|
|
|
*/
|
2010-03-28 05:15:45 +02:00
|
|
|
MObjectRef
|
2010-10-26 05:37:14 +02:00
|
|
|
SessionImpl::attach (PMO const& placement)
|
2009-06-06 06:18:37 +02:00
|
|
|
{
|
2010-10-26 05:37:14 +02:00
|
|
|
MObjectRef newAttachedInstance;
|
|
|
|
|
RefPlacement attachmentPoint = QueryFocus().currentPoint();
|
|
|
|
|
newAttachedInstance.activate(
|
|
|
|
|
contents_.insert (placement, attachmentPoint));
|
|
|
|
|
return newAttachedInstance;
|
2009-06-06 06:18:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-10-26 05:37:14 +02:00
|
|
|
/** detach the denoted object (placement) from model,
|
|
|
|
|
* together with any child objects contained in the
|
|
|
|
|
* scope of this placement.
|
|
|
|
|
* @note as a sideeffect, the current QueryFocus
|
|
|
|
|
* is moved to the scope containing the
|
|
|
|
|
* object to be removed
|
|
|
|
|
* @throw error::Invalid when attempting to kill root
|
|
|
|
|
* @return \c true if actually removing something
|
|
|
|
|
*/
|
2009-06-06 06:18:37 +02:00
|
|
|
bool
|
2010-10-26 05:37:14 +02:00
|
|
|
SessionImpl::detach (PMO const& placement)
|
2009-06-06 06:18:37 +02:00
|
|
|
{
|
2010-10-26 05:37:14 +02:00
|
|
|
bool is_known = contents_.contains (placement);
|
|
|
|
|
if (is_known)
|
|
|
|
|
{
|
|
|
|
|
if (Scope(placement).isRoot())
|
|
|
|
|
throw error::Invalid ("Can't detach the model root."
|
2018-04-02 01:48:51 +02:00
|
|
|
, LERR_(INVALID_SCOPE));
|
2010-10-26 05:37:14 +02:00
|
|
|
|
|
|
|
|
QueryFocus currentFocus;
|
2015-01-08 15:13:27 +01:00
|
|
|
currentFocus.shift (Scope(placement).getParent());
|
2010-10-26 05:37:14 +02:00
|
|
|
contents_.clear (placement);
|
|
|
|
|
}
|
|
|
|
|
ENSURE (!contents_.contains (placement));
|
|
|
|
|
return is_known;
|
2009-06-06 06:18:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-03-27 16:26:22 +01:00
|
|
|
MObjectRef
|
|
|
|
|
SessionImpl::getRoot()
|
|
|
|
|
{
|
2010-10-26 05:37:14 +02:00
|
|
|
MObjectRef refRoot;
|
|
|
|
|
refRoot.activate (contents_.getRoot());
|
|
|
|
|
return refRoot;
|
2010-03-27 16:26:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-04-25 18:27:16 +02:00
|
|
|
PFixture&
|
2009-06-06 06:18:37 +02:00
|
|
|
SessionImpl::getFixture ()
|
|
|
|
|
{
|
2010-03-12 01:50:33 +01:00
|
|
|
return fixture_;
|
2009-06-06 06:18:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
SessionImpl::rebuildFixture ()
|
|
|
|
|
{
|
|
|
|
|
UNIMPLEMENTED ("rebuild Fixture");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-11-15 23:55:13 +01:00
|
|
|
}}} // namespace steam::mobject::session
|