From c3d29d1eb328851707dca00c5a6d7fbc65fb26c6 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 27 Nov 2010 03:59:07 +0100 Subject: [PATCH] OutputMapping: interface refactorings to yield a cleaner structure --- src/lib/query.hpp | 15 +++++++++++-- src/proc/mobject/output-mapping.hpp | 21 +++++++++++++------ .../proc/mobject/output-mapping-test.cpp | 9 ++++---- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/lib/query.hpp b/src/lib/query.hpp index 19c42b0ea..283292b24 100644 --- a/src/lib/query.hpp +++ b/src/lib/query.hpp @@ -45,8 +45,19 @@ namespace lumiera { /** - * Generic query interface for retrieving objects matching - * some capability query + * Generic query interface for retrieving objects + * matching the given capability query + * @note until really integrating a rules based system + * this is a dummy placeholder implementation + * based on a dressed-up std::string + * @warning in this preliminary implementation, the + * given query-string is used as-is, without any + * normalisation. Moreover, as espeically the + * fake-configrules match by string comparision, + * this may led to unexpected mis-matches. + * @todo the »real thing« should be based on a + * normalised syntax tree representation + * of the atoms in the query. */ template class Query : public std::string diff --git a/src/proc/mobject/output-mapping.hpp b/src/proc/mobject/output-mapping.hpp index b05ff3c2b..ae39aac05 100644 --- a/src/proc/mobject/output-mapping.hpp +++ b/src/proc/mobject/output-mapping.hpp @@ -26,8 +26,11 @@ #include "proc/mobject/output-designation.hpp" #include "lib/meta/function.hpp" +#include "lib/bool-checkable.hpp" #include "lib/query.hpp" +#include + namespace mobject { @@ -104,14 +107,20 @@ namespace mobject { } class Resolver + : public lib::BoolCheckable { public: Resolver () { } - Resolver (PId newId2map) + + void + operator= (PId newId2map) { UNIMPLEMENTED ("store new fixed mapping"); } - Resolver (PPipe newPipe2map) + + void + operator= (PPipe newPipe2map) { UNIMPLEMENTED ("store new fixed mapping"); } @@ -122,7 +131,7 @@ namespace mobject { } bool - isDefined() const + isValid() const { UNIMPLEMENTED ("is this a NULL object, or a valid stored mapping?"); } @@ -136,20 +145,20 @@ namespace mobject { ////TODO: better use boost::operators }; - Resolver + Resolver& operator[] (PId) { UNIMPLEMENTED ("standard lookup"); } - Resolver + Resolver& operator[] (PPipe const& pipe) { REQUIRE (pipe); return (*this) [pipe->getID()]; } - Resolver + Resolver& operator[] (Query const& query4pipe) { UNIMPLEMENTED ("lookup by extended query"); diff --git a/tests/components/proc/mobject/output-mapping-test.cpp b/tests/components/proc/mobject/output-mapping-test.cpp index d0710648b..a2b5b298c 100644 --- a/tests/components/proc/mobject/output-mapping-test.cpp +++ b/tests/components/proc/mobject/output-mapping-test.cpp @@ -101,10 +101,11 @@ namespace test { CHECK (!isnil (map)); CHECK (1 == map.size()); CHECK (map[p1] == "furry"); - CHECK (map[p1].isDefined()); + CHECK (map[p1].isValid()); + CHECK (map[p1]); - CHECK (!map[pX].isDefined()); - CHECK (!map[p2].isDefined()); + CHECK (!map[pX]); + CHECK (!map[p2]); } @@ -136,7 +137,7 @@ namespace test { CHECK (isnil(m1)); CHECK (!isnil(m2)); CHECK (m2[p1] == "furry"); - CHECK (!m1[p1].isDefined()); + CHECK (!m1[p1].isValid()); }