diff --git a/src/common/query/fake-configrules.cpp b/src/common/query/fake-configrules.cpp index 5b9b60ca4..64b8c7944 100644 --- a/src/common/query/fake-configrules.cpp +++ b/src/common/query/fake-configrules.cpp @@ -23,9 +23,11 @@ #include "common/query/fake-configrules.hpp" +#include "proc/mobject/session.hpp" #include "proc/mobject/session/track.hpp" #include "proc/asset/procpatt.hpp" #include "proc/asset/pipe.hpp" +#include "lib/query.hpp" #include "include/logging.h" @@ -45,6 +47,10 @@ namespace lumiera { using asset::ProcPatt; using asset::PProcPatt; +// using lumiera::query::extractID; + using lumiera::query::removeTerm; + + namespace { typedef std::pair AnyPair; @@ -122,6 +128,7 @@ namespace lumiera { answer_->insert (entry (q, newPipe)); return true; // denotes query will now succeed... } + /** special case: create a new pipe for a specific stream ID */ bool MockTable::fabricate_just_new_Pipe (Query& q ) @@ -132,6 +139,7 @@ namespace lumiera { answer_->insert (entry (q, newPipe)); return true; } + /** special case: create/retrieve new processing pattern for given stream ID... */ bool MockTable::fabricate_ProcPatt_on_demand (Query& q) @@ -143,26 +151,66 @@ 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) + MockTable::fabricate_Timeline_on_demand (Query& query) { 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)); + string nameID = removeTerm ("id", query); + if (isnil (nameID)) + nameID = removeTerm ("timeline", query); + if (isnil (nameID)) + nameID = "prime"; + query.insert (0, "id("+nameID+"), "); + + // try to find an existing one with the desired id + Ptr newTimeline; + size_t i=0, cnt=Session::current->timelines.size(); + for ( ; i < cnt; ++i) + if (nameID == Session::current->timelines[i]->ident.name) + { + newTimeline = Session::current->timelines[i]; + break; + } + + if (!newTimeline) // no suitable Timeline found: create and attach new one + newTimeline = Struct::create (Query ("make(TL), "+query)); + // "make" magic token: bail out and invoke factory for new object + answer_->insert (entry (query, newTimeline)); // learn the found/created Timeline as new solution return true; } + /** special case: fabricate new Timeline, maybe using ID specs from the query... */ bool - MockTable::fabricate_Sequence_on_demand (Query& q) + MockTable::fabricate_Sequence_on_demand (Query& query) { 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)); + string nameID = removeTerm ("id", query); + if (isnil (nameID)) + nameID = removeTerm ("sequence", query); + if (isnil (nameID)) + nameID = "first"; + query.insert (0, "id("+nameID+"), "); + + // try to find an existing sequence with the desired id + Ptr newSequence; + size_t i=0, cnt=Session::current->sequences.size(); + for ( ; i < cnt; ++i) + if (nameID == Session::current->sequences[i]->ident.name) + { + newSequence = Session::current->sequences[i]; + break; + } + + if (!newSequence) + newSequence = Struct::create (Query ("make(SQ), "+query)); // no suitable found: create and attach new Sequence + + answer_->insert (entry (query, newSequence)); return true; } diff --git a/src/proc/asset/struct-factory-impl.hpp b/src/proc/asset/struct-factory-impl.hpp index fc2221d55..ce7b75dad 100644 --- a/src/proc/asset/struct-factory-impl.hpp +++ b/src/proc/asset/struct-factory-impl.hpp @@ -47,6 +47,7 @@ #include "proc/asset/sequence.hpp" #include "proc/asset/procpatt.hpp" #include "proc/asset/pipe.hpp" +#include "lib/query.hpp" #include "proc/asset/struct-scheme.hpp" diff --git a/src/proc/mobject/session/session-query.hpp b/src/proc/mobject/session/session-query.hpp index 08a32d53a..ca263d14b 100644 --- a/src/proc/mobject/session/session-query.hpp +++ b/src/proc/mobject/session/session-query.hpp @@ -43,7 +43,7 @@ #include "proc/mobject/session.hpp" #include "proc/mobject/placement.hpp" #include "proc/mobject/session/track.hpp" -#include "proc/mobject/session/specific-contents-query.hpp" ///////////////////TODO really necessary? +//#include "proc/mobject/session/specific-contents-query.hpp" ///////////////////TODO really necessary? #include diff --git a/tests/components/proc/mobject/session/defsmanagertest.cpp b/tests/components/proc/mobject/session/defsmanagertest.cpp index a9be0eb93..f5ac30187 100644 --- a/tests/components/proc/mobject/session/defsmanagertest.cpp +++ b/tests/components/proc/mobject/session/defsmanagertest.cpp @@ -40,10 +40,10 @@ using util::isnil; using std::string; -namespace asset - { - namespace test - { + +namespace asset { +namespace test { + using mobject::Session; using lumiera::Query; using lumiera::query::normaliseID; @@ -199,6 +199,4 @@ namespace asset - } // namespace test - -} // namespace asset +}} // namespace asset::test