From bba9ce2570f28f0bfdf52d20c3a13432f2ea63fb Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Wed, 6 Oct 2010 04:59:57 +0200 Subject: [PATCH] code up the remaining Scope operations. Closes #430 --- src/proc/mobject/session/scope-path.hpp | 5 +++- src/proc/mobject/session/scope.cpp | 38 ++++++++++++------------- src/proc/mobject/session/scope.hpp | 31 +++++++------------- 3 files changed, 33 insertions(+), 41 deletions(-) diff --git a/src/proc/mobject/session/scope-path.hpp b/src/proc/mobject/session/scope-path.hpp index ba774bffb..4eaa6db1f 100644 --- a/src/proc/mobject/session/scope-path.hpp +++ b/src/proc/mobject/session/scope-path.hpp @@ -259,7 +259,10 @@ namespace session { } - inline ScopePath::iterator + /** @note actually this is an Lumiera Forward Iterator, + * yielding the path up to root as a sequence of + * const Scope elements */ + inline ScopePath::iterator ScopePath::begin() const { return iterator (path_.rbegin(), path_.rend()); diff --git a/src/proc/mobject/session/scope.cpp b/src/proc/mobject/session/scope.cpp index ab12be8c7..92db84948 100644 --- a/src/proc/mobject/session/scope.cpp +++ b/src/proc/mobject/session/scope.cpp @@ -27,10 +27,7 @@ #include "proc/mobject/session/session-service-explore-scope.hpp" #include "proc/mobject/mobject.hpp" #include "lib/iter-source.hpp" ////////////////////TICKET #493 : using the IterSource adapters here -//#include "proc/mobject/session/track.hpp" -//#include "proc/mobject/placement.hpp" -//#include "proc/mobject/session/mobjectfactory.hpp" #include using std::vector; @@ -42,17 +39,16 @@ namespace session { LUMIERA_ERROR_DEFINE (INVALID_SCOPE, "Placement scope invalid and not locatable within model"); + LUMIERA_ERROR_DEFINE (NO_PARENT_SCOPE, "Parent scope of root not accessible"); + - /** conversion of a scope top (placement) into a Scope. * only allowed if the given Placement is actually attached * to the session, which will be checked by index access */ Scope::Scope (PlacementMO const& constitutingPlacement) : anchor_(constitutingPlacement) - { - - } + { } Scope::Scope () @@ -64,7 +60,9 @@ namespace session { Scope::Scope (Scope const& o) : anchor_(o.anchor_) - { } + { + ENSURE (anchor_.isValid()); + } Scope& @@ -78,9 +76,7 @@ namespace session { ScopeLocator::ScopeLocator() : focusStack_(new QueryFocusStack) - { - TODO ("anything to initialise here?"); - } + { } ScopeLocator::~ScopeLocator() { } @@ -129,7 +125,7 @@ namespace session { return focusStack_->push (SessionServiceExploreScope::getScopeRoot()); } - + /** navigate the \em current QueryFocus scope location. The resulting * access path to the new location is chosen such as to be most closely related * to the original location; this includes picking a timeline or meta-clip @@ -149,18 +145,18 @@ namespace session { currentPath.navigate (scope); return wrapIter (currentPath.begin()); } - + /** discover the enclosing scope of a given Placement */ - Scope const& + Scope Scope::containing (PlacementMO const& aPlacement) { - UNIMPLEMENTED ("scope discovery"); + return SessionServiceExploreScope::getScope (aPlacement); } - Scope const& + Scope Scope::containing (RefPlacement const& refPlacement) { return containing (*refPlacement); @@ -178,10 +174,14 @@ namespace session { /** retrieve the parent scope which encloses this scope. * @throw error::Invalid if this is the root scope */ - Scope const& + Scope Scope::getParent() const { - UNIMPLEMENTED ("retrieve the enclosing parent scope"); + if (isRoot()) + throw lumiera::error::Invalid ("can't get parent of root scope" + , LUMIERA_ERROR_NO_PARENT_SCOPE); + + return SessionServiceExploreScope::getScope (*anchor_); } @@ -189,7 +189,7 @@ namespace session { bool Scope::isRoot() const { - UNIMPLEMENTED ("detection of root scope"); + return *anchor_ == SessionServiceExploreScope::getScopeRoot(); } diff --git a/src/proc/mobject/session/scope.hpp b/src/proc/mobject/session/scope.hpp index 934ee87de..fbdee81a3 100644 --- a/src/proc/mobject/session/scope.hpp +++ b/src/proc/mobject/session/scope.hpp @@ -24,30 +24,19 @@ #ifndef MOBJECT_SESSION_SCOPE_H #define MOBJECT_SESSION_SCOPE_H -//#include "proc/mobject/mobject.hpp" #include "proc/mobject/placement.hpp" #include "proc/mobject/placement-ref.hpp" -//#include "proc/mobject/session/query-resolver.hpp" ///////////TODO: really? -//#include "lib/iter-adapter.hpp" #include "lib/error.hpp" -//#include "lib/singleton.hpp" -//#include -//#include -//#include -//#include -//#include - -//using std::vector; -//using std::string; namespace mobject { namespace session { - LUMIERA_ERROR_DECLARE (INVALID_SCOPE); ///< Placement scope invalid and not locatable within model + LUMIERA_ERROR_DECLARE (NO_PARENT_SCOPE); ///< Parent scope of root not accessible + LUMIERA_ERROR_DECLARE (INVALID_SCOPE); ///< Placement scope invalid and not locatable within model + - /** * TODO type comment * @note Scope is a passive entity, @@ -66,10 +55,10 @@ namespace session { Scope (Scope const&); Scope& operator= (Scope const&); - static Scope const& containing (PlacementMO const& aPlacement); //////////////TODO really returning a const& here?? - static Scope const& containing (RefPlacement const& refPlacement); + static Scope containing (PlacementMO const& aPlacement); + static Scope containing (RefPlacement const& refPlacement); - Scope const& getParent() const; + Scope getParent() const; PlacementMO& getTop() const; bool isValid() const; bool isRoot() const; @@ -79,9 +68,9 @@ namespace session { }; -///////////////////////////TODO currently just fleshing the API - + + /** as scopes are constituted by a "scope top" element (placement) * registered within the PlacementIndex of the current session, * equality is defined in terms of this defining placement. @@ -89,13 +78,13 @@ namespace session { inline bool operator== (Scope const& scope1, Scope const& scope2) { - return scope1.anchor_ == scope2.anchor_; + return scope1.anchor_ == scope2.anchor_; } inline bool operator!= (Scope const& scope1, Scope const& scope2) { - return scope1.anchor_ != scope2.anchor_; + return scope1.anchor_ != scope2.anchor_; }