session: attaching and detaching objects
This commit is contained in:
parent
0733b0c39b
commit
fcbd18621e
5 changed files with 63 additions and 16 deletions
|
|
@ -129,14 +129,14 @@ namespace mobject {
|
|||
TimelineAccess timelines; ///< collection of timelines (top level)
|
||||
SequenceAccess sequences; ///< collection of sequences
|
||||
|
||||
virtual bool isValid () = 0;
|
||||
virtual MObjectRef attach (PMO& placement) = 0;
|
||||
virtual bool detach (PMO& placement) = 0;
|
||||
virtual bool isValid () = 0;
|
||||
virtual MObjectRef attach (PMO const& placement) = 0;
|
||||
virtual bool detach (PMO const& placement) = 0;
|
||||
|
||||
virtual MObjectRef getRoot() = 0;
|
||||
virtual MObjectRef getRoot() = 0;
|
||||
|
||||
virtual session::PFix& getFixture () = 0;
|
||||
virtual void rebuildFixture () = 0;
|
||||
virtual session::PFix& getFixture () = 0;
|
||||
virtual void rebuildFixture () = 0;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace session {
|
|||
: boundSequence_(sequence_to_bind)
|
||||
{
|
||||
throwIfInvalid();
|
||||
UNIMPLEMENTED ("what additionally to do when binding a sequence??");
|
||||
TODO ("what additionally to do when binding a sequence??");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include "proc/mobject/session/scope-path.hpp"
|
||||
#include "proc/mobject/session/scope-query.hpp"
|
||||
#include "proc/mobject/session/scope-locator.hpp"
|
||||
#include "proc/mobject/placement-ref.hpp"
|
||||
|
||||
#include <boost/intrusive_ptr.hpp>
|
||||
#include <string>
|
||||
|
|
@ -91,6 +92,7 @@ namespace session {
|
|||
QueryFocus();
|
||||
|
||||
ScopePath const& currentPath() const;
|
||||
RefPlacement currentPoint() const;
|
||||
operator Scope() const;
|
||||
operator string() const;
|
||||
|
||||
|
|
@ -144,6 +146,15 @@ namespace session {
|
|||
return *focus_;
|
||||
}
|
||||
|
||||
/** @return placement-ref to the object the
|
||||
* QueryFocus is currently pointing at
|
||||
*/
|
||||
inline RefPlacement
|
||||
QueryFocus::currentPoint() const
|
||||
{
|
||||
return RefPlacement (focus_->getLeaf().getTop());
|
||||
}
|
||||
|
||||
|
||||
/** discover depth-first any matching object
|
||||
* within \em current focus. Resolution is
|
||||
|
|
|
|||
|
|
@ -23,10 +23,13 @@
|
|||
|
||||
#include "proc/mobject/session/session-impl.hpp"
|
||||
#include "proc/mobject/session/mobjectfactory.hpp"
|
||||
#include "proc/mobject/session/query-focus.hpp"
|
||||
#include "proc/mobject/placement.hpp"
|
||||
#include "proc/mobject/mobject.hpp"
|
||||
#include "lib/error.hpp"
|
||||
|
||||
using namespace lumiera;
|
||||
|
||||
namespace mobject {
|
||||
namespace session {
|
||||
|
||||
|
|
@ -63,7 +66,7 @@ namespace session {
|
|||
}
|
||||
catch (...)
|
||||
{
|
||||
throw lumiera::error::Fatal ("unexpected exception while clearing the session"); ///////////TODO still required??
|
||||
throw error::Fatal ("unexpected exception while clearing the session"); ///////////TODO still required??
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -75,25 +78,58 @@ namespace session {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/** 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
|
||||
*/
|
||||
MObjectRef
|
||||
SessionImpl::attach (PMO& placement)
|
||||
SessionImpl::attach (PMO const& placement)
|
||||
{
|
||||
UNIMPLEMENTED ("add Placement to the current Session");
|
||||
MObjectRef newAttachedInstance;
|
||||
RefPlacement attachmentPoint = QueryFocus().currentPoint();
|
||||
newAttachedInstance.activate(
|
||||
contents_.insert (placement, attachmentPoint));
|
||||
return newAttachedInstance;
|
||||
}
|
||||
|
||||
|
||||
/** 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
|
||||
*/
|
||||
bool
|
||||
SessionImpl::detach (PMO& placement)
|
||||
SessionImpl::detach (PMO const& placement)
|
||||
{
|
||||
UNIMPLEMENTED ("search and remove a given Placement from current Session");
|
||||
return false; // TODO
|
||||
bool is_known = contents_.contains (placement);
|
||||
if (is_known)
|
||||
{
|
||||
if (Scope(placement).isRoot())
|
||||
throw error::Invalid ("Can't detach the model root."
|
||||
, LUMIERA_ERROR_INVALID_SCOPE);
|
||||
|
||||
QueryFocus currentFocus;
|
||||
currentFocus.attach (Scope(placement).getParent());
|
||||
contents_.clear (placement);
|
||||
}
|
||||
ENSURE (!contents_.contains (placement));
|
||||
return is_known;
|
||||
}
|
||||
|
||||
|
||||
MObjectRef
|
||||
SessionImpl::getRoot()
|
||||
{
|
||||
UNIMPLEMENTED ("access and return the model root, packaged as MObject-ref");
|
||||
MObjectRef refRoot;
|
||||
refRoot.activate (contents_.getRoot());
|
||||
return refRoot;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -84,8 +84,8 @@ namespace session {
|
|||
|
||||
/* ==== Session API ==== */
|
||||
virtual bool isValid ();
|
||||
virtual MObjectRef attach (PMO& placement);
|
||||
virtual bool detach (PMO& placement);
|
||||
virtual MObjectRef attach (PMO const& placement);
|
||||
virtual bool detach (PMO const& placement);
|
||||
|
||||
virtual MObjectRef getRoot();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue