diff --git a/src/proc/mobject/session/scope.cpp b/src/proc/mobject/session/scope.cpp index dc86bc2ed..bc2912085 100644 --- a/src/proc/mobject/session/scope.cpp +++ b/src/proc/mobject/session/scope.cpp @@ -47,6 +47,7 @@ #include +using std::string; using std::vector; using lib::IterSource; using lib::iter_source::wrapIter; @@ -225,6 +226,19 @@ namespace session { } + /** Scope diagnostic self display. + * Implemented based on the self-display of the MObject + * attached through the scope top placement. Usually this + * should yield a reasonably unique, descriptive string. */ + Scope::operator string() const + { + string res("["); + res += anchor_->shortID(); + res += "]"; + return res; + } + + diff --git a/src/proc/mobject/session/scope.hpp b/src/proc/mobject/session/scope.hpp index a6e266e6f..c9806ddce 100644 --- a/src/proc/mobject/session/scope.hpp +++ b/src/proc/mobject/session/scope.hpp @@ -28,6 +28,8 @@ #include "proc/mobject/placement-ref.hpp" #include "lib/error.hpp" +#include + namespace mobject { namespace session { @@ -72,16 +74,17 @@ namespace session { Scope (Scope const&); Scope& operator= (Scope const&); - + static const Scope INVALID; - + static Scope containing (PlacementMO const& aPlacement); static Scope containing (RefPlacement const& refPlacement); + operator std::string() const; Scope getParent() const; PlacementMO& getTop() const; - bool isValid() const; - bool isRoot() const; + bool isValid() const; + bool isRoot() const; friend bool operator== (Scope const&, Scope const&); friend bool operator!= (Scope const&, Scope const&); diff --git a/tests/43session.tests b/tests/43session.tests index 5dda9c56d..32c12d434 100644 --- a/tests/43session.tests +++ b/tests/43session.tests @@ -169,9 +169,21 @@ END TEST "Placement search scope" PlacementScope_test < +out: Scope: \[DummyMO\.[0-9]{3}\] +out: Placement<.+TestSubMO21.> +out: Scope: \[DummyMO\.[0-9]{3}\] +out: Placement<.+TestSubMO21.> +out: Scope: \[DummyMO\.[0-9]{3}\] +out: Placement<.+TestSubMO21.> +out: Scope: \[DummyMO\.[0-9]{3}\] +out: Placement<.+TestSubMO21.> +out: Scope: \[Label\.[0-9]{3}\] out: Placement<.+TestSubMO2.> +out: Scope: \[DummyMO\.[0-9]{3}\] out: Placement<.+TestSubMO1.> +out: Scope: \[Label\.[0-9]{3}\] out: Placement<.+DummyMO.> return: 0 END diff --git a/tests/components/proc/mobject/session/placement-scope-test.cpp b/tests/components/proc/mobject/session/placement-scope-test.cpp index 374246c71..f3efca615 100644 --- a/tests/components/proc/mobject/session/placement-scope-test.cpp +++ b/tests/components/proc/mobject/session/placement-scope-test.cpp @@ -100,8 +100,9 @@ namespace test { { PlacementMO& elm = *ii; ASSERT (elm.isValid()); - std::cout << string(elm) << std::endl; Scope const& scope1 = Scope::containing(elm); + std::cout << "Scope: " << string(scope1) << std::endl; + std::cout << string(elm) << std::endl; RefPlacement ref (elm); Scope const& scope2 = Scope::containing(ref);