From 474c29319717fe72698ea74e1a2eb944066fb7b3 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sun, 18 Oct 2009 01:30:43 +0200 Subject: [PATCH] first shot at Ticket #355: use a default-constructed "invalid" PlacementRef Making PlacementRef default constructible this way would resolve the immediate problems; as any access goes through an index lookup and thus will throw. The bool check on this special ref yields false, so this solution seems to fill the bill. --- src/proc/mobject/placement-ref.hpp | 7 +++++++ src/proc/mobject/session/scope-path.hpp | 2 +- src/proc/mobject/session/scope.cpp | 7 +++++++ src/proc/mobject/session/scope.hpp | 1 + 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/proc/mobject/placement-ref.hpp b/src/proc/mobject/placement-ref.hpp index 37f629472..5677aeac4 100644 --- a/src/proc/mobject/placement-ref.hpp +++ b/src/proc/mobject/placement-ref.hpp @@ -106,6 +106,13 @@ namespace mobject { validate(id_); } + /** Default is an NIL Placement ref. It throws on any access. */ + PlacementRef () + : id_() + { + REQUIRE (!isValid(), "hash-ID clash with existing ID"); + } + PlacementRef (PlacementRef const& r) ///< copy ctor : id_(r.id_) { diff --git a/src/proc/mobject/session/scope-path.hpp b/src/proc/mobject/session/scope-path.hpp index f5366a457..5835e6a8d 100644 --- a/src/proc/mobject/session/scope-path.hpp +++ b/src/proc/mobject/session/scope-path.hpp @@ -43,7 +43,7 @@ namespace session { */ class ScopePath { - vector path_; + vector path_; public: ScopePath(); diff --git a/src/proc/mobject/session/scope.cpp b/src/proc/mobject/session/scope.cpp index 6c00a222e..abd0293ff 100644 --- a/src/proc/mobject/session/scope.cpp +++ b/src/proc/mobject/session/scope.cpp @@ -42,6 +42,13 @@ namespace session { } + Scope::Scope () + : anchor_() + { + REQUIRE (!anchor_.isValid()); + } + + ScopeLocator::ScopeLocator() : focusStack_(new QueryFocusStack) { diff --git a/src/proc/mobject/session/scope.hpp b/src/proc/mobject/session/scope.hpp index ce3de7d86..bc192bbb5 100644 --- a/src/proc/mobject/session/scope.hpp +++ b/src/proc/mobject/session/scope.hpp @@ -59,6 +59,7 @@ namespace session { public: Scope (PlacementMO const& constitutingPlacement); + Scope (); ///< unlocated NIL scope static Scope const& containing (PlacementMO const& aPlacement); //////////////TODO really returning a const& here?? static Scope const& containing (RefPlacement const& refPlacement);