diff --git a/src/proc/mobject/session/query-focus.cpp b/src/proc/mobject/session/query-focus.cpp index d79eec26a..b6bcf3bd0 100644 --- a/src/proc/mobject/session/query-focus.cpp +++ b/src/proc/mobject/session/query-focus.cpp @@ -24,6 +24,11 @@ #include "proc/mobject/session/query-focus.hpp" #include "proc/mobject/mobject.hpp" +#include + +using boost::format; +using boost::str; + namespace mobject { namespace session { @@ -155,4 +160,14 @@ namespace session { + /** diagnostic self-display based on the ScopePath */ + QueryFocus::operator string() const + { + static format display("Focus(%d)--->%s"); + return str ( display % ScopeLocator::instance().stackSize() + % string (*focus_)); + } + + + }} // namespace mobject::session diff --git a/src/proc/mobject/session/query-focus.hpp b/src/proc/mobject/session/query-focus.hpp index 20f8a67d4..1fed6da2a 100644 --- a/src/proc/mobject/session/query-focus.hpp +++ b/src/proc/mobject/session/query-focus.hpp @@ -29,6 +29,7 @@ #include "proc/mobject/session/scope-locator.hpp" #include +#include namespace mobject { namespace session { @@ -91,6 +92,7 @@ namespace session { ScopePath const& currentPath() const; operator Scope() const; + operator string() const; QueryFocus& attach (Scope const&); static QueryFocus push (Scope const&); diff --git a/src/proc/mobject/session/scope-locator.hpp b/src/proc/mobject/session/scope-locator.hpp index 4d6753967..5512f3917 100644 --- a/src/proc/mobject/session/scope-locator.hpp +++ b/src/proc/mobject/session/scope-locator.hpp @@ -85,6 +85,8 @@ namespace session { lib::IterSource::iterator locate (Scope const& target); + size_t stackSize() const; + ~ScopeLocator(); @@ -143,7 +145,7 @@ namespace session { { return ScopeQuery (scope.getTop(), PATH).resolveBy (theResolver()); } - - + + }} // namespace mobject::session #endif diff --git a/src/proc/mobject/session/scope.cpp b/src/proc/mobject/session/scope.cpp index bc2912085..30fab781c 100644 --- a/src/proc/mobject/session/scope.cpp +++ b/src/proc/mobject/session/scope.cpp @@ -121,6 +121,13 @@ namespace session { } + size_t + ScopeLocator::stackSize() const + { + return focusStack_->size(); + } + + /** establishes the \em current query focus location. * Relies on the state of the QueryFocusStack. * If there is no current focus location, a new diff --git a/tests/43session.tests b/tests/43session.tests index 5f6f8994b..ebe930800 100644 --- a/tests/43session.tests +++ b/tests/43session.tests @@ -221,6 +221,16 @@ END TEST "Query focus management" QueryFocus_test </\[DummyMO....\] +out: Focus\(3\)--->/$ +out: Focus\(3\)--->/\[DummyMO....\]$ +out: Focus\(3\)--->/\[DummyMO....\]/\[DummyMO....\]$ +out: Focus\(3\)--->/\[DummyMO....\]/\[DummyMO....\]/\[DummyMO....\]$ +out: Focus\(3\)--->/\[DummyMO....\]/\[DummyMO....\]/\[DummyMO....\]/\[DummyMO....\]$ +out: Focus\(3\)--->/\[DummyMO....\]/\[DummyMO....\]/\[DummyMO....\]/\[DummyMO....\]/\[DummyMO....\]$ +out: Focus\(3\)--->/\[DummyMO....\]/\[DummyMO....\]/\[DummyMO....\]/\[DummyMO....\]/\[DummyMO....\]<<<--discovery exhausted +out: Focus\(2\)--->/\[DummyMO....\]<<<--after pop +out: Focus\(2\)--->/\[DummyMO....\] return: 0 END diff --git a/tests/components/proc/mobject/session/query-focus-test.cpp b/tests/components/proc/mobject/session/query-focus-test.cpp index 769662d95..946250c37 100644 --- a/tests/components/proc/mobject/session/query-focus-test.cpp +++ b/tests/components/proc/mobject/session/query-focus-test.cpp @@ -137,7 +137,7 @@ namespace test { ASSERT (num_refs > 1); // because the run() function also holds a ref QueryFocus subF = QueryFocus::push(); -// cout << string(subF) << endl; /////////////////////////////////////TICKET #429 display diagnostic output + cout << string(subF) << endl; ASSERT (subF == original); ASSERT ( 1 == refs(subF) ); @@ -147,25 +147,25 @@ namespace test { QueryFocus subF2 = QueryFocus::push(Scope(subF).getParent()); ASSERT (subF2 != subF); ASSERT (subF == original); -// cout << string(subF2) << endl; /////////////////////////////////////TICKET #429 display diagnostic output + cout << string(subF2) << endl; ScopeQuery::iterator ii = subF2.explore(); while (ii) // drill down depth first { subF2.attach(*ii); -// cout << string(subF2) << endl; /////////////////////////////////////TICKET #429 display diagnostic output + cout << string(subF2) << endl; ii = subF2.explore(); } -// cout << string(subF2) << "<<<--discovery exhausted" << endl; /////////////////////////////////////TICKET #429 display diagnostic output + cout << string(subF2) << "<<<--discovery exhausted" << endl; subF2.pop(); // releasing this focus and re-attaching to what's on stack top -// cout << string(subF2) << "<<<--after pop()" << endl; /////////////////////////////////////TICKET #429 display diagnostic output + cout << string(subF2) << "<<<--after pop()" << endl; ASSERT (subF2 == subF); ASSERT (2 == refs(subF2)); // both are now attached to the same path ASSERT (2 == refs(subF)); } // subF2 went out of scope, but no auto-pop happens (because subF is still there) -// cout << string(subF) << endl; /////////////////////////////////////TICKET #429 display diagnostic output + cout << string(subF) << endl; ASSERT ( 1 == refs(subF)); ASSERT (num_refs == refs(original));