From 9451a6888f6fcf9de8bea8010dde309f5b18fef1 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 16 Oct 2009 03:13:57 +0200 Subject: [PATCH] start definition of new session::Scope interface --- src/proc/mobject/placement-index.cpp | 7 ++ src/proc/mobject/placement-index.hpp | 2 + src/proc/mobject/placement-ref.hpp | 3 +- src/proc/mobject/session/scope.cpp | 54 ++++++++++++ src/proc/mobject/session/scope.hpp | 70 ++++++++++++++++ tests/43session.tests | 4 + .../proc/mobject/placement-scope-test.cpp | 81 ++++++++++++++++++ .../proc/mobject/query-focus-test.cpp | 22 +---- .../proc/mobject/scope-path-test.cpp | 4 + .../proc/mobject/session/test-scopes.cpp | 84 +++++++++++++++++++ .../proc/mobject/session/test-scopes.hpp | 72 ++++++++++++++++ 11 files changed, 383 insertions(+), 20 deletions(-) create mode 100644 src/proc/mobject/session/scope.cpp create mode 100644 src/proc/mobject/session/scope.hpp create mode 100644 tests/components/proc/mobject/placement-scope-test.cpp create mode 100644 tests/components/proc/mobject/session/test-scopes.cpp create mode 100644 tests/components/proc/mobject/session/test-scopes.hpp diff --git a/src/proc/mobject/placement-index.cpp b/src/proc/mobject/placement-index.cpp index 7fc5d9be0..38758d80e 100644 --- a/src/proc/mobject/placement-index.cpp +++ b/src/proc/mobject/placement-index.cpp @@ -135,6 +135,13 @@ namespace mobject { } + void + PlacementIndex::clear() + { + UNIMPLEMENTED ("purge the PlacementIndex, discarding any contained placements"); + } + + namespace { // implementation detail: default global placement index access diff --git a/src/proc/mobject/placement-index.hpp b/src/proc/mobject/placement-index.hpp index bd8950ef4..5d9da5ff7 100644 --- a/src/proc/mobject/placement-index.hpp +++ b/src/proc/mobject/placement-index.hpp @@ -107,6 +107,8 @@ namespace mobject { ~PlacementIndex(); + void clear(); + protected: PlacementIndex() ; diff --git a/src/proc/mobject/placement-ref.hpp b/src/proc/mobject/placement-ref.hpp index 86171e914..c70e4cf1e 100644 --- a/src/proc/mobject/placement-ref.hpp +++ b/src/proc/mobject/placement-ref.hpp @@ -31,7 +31,7 @@ ** these cases will just be a subclass or Placement ** (which in the mentioned example would mean it couldn't be ** passed to a API function expecting a Placement). - ** This is uggly, but doesn't seem to bear any danger. + ** This is ugly, but doesn't seem to bear any danger. ** ** @see Placement ** @see PlacementRef_test @@ -71,6 +71,7 @@ namespace mobject { LUMIERA_ERROR_DECLARE (INVALID_PLACEMENTREF); ///< unresolvable placement reference, or of incompatible type /** + * TODO type comment */ template class PlacementRef diff --git a/src/proc/mobject/session/scope.cpp b/src/proc/mobject/session/scope.cpp new file mode 100644 index 000000000..570fe90ff --- /dev/null +++ b/src/proc/mobject/session/scope.cpp @@ -0,0 +1,54 @@ +/* + Scope - nested search scope for properties of placement + + Copyright (C) Lumiera.org + 2009, Hermann Vosseler + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +* *****************************************************/ + + +#include "proc/mobject/session/scope.hpp" +#include "proc/mobject/mobject.hpp" +//#include "proc/mobject/session/track.hpp" +//#include "proc/mobject/placement.hpp" +//#include "proc/mobject/session/mobjectfactory.hpp" +//#include "proc/asset/track.hpp" + +namespace mobject { +namespace session { + + + + /** TODO??? */ + Scope::Scope (PlacementMO const& constitutingPlacement) + : anchor_(constitutingPlacement) + { + + } + + + ScopeLocator::ScopeLocator() + { + + } + + + + + + +}} // namespace mobject::session diff --git a/src/proc/mobject/session/scope.hpp b/src/proc/mobject/session/scope.hpp new file mode 100644 index 000000000..05ff245fd --- /dev/null +++ b/src/proc/mobject/session/scope.hpp @@ -0,0 +1,70 @@ +/* + SCOPE.hpp - nested search scope for properties of placement + + + Copyright (C) Lumiera.org + 2009, Hermann Vosseler + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + + +#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 "lib/singleton.hpp" + +//#include +//#include + +//using std::vector; +//using std::string; + +namespace mobject { +namespace session { + + + class ScopeLocator; + + + /** + * TODO type comment + */ + class Scope + { + RefPlacement anchor_; + + public: + Scope (PlacementMO const& constitutingPlacement); + + }; + + + class ScopeLocator + { + + public: + ScopeLocator(); + + }; +///////////////////////////TODO currently just fleshing the API + + +}} // namespace mobject::session +#endif diff --git a/tests/43session.tests b/tests/43session.tests index 2999d6d68..d5218096c 100644 --- a/tests/43session.tests +++ b/tests/43session.tests @@ -55,6 +55,10 @@ PLANNED "PlacementRef_test" PlacementRef_test < + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +* *****************************************************/ + + +#include "lib/test/run.hpp" +#include "proc/mobject/session/test-scopes.hpp" +//#include "lib/lumitime.hpp" +//#include "proc/mobject/placement-ref.hpp" +//#include "proc/mobject/placement-index.hpp" +//#include "proc/mobject/test-dummy-mobject.hpp" +//#include "lib/util.hpp" + +//#include +//#include + +//using util::isSameObject; +//using lumiera::Time; +//using std::string; +//using std::cout; +//using std::endl; + + +namespace mobject { +namespace session { +namespace test { + +// using namespace mobject::test; +// typedef TestPlacement PSub; + + + /*************************************************************************** + * @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... + * - discovers the scope of a placement + * - finds the parent scope + * - enumerates a scope path up to root + * + * @see mobject::Placement + * @see mobject::session::ScopePath + * @see mobject::session::QueryFocus + */ + class PlacementScope_test : public Test + { + + virtual void + run (Arg) + { + // Prepare an (test)Index backing the PlacementRefs + PIdx index = build_testScopes(); + + UNIMPLEMENTED ("function test of placement scope interface"); + } + + }; + + + /** Register this test class... */ + LAUNCHER (PlacementScope_test, "function session"); + + +}}} // namespace mobject::session::test diff --git a/tests/components/proc/mobject/query-focus-test.cpp b/tests/components/proc/mobject/query-focus-test.cpp index 27ee07380..4500c0db6 100644 --- a/tests/components/proc/mobject/query-focus-test.cpp +++ b/tests/components/proc/mobject/query-focus-test.cpp @@ -24,8 +24,8 @@ #include "lib/test/run.hpp" //#include "lib/lumitime.hpp" //#include "proc/mobject/placement-ref.hpp" +#include "proc/mobject/session/test-scopes.hpp" #include "proc/mobject/placement-index.hpp" -#include "proc/mobject/test-dummy-mobject.hpp" //#include "lib/util.hpp" //#include @@ -42,8 +42,6 @@ namespace mobject { namespace session { namespace test { - using namespace mobject::test; - typedef TestPlacement PSub; /********************************************************************************** @@ -61,28 +59,14 @@ namespace test { virtual void run (Arg) { - PSub p1(*new TestSubMO21); - PSub p2(*new TestSubMO21); - PSub p3(*new TestSubMO21); - PSub p4(*new TestSubMO21); - PSub p5(*new TestSubMO21); // Prepare an (test)Index backing the PlacementRefs - typedef shared_ptr PIdx; - PIdx index (PlacementIndex::create()); - PMO& root = index->getRoot(); - reset_PlacementIndex(index); - - index->insert (p1, root); - index->insert (p2, p1 ); - index->insert (p3, p2 ); - index->insert (p4, p3 ); - index->insert (p5, p4 ); + PIdx index = build_testScopes(); +// PMO& root = index->getRoot(); UNIMPLEMENTED ("unit test to cover query focus management"); //?? ASSERT (0 == index->size()); - reset_PlacementIndex(); } }; diff --git a/tests/components/proc/mobject/scope-path-test.cpp b/tests/components/proc/mobject/scope-path-test.cpp index 3f96612ed..817883c4b 100644 --- a/tests/components/proc/mobject/scope-path-test.cpp +++ b/tests/components/proc/mobject/scope-path-test.cpp @@ -22,6 +22,7 @@ #include "lib/test/run.hpp" +#include "proc/mobject/session/test-scopes.hpp" //#include "lib/lumitime.hpp" //#include "proc/mobject/placement-ref.hpp" //#include "proc/mobject/placement-index.hpp" @@ -60,6 +61,9 @@ namespace test { virtual void run (Arg) { + // Prepare an (test)Index backing the PlacementRefs + PIdx index = build_testScopes(); + UNIMPLEMENTED ("unit test regarding placement scope handling"); } diff --git a/tests/components/proc/mobject/session/test-scopes.cpp b/tests/components/proc/mobject/session/test-scopes.cpp new file mode 100644 index 000000000..0b58081d5 --- /dev/null +++ b/tests/components/proc/mobject/session/test-scopes.cpp @@ -0,0 +1,84 @@ +/* + TEST-SCOPES.cpp - builds a test PlacementIndex containing dummy Placements as nested scopes + + Copyright (C) Lumiera.org + 2009, Hermann Vosseler + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +* *****************************************************/ + + +#include "proc/mobject/session/test-scopes.hpp" +//#include "lib/util.hpp" + +//#include +//#include + +//using util::isSameObject; +//using lumiera::Time; +//using std::string; +//using std::cout; +//using std::endl; + + +namespace mobject { +namespace session { +namespace test { + + + namespace { // deleter function to clean up Test fixture + void + remove_testIndex (PlacementIndex* testIdx) + { + REQUIRE (testIdx); + testIdx->clear(); + ASSERT (0 == testIdx->size()); + reset_PlacementIndex(); // restore default Index from Session + + delete testIdx; + } + } + + + /** @note when this object goes out of scope, the activation of this + * test PlacementIndex will be cleared automatically, and the + * default Index within the session will be re-activated. + */ + PIdx + build_testScopes() + { + PSub p1(*new TestSubMO21); + PSub p2(*new TestSubMO21); + PSub p3(*new TestSubMO21); + PSub p4(*new TestSubMO21); + PSub p5(*new TestSubMO21); + + // Prepare an (test)Index backing the PlacementRefs + PIdx index (PlacementIndex::create().get(), &remove_testIndex); // taking ownership + reset_PlacementIndex(index); + PMO& root = index->getRoot(); + + index->insert (p1, root); + index->insert (p2, p1 ); + index->insert (p3, p2 ); + index->insert (p4, p3 ); + index->insert (p5, p4 ); + + return index; + } + + +}}} // namespace mobject::session::test diff --git a/tests/components/proc/mobject/session/test-scopes.hpp b/tests/components/proc/mobject/session/test-scopes.hpp new file mode 100644 index 000000000..760ab0d75 --- /dev/null +++ b/tests/components/proc/mobject/session/test-scopes.hpp @@ -0,0 +1,72 @@ +/* + TEST-SCOPES.hpp - builds a test PlacementIndex containing dummy Placements as nested scopes + + Copyright (C) Lumiera.org + 2009, Hermann Vosseler + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + + +#ifndef MOBJECT_SESSION_TEST_TEST_SCOPES_H +#define MOBJECT_SESSION_TEST_TEST_SCOPES_H + + +//#include "lib/lumitime.hpp" +//#include "proc/mobject/placement-ref.hpp" +#include "proc/mobject/session/test-scopes.hpp" +#include "proc/mobject/test-dummy-mobject.hpp" +#include "proc/mobject/placement-index.hpp" +//#include "lib/util.hpp" + +#include +//#include +//#include + +//using util::isSameObject; +//using lumiera::Time; +//using std::string; +//using std::cout; +//using std::endl; + + +namespace mobject { +namespace session { +namespace test { + + using std::tr1::shared_ptr; + + using namespace mobject::test; + typedef TestPlacement PSub; + typedef shared_ptr PIdx; + + + + /** helper for tests: create a pseudo-session (actually just a PlacementIndex), + * which contains some nested placement scopes. + * @return new PlacementIndex, which has already been activated to be used + * by all Placements from now on. This activation will be cleared + * automatically, when this object goes out of scope. + * + * @see mobject::PlacementIndex + * @see session::SessManagerImpl::getCurrentIndex() + * @see mobject::reset_PlacementIndex + */ + PIdx build_testScopes(); + + +}}} // namespace mobject::session::test +#endif