diff --git a/src/proc/mobject/placement-ref.hpp b/src/proc/mobject/placement-ref.hpp index c70e4cf1e..37f629472 100644 --- a/src/proc/mobject/placement-ref.hpp +++ b/src/proc/mobject/placement-ref.hpp @@ -167,7 +167,7 @@ namespace mobject { bool operator!= (PlacementRef const& o) const { return id_ != o; } - typedef _Id PlacementRef::*__unspecified_bool_type; + typedef _Id PlacementRef::*__unspecified_bool_type; ////////TICKET #178 : implement by lib::BoolCheckable? /** implicit conversion to "bool" */ operator __unspecified_bool_type() const { return isValid()? &PlacementRef::id_ : 0; } // never throws diff --git a/src/proc/mobject/session/scope.cpp b/src/proc/mobject/session/scope.cpp index fe5f60bcb..6c00a222e 100644 --- a/src/proc/mobject/session/scope.cpp +++ b/src/proc/mobject/session/scope.cpp @@ -50,6 +50,44 @@ namespace session { + /** discover the enclosing scope of a given Placement */ + Scope const& + Scope::containing (PlacementMO const& aPlacement) + { + UNIMPLEMENTED ("scope discovery"); + } + + + /** retrieve the parent scope which encloses this scope. + * @throw error::Invalid if this is the root scope + */ + Scope const& + Scope::getParent() const + { + UNIMPLEMENTED ("retrieve the enclosing parent scope"); + } + + + /** @return true if this is the outmost (root) scope */ + bool + Scope::isRoot() const + { + UNIMPLEMENTED ("detection of root scope"); + } + + + /** enumerate the path of nested scopes up to root scope. + * @return an iterator which starts with this scope and + * successively yields outer scopes, stopping at root. + */ + Scope::IterType_ + Scope::ascend() const + { + UNIMPLEMENTED ("ascend scope hierarchy up to root"); + } + + + diff --git a/src/proc/mobject/session/scope.hpp b/src/proc/mobject/session/scope.hpp index fa7a0a0a7..c4bffae06 100644 --- a/src/proc/mobject/session/scope.hpp +++ b/src/proc/mobject/session/scope.hpp @@ -28,6 +28,7 @@ //#include "proc/mobject/mobject.hpp" #include "proc/mobject/placement.hpp" #include "proc/mobject/placement-ref.hpp" +#include "lib/iter-adapter.hpp" #include "lib/singleton.hpp" #include @@ -41,6 +42,7 @@ namespace mobject { namespace session { using boost::scoped_ptr; + using lib::IterAdapter; class ScopeLocator; class QueryFocusStack; @@ -53,6 +55,8 @@ namespace session { { RefPlacement anchor_; + typedef IterAdapter IterType_; + public: Scope (PlacementMO const& constitutingPlacement); @@ -60,6 +64,11 @@ namespace session { static Scope const& containing (RefPlacement const& refPlacement); Scope const& getParent() const; + PlacementMO& getTop() const; + bool isRoot() const; + + typedef IterType_ iterator; + iterator ascend() const; }; @@ -74,5 +83,21 @@ namespace session { ///////////////////////////TODO currently just fleshing the API + + inline Scope const& + Scope::containing (RefPlacement const& refPlacement) + { + return containing (*refPlacement); + } + + + inline PlacementMO& + Scope::getTop() const + { + ASSERT (anchor_); + return *anchor_; + } + + }} // namespace mobject::session #endif diff --git a/tests/components/proc/mobject/placement-scope-test.cpp b/tests/components/proc/mobject/placement-scope-test.cpp index f89cc4f4d..cac6cc14b 100644 --- a/tests/components/proc/mobject/placement-scope-test.cpp +++ b/tests/components/proc/mobject/placement-scope-test.cpp @@ -47,12 +47,13 @@ namespace test { // using namespace mobject::test; // typedef TestPlacement PSub; + using lumiera::error::LUMIERA_ERROR_INVALID; /*************************************************************************** * @test basic behaviour of the nested placement search scopes. - * Using a pseudo-session (actually just a PlacementIndex), this test - * creates some nested scopes and then... + * Using a pseudo-session (actually just a PlacementIndex), + * this test creates some nested scopes and then... * - discovers the scope of a placement * - finds the parent scope * - enumerates a scope path up to root