diff --git a/src/common/query.hpp b/src/common/query.hpp index e47f93019..db6b454b8 100644 --- a/src/common/query.hpp +++ b/src/common/query.hpp @@ -327,7 +327,8 @@ namespace lumiera { return Query::build(id_.kind).withConditions(def_); } - operator string() const + string + display() const { return "kind=" + lexical_cast(id_.kind) +",type=" + lexical_cast(id_.type) @@ -431,6 +432,13 @@ namespace lumiera { return *this; } + Builder& + fromText (string queryPredicates) + { + this->predicateForm_ = queryPredicates; + return *this; + } + }; diff --git a/src/common/query/defs-registry.hpp b/src/common/query/defs-registry.hpp index 8ee58d40d..58d1791dd 100644 --- a/src/common/query/defs-registry.hpp +++ b/src/common/query/defs-registry.hpp @@ -132,7 +132,7 @@ namespace query { return one.queryKey < two.queryKey; } - operator string () const { return dumpRecord % degree % queryKey % dumpObj(); } + operator string () const { return dumpRecord % degree % queryKey.display() % dumpObj(); } string dumpObj () const { P o (objRef.lock()); return o? string(*o):"dead"; } }; diff --git a/src/proc/mobject/session/query/fake-configrules.hpp b/src/proc/mobject/session/query/fake-configrules.hpp index e9bd0e50d..75c882a26 100644 --- a/src/proc/mobject/session/query/fake-configrules.hpp +++ b/src/proc/mobject/session/query/fake-configrules.hpp @@ -177,7 +177,7 @@ namespace session { string querySpec ;//(q);////////////////////////////////////////////////////////////////////////////////////////////TODO if (treat_as_defaults_query (querySpec)) { - Query defaultsQuery(querySpec); + Query defaultsQuery = Query::build().fromText(querySpec); return solution = Session::current->defaults (defaultsQuery); } // may cause recursion diff --git a/tests/components/proc/mobject/session/defs-registry-impl-test.cpp b/tests/components/proc/mobject/session/defs-registry-impl-test.cpp index a9208082a..0d35f95ab 100644 --- a/tests/components/proc/mobject/session/defs-registry-impl-test.cpp +++ b/tests/components/proc/mobject/session/defs-registry-impl-test.cpp @@ -105,7 +105,7 @@ namespace test { scoped_ptr reg_; typedef P > Obj; - typedef P > Prd; + typedef P > Pra; typedef Query > Q13; typedef Query > Q23; @@ -117,7 +117,7 @@ namespace test { // some test objects... Obj o1, o2, o3; Q13 q1, q2, q3, q4, q5; - map ps; + map ps; public: DefsRegistryImpl_test () @@ -162,13 +162,13 @@ namespace test { ps.clear(); for (int i=0; i<100; ++i) { - Prd px (fabricate<23>()); + Pra px (fabricate<23>()); Q23 qx (garbage_query()); - UNIMPLEMENTED ("generic query key and ordering for map access");////////////////////////////////////////////////////////////////////////////////////////////TODO -// ps[qx] = px; reg_->put (px, qx); - UNIMPLEMENTED ("Query building from predicate string");////////////////////////////////////////////////////////////////////////////////////////////TODO -// px->instanceID = qx;////////////////////////////////////////////////////////////////////////////////////////////TODO + + // store for verification.... + px->instanceID = QueryKey(qx).display(); + ps[qx] = px; } } @@ -214,10 +214,8 @@ namespace test { { CHECK ( *j ); Q23 qx ((*j)->instanceID); - UNIMPLEMENTED ("generic query key and ordering for map access");////////////////////////////////////////////////////////////////////////////////////////////TODO -// CHECK ( ps[qx] == (*j));////////////////////////////////////////////////////////////////////////////////////////////TODO - UNIMPLEMENTED ("Query remolding");////////////////////////////////////////////////////////////////////////////////////////////TODO -// d = lib::query::countPred (qx);////////////////////////////////////////////////////////////////////////////////////////////TODO + CHECK ( ps[qx] == (*j)); + d = QueryKey(qx).degree(); CHECK ( d_prev <= d ); d_prev = d; } @@ -225,7 +223,8 @@ namespace test { // calling with an arbitrary (registered) query // yields the corresponding object at start of the enumeration - j = reg_->candidates(ps.begin()->first); + Q23 someQuery(ps.begin()->first); + j = reg_->candidates(someQuery); CHECK ( *j == ps.begin()->second); }