From 6c187224ebb0347a765cade6a47858e64b987d54 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 12 Dec 2009 05:03:50 +0100 Subject: [PATCH] get it through the compiler again... --- .../placement-index-query-resolver.cpp | 23 ++++++++++--------- .../placement-index-query-resolver.hpp | 12 ++++++---- src/proc/mobject/session/placement-index.cpp | 13 +++++++---- src/proc/mobject/session/session-impl.cpp | 9 ++++---- src/proc/mobject/session/session-impl.hpp | 6 ++--- src/proc/mobject/session/session-services.cpp | 2 +- .../session/placement-index-query-test.cpp | 2 +- .../mobject/session/placement-index-test.cpp | 16 ++++++++----- .../proc/mobject/session/test-scopes.hpp | 4 ++-- 9 files changed, 50 insertions(+), 37 deletions(-) diff --git a/src/proc/mobject/session/placement-index-query-resolver.cpp b/src/proc/mobject/session/placement-index-query-resolver.cpp index b85ca6e6f..eb7b2731c 100644 --- a/src/proc/mobject/session/placement-index-query-resolver.cpp +++ b/src/proc/mobject/session/placement-index-query-resolver.cpp @@ -43,6 +43,7 @@ namespace session { typedef Goal::QueryID QueryID; typedef QueryID const& QID; + typedef PlacementIndex& PIdx; typedef PlacementIndex::iterator PIter; /** @note all of this search implementation works on Placement refs. @@ -109,7 +110,7 @@ namespace session { class DeepExplorer : public Explorer { - PPIdx index_; + PIdx index_; std::stack scopes_; bool @@ -126,12 +127,12 @@ namespace session { REQUIRE (!scopes_.empty() && scopes_.top()); Pla& pos = *scopes_.top(); ++scopes_.top(); - scopes_.push(index_->getReferrers(pos.getID())); + scopes_.push(index_.getReferrers(pos.getID())); return pos; } public: - DeepExplorer(PIter start, PPIdx idx) + DeepExplorer(PIter start, PIdx idx) : index_(idx) { scopes_.push(start); @@ -146,7 +147,7 @@ namespace session { class UpExplorer : public Explorer { - PPIdx index_; + PIdx index_; Pla* tip_; bool @@ -160,14 +161,14 @@ namespace session { { REQUIRE (tip_); Pla& pos = *tip_; - tip_ = &index_->getScope(*tip_); + tip_ = &index_.getScope(*tip_); if (tip_ == &pos) tip_ = 0; return pos; } public: - UpExplorer(Pla& start, PPIdx idx) + UpExplorer(Pla& start, PIdx idx) : index_(idx) , tip_(&start) { } @@ -277,7 +278,7 @@ namespace session { - PlacementIndexQueryResolver::PlacementIndexQueryResolver (PPIdx theIndex) + PlacementIndexQueryResolver::PlacementIndexQueryResolver (PIdx theIndex) : index_(theIndex) { defineHandling(); @@ -346,10 +347,10 @@ namespace session { { switch (direction) { - case CONTENTS: return new DeepExplorer(index_->getReferrers(startID), index_); - case CHILDREN: return new ChildExplorer(index_->getReferrers(startID)); - case PARENTS: return new UpExplorer(index_->getScope(startID),index_); - case PATH: return new UpExplorer(index_->find(startID),index_); + case CONTENTS: return new DeepExplorer(index_.getReferrers(startID), index_); + case CHILDREN: return new ChildExplorer(index_.getReferrers(startID)); + case PARENTS: return new UpExplorer(index_.getScope(startID),index_); + case PATH: return new UpExplorer(index_.find(startID),index_); default: throw lumiera::error::Invalid("unknown query direction"); //////TICKET #197 diff --git a/src/proc/mobject/session/placement-index-query-resolver.hpp b/src/proc/mobject/session/placement-index-query-resolver.hpp index 26da4a824..e4846ec78 100644 --- a/src/proc/mobject/session/placement-index-query-resolver.hpp +++ b/src/proc/mobject/session/placement-index-query-resolver.hpp @@ -24,7 +24,7 @@ /** @file placement-index-query-resolver.hpp ** Implementing resolution of "discover contents"-queries based on PlacementIndex. ** This wrapper adds a service to resolve queries for exploring the contents or - ** the parent path of a given scope; the actual implementation is based on the + ** the parent path of a given scope; the actual implementation relies on the ** basic operations provided by the PlacementIndex; usually this wrapper is ** instantiated as one of the SessionServices for use by Proc-Layer internals. ** The PlacementIndex to use for the implementation is handed in to the ctor. @@ -33,7 +33,7 @@ ** decoupled from the querying client code, which retrieves the query results ** through an iterator. Parametrisation is transmitted to the resolver using a ** special subclass of Goal, a ScopeQuery. Especially, besides a filter to apply - ** on the results to retrieve, the direction and way* to search can be parametrised: + ** on the results to retrieve, the direction and way to search can be parametrised: ** - ascending to the parents of the start scope ** - enumerating the immediate child elements of the scope ** - exhaustive depth-first search to get any content of the scope @@ -42,7 +42,7 @@ ** On initialisation, a table with preconfigured resolution functions is built, ** in order to re-gain the fully typed context when receiving a query. From within ** this context, the concrete Query instance can be investigated to define a - ** constructor function for the actual result set, to determine the way how further + ** constructor function for the actual result set, determining the way how further ** results will be searched and extracted. The further exploration is driven by the ** client pulling values from the iterator until exhaustion. ** @@ -84,7 +84,9 @@ namespace session { class PlacementIndexQueryResolver : public session::QueryResolver { - PPIdx index_; + typedef PlacementIndex& PIdx; + + PIdx index_; virtual bool canHandleQuery(Goal::QueryID const&) const; @@ -102,7 +104,7 @@ namespace session { public: - PlacementIndexQueryResolver (PPIdx theIndex); + PlacementIndexQueryResolver (PIdx theIndex); }; diff --git a/src/proc/mobject/session/placement-index.cpp b/src/proc/mobject/session/placement-index.cpp index d304ab5e4..997c61197 100644 --- a/src/proc/mobject/session/placement-index.cpp +++ b/src/proc/mobject/session/placement-index.cpp @@ -257,10 +257,6 @@ namespace session { - /** @internal Factory for creating a new placement index. - * For use by the Session and for unit tests. - */ - PlacementIndex::Factory PlacementIndex::create; PlacementIndex::PlacementIndex() : pTab_(new Table) @@ -276,6 +272,15 @@ namespace session { } + /** validity self-check, used for sanity checks + * and the session self-check. */ + bool + PlacementIndex::isValid() const + { + UNIMPLEMENTED ("PlacementIndex validity self-check"); + } + + size_t PlacementIndex::size() const { diff --git a/src/proc/mobject/session/session-impl.cpp b/src/proc/mobject/session/session-impl.cpp index c3bc059a4..1d4f59ecc 100644 --- a/src/proc/mobject/session/session-impl.cpp +++ b/src/proc/mobject/session/session-impl.cpp @@ -28,14 +28,15 @@ namespace mobject { namespace session { - /////////////////////////////////////////TODO temporary hack + /////////////////////////////////////////TODO temporary hack: use Meyer's singleton namespace { DefsManager& getDummyDefaultsManager() { - static scoped_ptr dummyDefaultsManagerInstance(new DefsManager); + static scoped_ptr dummyInstance(0); + if (!dummyInstance) dummyInstance.reset (new DefsManager); - return *dummyDefaultsManagerInstance; + return *dummyInstance; } } /////////////////////////////////////////TODO temporary hack @@ -51,7 +52,7 @@ namespace session { focusEDL_(0), edls(1), fixture(new Fixture), - pIdx_(PlacementIndex::create()) + pIdx_() /////////////////////////////////////////////TODO { } diff --git a/src/proc/mobject/session/session-impl.hpp b/src/proc/mobject/session/session-impl.hpp index cd856bddb..475ec1a3b 100644 --- a/src/proc/mobject/session/session-impl.hpp +++ b/src/proc/mobject/session/session-impl.hpp @@ -123,13 +123,13 @@ namespace session { bool isRegisteredID (PMO::ID const& placementID) { - return IMPL::getPlacementIndex()->contains (placementID); //never throws + return IMPL::getPlacementIndex().contains (placementID); //never throws } PMO& resolveID (PMO::ID const& placementID) { - return IMPL::getPlacementIndex()->find (placementID); //may throw + return IMPL::getPlacementIndex().find (placementID); //may throw } }; @@ -148,7 +148,7 @@ namespace session { PlacementMO& getScopeRoot() { - return IMPL::getPlacementIndex()->getRoot(); + return IMPL::getPlacementIndex().getRoot(); } protected: diff --git a/src/proc/mobject/session/session-services.cpp b/src/proc/mobject/session/session-services.cpp index e846dfbfa..261e4ce4b 100644 --- a/src/proc/mobject/session/session-services.cpp +++ b/src/proc/mobject/session/session-services.cpp @@ -83,7 +83,7 @@ namespace session { ENSURE (mockIndex->isValid()); ENSURE (1 == mockIndex.use_count()); - SessionImplAPI::current->reset_PlacementIndex (*mockIndex); + SessionImplAPI::current->reset_PlacementIndex (mockIndex.get()); return mockIndex; } diff --git a/tests/components/proc/mobject/session/placement-index-query-test.cpp b/tests/components/proc/mobject/session/placement-index-query-test.cpp index a07b85480..a0728fff2 100644 --- a/tests/components/proc/mobject/session/placement-index-query-test.cpp +++ b/tests/components/proc/mobject/session/placement-index-query-test.cpp @@ -88,7 +88,7 @@ namespace test { // Prepare an (test)Index (dummy "session") PPIdx index = build_testScopes(); PlacementMO& root = index->getRoot(); - PlacementIndexQueryResolver resolver(index); + PlacementIndexQueryResolver resolver(*index); discover (ContentsQuery (resolver,root)); diff --git a/tests/components/proc/mobject/session/placement-index-test.cpp b/tests/components/proc/mobject/session/placement-index-test.cpp index 7ad20f7a0..63fd5ca32 100644 --- a/tests/components/proc/mobject/session/placement-index-test.cpp +++ b/tests/components/proc/mobject/session/placement-index-test.cpp @@ -68,7 +68,7 @@ namespace test { run (Arg) { PlacementIndex index; - ASSERT (index); + ASSERT (index.isValid()); checkSimpleInsertRemove (index); has_size (0, index); @@ -121,12 +121,14 @@ namespace test { PMO& elm = index.find(elmID); ASSERT (elmID == elm.getID()); ASSERT (!isSameObject (elm,testObj)); // note: placements are registered as copy - ASSERT (elm == testObj); // they are semantically equivalent +// ///////////////////////////////////////////////////////////////////////////////TICKET #119 +// ASSERT (elm == testObj); // they are semantically equivalent ASSERT (elmID != testObj.getID()); // but have a distinct identity PMO::ID elmID2 = index.insert(testObj, root); ASSERT (elmID != elmID); // ...and each insert creates a new instance - ASSERT (testObj == index.find(elmID2)); +// ///////////////////////////////////////////////////////////////////////////////TICKET #119 +// ASSERT (testObj == index.find(elmID2)); ASSERT (!isSameObject (elm, index.find(elmID2))); ASSERT ( isSameObject (elm, index.find(elmID ))); @@ -151,7 +153,8 @@ namespace test { ID e133 = index.insert (testObj, e13); ID e1331 = index.insert (testObj, e133); - ASSERT (root == index.getScope(e1)); +// ///////////////////////////////////////////////////////////////////////////////TICKET #119 +// ASSERT (root == index.getScope(e1)); ASSERT (e1 == index.getScope(e11).getID()); ASSERT (e1 == index.getScope(e12).getID()); ASSERT (e1 == index.getScope(e13).getID()); @@ -162,8 +165,9 @@ namespace test { ASSERT (e1 != e13); ASSERT (e13 != e133); - ASSERT (index.getScope(e11) == index.getScope(index.find(e11))); - ASSERT (index.getScope(e131) == index.getScope(index.find(e131))); +// ///////////////////////////////////////////////////////////////////////////////TICKET #119 +// ASSERT (index.getScope(e11) == index.getScope(index.find(e11))); +// ASSERT (index.getScope(e131) == index.getScope(index.find(e131))); VERIFY_ERROR(NONEMPTY_SCOPE, index.remove(e13) ); // can't remove a scope-constituting element VERIFY_ERROR(NONEMPTY_SCOPE, index.remove(e133) ); diff --git a/tests/components/proc/mobject/session/test-scopes.hpp b/tests/components/proc/mobject/session/test-scopes.hpp index a88f94594..29da6ba88 100644 --- a/tests/components/proc/mobject/session/test-scopes.hpp +++ b/tests/components/proc/mobject/session/test-scopes.hpp @@ -37,11 +37,11 @@ namespace mobject { namespace session { namespace test { - using std::tr1::shared_ptr; - using namespace mobject::test; typedef TestPlacement PDum; + typedef std::tr1::shared_ptr PPIdx; + /** helper for tests: create a pseudo-session (actually just a PlacementIndex),