2009-11-09 05:21:59 +01:00
|
|
|
|
/*
|
2018-11-15 21:13:52 +01:00
|
|
|
|
SessionServices - accessing Steam-Layer internal session implementation services
|
2010-12-17 23:28:49 +01:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
Copyright (C)
|
|
|
|
|
|
2008, Hermann Vosseler <Ichthyostega@web.de>
|
2010-12-17 23:28:49 +01:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
**Lumiera** 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. See the file COPYING for further details.
|
2010-12-17 23:28:49 +01:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
* *****************************************************************/
|
2009-11-09 05:21:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
2016-11-03 18:22:31 +01:00
|
|
|
|
/** @file session-services.cpp
|
2016-11-09 22:22:55 +01:00
|
|
|
|
** Implementation of some top-level internal services of the session.
|
|
|
|
|
|
** The Session is _the_ central interface to access the model and thus the
|
|
|
|
|
|
** edit being worked on. Behind the scenes, it needs to operate several technically
|
|
|
|
|
|
** quite involved services, which we prefer to hide away as implementation details.
|
|
|
|
|
|
** Typically, each of these services defines a dedicated interface, and is implemented
|
|
|
|
|
|
** by delegating to a set of more specialised facilities.
|
|
|
|
|
|
**
|
|
|
|
|
|
** The following services are integrated here
|
|
|
|
|
|
** - service to access a Placement by (hash) ID
|
|
|
|
|
|
** - service to attach or remove session content, while maintaining all indices
|
|
|
|
|
|
** - service to query and explore session contents
|
|
|
|
|
|
** - service to inject mock content for unit testing
|
|
|
|
|
|
** - service to manage and discover default settings by resolution query
|
|
|
|
|
|
**
|
|
|
|
|
|
** @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-service-fetch.hpp"
|
|
|
|
|
|
#include "steam/mobject/session/session-service-mutate.hpp"
|
|
|
|
|
|
#include "steam/mobject/session/session-service-explore-scope.hpp"
|
|
|
|
|
|
#include "steam/mobject/session/session-service-mock-index.hpp"
|
|
|
|
|
|
#include "steam/mobject/session/session-service-defaults.hpp"
|
2009-11-09 07:35:08 +01:00
|
|
|
|
|
2018-11-15 23:42:43 +01:00
|
|
|
|
#include "steam/mobject/session/session-services.hpp"
|
|
|
|
|
|
#include "steam/mobject/session/session-impl.hpp"
|
|
|
|
|
|
#include "steam/mobject/session/sess-manager-impl.hpp"
|
2009-11-09 05:21:59 +01:00
|
|
|
|
|
2018-11-15 23:42:43 +01:00
|
|
|
|
#include "steam/mobject/session/mobjectfactory.hpp"
|
2009-12-17 03:16:08 +01:00
|
|
|
|
#include "lib/symbol.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
using lib::Symbol;
|
|
|
|
|
|
|
2018-11-15 23:55:13 +01:00
|
|
|
|
namespace steam {
|
2009-11-09 05:21:59 +01:00
|
|
|
|
namespace mobject {
|
|
|
|
|
|
namespace session {
|
|
|
|
|
|
|
2009-12-13 04:27:57 +01:00
|
|
|
|
/** is the element-fetch service usable?
|
|
|
|
|
|
* Effectively this means: is the session up?
|
|
|
|
|
|
*/
|
|
|
|
|
|
bool
|
|
|
|
|
|
SessionServiceFetch::isAccessible ()
|
|
|
|
|
|
{
|
2010-01-10 00:04:58 +01:00
|
|
|
|
return Session::initFlag
|
2025-06-07 23:59:57 +02:00
|
|
|
|
and Session::current.isUp();
|
2009-12-13 04:27:57 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2009-11-11 05:30:24 +01:00
|
|
|
|
/** verify the given placement-ID (hash) is valid,
|
|
|
|
|
|
* by checking if it refers to a Placement instance
|
|
|
|
|
|
* currently registered with the PlacementIndex of the
|
|
|
|
|
|
* active Session. */
|
2009-11-09 07:35:08 +01:00
|
|
|
|
bool
|
|
|
|
|
|
SessionServiceFetch::isRegisteredID (PlacementMO::ID const& placementID)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SessionImplAPI::current->isRegisteredID (placementID);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-11-11 05:30:24 +01:00
|
|
|
|
/** actually retrieve a Placement tracked by the index.
|
|
|
|
|
|
* @param placementID hash-ID, typically from a PlacementRef
|
|
|
|
|
|
* @throw error::Invalid if the ID isn't resolvable
|
|
|
|
|
|
* @note the returned ref is guaranteed to be valid and usable
|
2018-11-23 21:29:54 +01:00
|
|
|
|
* only \em now, which means, by virtue of the SteamDispatcher
|
2009-11-11 05:30:24 +01:00
|
|
|
|
* and command processing, during this operation. It can be
|
|
|
|
|
|
* used to invoke an operation, but should never be stored;
|
2025-06-07 23:59:57 +02:00
|
|
|
|
* rather, client code should create an MObjectRef, if
|
2009-11-11 05:30:24 +01:00
|
|
|
|
* bound to store an reference for later.
|
|
|
|
|
|
*/
|
2009-11-09 07:35:08 +01:00
|
|
|
|
PlacementMO&
|
|
|
|
|
|
SessionServiceFetch::resolveID (PlacementMO::ID const& placementID)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SessionImplAPI::current->resolveID (placementID);
|
|
|
|
|
|
}
|
2009-11-09 05:21:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
2010-03-28 05:15:45 +02:00
|
|
|
|
/** attach an object by placement onto the session.
|
|
|
|
|
|
* Implemented by registering a copy of the Placement into the
|
|
|
|
|
|
* PlacementIndex in the session. This copy establishes a new kind of
|
|
|
|
|
|
* "object instance", represented by a new placement-ID, which is returned
|
|
|
|
|
|
* and can be used to refer to this "instance" within the session from now on.
|
|
|
|
|
|
* @param scope the (existing) parent scope where to attach the new element
|
|
|
|
|
|
*/
|
|
|
|
|
|
PlacementMO::ID const&
|
|
|
|
|
|
SessionServiceMutate::attach_toModel(PMO newPlacement, PID scope)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SessionImplAPI::current->insertCopy (newPlacement,scope);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-04-26 23:59:29 +02:00
|
|
|
|
/** detach the denoted element from the model _including all children_.
|
2010-03-28 05:15:45 +02:00
|
|
|
|
* @return true if actually erased something
|
|
|
|
|
|
* @note when specifying model root, all sub-elements will be cleared,
|
2025-06-07 23:59:57 +02:00
|
|
|
|
* but model root itself will be retained.
|
2010-03-28 05:15:45 +02:00
|
|
|
|
*/
|
|
|
|
|
|
bool
|
|
|
|
|
|
SessionServiceMutate::detach_and_clear (PID scope)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SessionImplAPI::current->purgeScopeRecursively (scope);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** detach the denoted leaf element from the model.
|
|
|
|
|
|
* @return true if actually erased something
|
|
|
|
|
|
* @throw error::Fatal when attempting to remove the model root
|
|
|
|
|
|
* @throw error::State when the given element contains sub elements
|
|
|
|
|
|
*/
|
|
|
|
|
|
bool
|
|
|
|
|
|
SessionServiceMutate::detach (PID leafElement)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SessionImplAPI::current->detachElement (leafElement);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-11 02:49:12 +01:00
|
|
|
|
namespace { // deleter function to clean up test/mock PlacementIndex
|
|
|
|
|
|
void
|
|
|
|
|
|
remove_testIndex (PlacementIndex* testIdx)
|
|
|
|
|
|
{
|
|
|
|
|
|
REQUIRE (testIdx);
|
|
|
|
|
|
SessionImplAPI::current->reset_PlacementIndex(); // restore default Index from Session
|
|
|
|
|
|
|
|
|
|
|
|
testIdx->clear();
|
|
|
|
|
|
ASSERT (0 == testIdx->size());
|
|
|
|
|
|
delete testIdx;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2009-11-22 01:16:33 +01:00
|
|
|
|
/** Re-define the implicit PlacementIndex temporarily, e.g. for unit tests. */
|
2009-12-11 02:49:12 +01:00
|
|
|
|
PPIdx
|
|
|
|
|
|
SessionServiceMockIndex:: install ()
|
2009-11-11 05:30:24 +01:00
|
|
|
|
{
|
2009-12-17 03:16:08 +01:00
|
|
|
|
Symbol typeID ("dummyRoot");
|
|
|
|
|
|
PMO dummyRoot (MObject::create (typeID));
|
|
|
|
|
|
PPIdx mockIndex (new PlacementIndex(dummyRoot), &remove_testIndex); // manage instance lifecycle
|
2009-12-11 02:49:12 +01:00
|
|
|
|
ENSURE (mockIndex);
|
|
|
|
|
|
ENSURE (mockIndex->isValid());
|
|
|
|
|
|
ENSURE (1 == mockIndex.use_count());
|
|
|
|
|
|
|
2009-12-12 05:03:50 +01:00
|
|
|
|
SessionImplAPI::current->reset_PlacementIndex (mockIndex.get());
|
2009-12-11 02:49:12 +01:00
|
|
|
|
return mockIndex;
|
2009-11-11 05:30:24 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-11-22 01:16:33 +01:00
|
|
|
|
/** @return resolver for DiscoveryQuery instances, actually backed by PlacementIndex */
|
2009-11-12 02:15:02 +01:00
|
|
|
|
QueryResolver const&
|
|
|
|
|
|
SessionServiceExploreScope::getResolver()
|
|
|
|
|
|
{
|
|
|
|
|
|
return SessionImplAPI::current->getScopeQueryResolver();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-11-22 01:16:33 +01:00
|
|
|
|
/** @return root scope of the current model (session datastructure) */
|
2025-06-07 23:59:57 +02:00
|
|
|
|
PlacementMO&
|
2010-10-06 04:26:04 +02:00
|
|
|
|
SessionServiceExploreScope::getScope (PlacementMO const& placementToLocate)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SessionImplAPI::current->getScope(placementToLocate);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-06-07 23:59:57 +02:00
|
|
|
|
PlacementMO&
|
2010-10-17 06:30:56 +02:00
|
|
|
|
SessionServiceExploreScope::getScope (PlacementMO::ID const& placementToLocate)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SessionImplAPI::current->getScope(placementToLocate);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-10-06 04:26:04 +02:00
|
|
|
|
/** @return root scope of the current model (session datastructure) */
|
|
|
|
|
|
PlacementMO&
|
2009-11-12 02:15:02 +01:00
|
|
|
|
SessionServiceExploreScope::getScopeRoot()
|
|
|
|
|
|
{
|
|
|
|
|
|
return SessionImplAPI::current->getScopeRoot();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2009-11-11 05:30:24 +01:00
|
|
|
|
|
2009-11-09 05:21:59 +01:00
|
|
|
|
|
2018-11-15 23:55:13 +01:00
|
|
|
|
}}} // namespace steam::mobject::session
|