diff --git a/src/common/query/fake-configrules.cpp b/src/common/query/fake-configrules.cpp index 8a7ece449..5b9b60ca4 100644 --- a/src/common/query/fake-configrules.cpp +++ b/src/common/query/fake-configrules.cpp @@ -143,6 +143,29 @@ namespace lumiera { answer_->insert (entry (q, newPP)); return true; } + /** special case: fabricate new Timeline, maybe using ID specs from the query... */ + bool + MockTable::fabricate_Timeline_on_demand (Query& q) + { + typedef asset::Timeline aTl; + typedef WrapReturn::Wrapper Ptr; + + Ptr newTimeline (Struct::create (Query ("make(TL), "+q))); // magic token: bail out and invoke factory for new object + answer_->insert (entry (q, newTimeline)); + return true; + } + /** special case: fabricate new Timeline, maybe using ID specs from the query... */ + bool + MockTable::fabricate_Sequence_on_demand (Query& q) + { + typedef asset::Sequence aSq; + typedef WrapReturn::Wrapper Ptr; + + Ptr newSequence (Struct::create (Query ("make(SQ), "+q))); // magic token: bail out and invoke factory for new object + answer_->insert (entry (q, newSequence)); + return true; + } + /** for entering "valid" solutions on-the-fly from tests */ template diff --git a/src/common/query/fake-configrules.hpp b/src/common/query/fake-configrules.hpp index e5f55a27b..127a38059 100644 --- a/src/common/query/fake-configrules.hpp +++ b/src/common/query/fake-configrules.hpp @@ -111,6 +111,8 @@ namespace lumiera { bool fabricate_matching_new_Pipe (Query& q, string const& pipeID, string const& streamID); bool fabricate_just_new_Pipe (Query& q); bool fabricate_ProcPatt_on_demand (Query& q); + bool fabricate_Timeline_on_demand (Query& q); + bool fabricate_Sequence_on_demand (Query& q); template bool set_new_mock_solution (Query& q, typename WrapReturn::Wrapper& candidate); @@ -134,12 +136,12 @@ namespace lumiera { public: /** (dummy) implementation of the QueryHandler interface */ virtual bool - resolve (Ret& solution, const Query& q) + resolve (Ret& solution, Query const& q) { const any& entry = fetch_from_table_for (q.asKey()); if (!isnil (entry)) { - const Ret& candidate (any_cast (entry)); + Ret const& candidate (any_cast (entry)); if (! solution ||(solution && solution == candidate) // simulates a real unification ) @@ -150,7 +152,7 @@ namespace lumiera { private: bool - try_special_case (Ret& solution, const Query& q) + try_special_case (Ret& solution, Query const& q) { if (solution && isFakeBypass(q)) // backdoor for tests return solution; @@ -213,6 +215,32 @@ namespace lumiera { q.clear(); return false; } + template<> + inline bool + MockTable::detect_case (WrapReturn::Wrapper& candidate, Query& q) + { + if (!isnil (extractID("make", q))) + return false; // failure triggers creation... + + if (!candidate) + return fabricate_Timeline_on_demand (q); + + q.clear(); + return bool(candidate); + } + template<> + inline bool + MockTable::detect_case (WrapReturn::Wrapper& candidate, Query& q) + { + if (!isnil (extractID("make", q))) + return false; // failure triggers creation... + + if (!candidate) + return fabricate_Sequence_on_demand (q); + + q.clear(); + return bool(candidate); + }