diff --git a/src/common/configrules.cpp b/src/common/configrules.cpp index 09b46d51e..2eeca2649 100644 --- a/src/common/configrules.cpp +++ b/src/common/configrules.cpp @@ -34,7 +34,8 @@ namespace cinelerra namespace query { - + CINELERRA_ERROR_DEFINE (CAPABILITY_QUERY, "unresolvable capability query"); + } // namespace query diff --git a/src/common/configrules.hpp b/src/common/configrules.hpp index 2c2c52d7c..80ba8df3c 100644 --- a/src/common/configrules.hpp +++ b/src/common/configrules.hpp @@ -34,6 +34,8 @@ ** they want to provide, together with functors carrying out the neccessary configuration steps. ** All details and consequences of this approach still have to be worked out... ** + ** @note this is rather a scrapbook and in flux... don't take this code too literal! + ** ** @see cinelerra::Query ** @see mobject::session::DefsManager ** @see asset::StructFactory @@ -49,17 +51,21 @@ #include "common/typelist.hpp" #include "proc/mobject/session/track.hpp" +#include "proc/asset/procpatt.hpp" #include "proc/asset/port.hpp" #include +#include namespace cinelerra { using std::string; - namespace query { class MockConfigRules; } + using std::tr1::shared_ptr; + + namespace query { class MockConfigRules; } // TODO: need a better way to return a sub-type from a singleton @@ -114,7 +120,7 @@ namespace cinelerra protected: virtual ~QueryHandler(); public: - virtual TY resolve (Query q); + virtual shared_ptr resolve (Query q); }; // TODO: the Idea is to provide specialisations for the concrete types @@ -179,6 +185,8 @@ namespace cinelerra cinelerra::Singleton ConfigRules::instance; + + CINELERRA_ERROR_DECLARE (CAPABILITY_QUERY); ///< unresolvable capability query. } // namespace query @@ -194,6 +202,7 @@ namespace cinelerra */ typedef cinelerra::typelist::Types < mobject::session::Track , asset::Port + , const asset::ProcPatt > InterfaceTypes; diff --git a/src/common/query/mockconfigrules.cpp b/src/common/query/mockconfigrules.cpp index 7a938728e..915e20ba8 100644 --- a/src/common/query/mockconfigrules.cpp +++ b/src/common/query/mockconfigrules.cpp @@ -33,6 +33,11 @@ namespace cinelerra namespace query { + MockConfigRules::MockConfigRules () + { + + } + } // namespace query diff --git a/src/common/query/mockconfigrules.hpp b/src/common/query/mockconfigrules.hpp index 856d283c3..07fc98831 100644 --- a/src/common/query/mockconfigrules.hpp +++ b/src/common/query/mockconfigrules.hpp @@ -53,6 +53,8 @@ namespace cinelerra { using mobject::session::Track; using asset::Port; + using asset::ProcPatt; + using asset::PProcPatt; /** * Dummy Implementation of the query interface. @@ -67,8 +69,9 @@ namespace cinelerra public: - virtual Track resolve (Query q); - virtual Port resolve (Query q); + virtual shared_ptr resolve (Query q); + virtual shared_ptr resolve (Query q); + virtual PProcPatt resolve (Query q); }; diff --git a/src/proc/asset/struct.cpp b/src/proc/asset/struct.cpp index dd8f71aa5..ad1191045 100644 --- a/src/proc/asset/struct.cpp +++ b/src/proc/asset/struct.cpp @@ -115,7 +115,7 @@ namespace asset { normalizeID (portID); normalizeID (streamID); - PProcPatt processingPattern = Session::current->defaults (Query("stream("+streamID+")")); + PProcPatt processingPattern = Session::current->defaults (Query("stream("+streamID+")")); Port* pP = new Port (processingPattern, portID); return AssetManager::instance().wrap (*pP); } diff --git a/src/proc/mobject/session/defsmanager.cpp b/src/proc/mobject/session/defsmanager.cpp index 291233ce0..2851ea235 100644 --- a/src/proc/mobject/session/defsmanager.cpp +++ b/src/proc/mobject/session/defsmanager.cpp @@ -24,10 +24,21 @@ #include "proc/mobject/session/defsmanager.hpp" #include "proc/asset/procpatt.hpp" #include "proc/asset/port.hpp" +#include "common/configrules.hpp" +#include "common/query/mockconfigrules.hpp" // TODO: better way to handle the includes (rework singleton template?) +#include "common/error.hpp" + +#include + +using boost::format; using asset::Query; using asset::Port; using asset::ProcPatt; +using asset::PProcPatt; + +using cinelerra::ConfigRules; +using cinelerra::query::CINELERRA_ERROR_CAPABILITY_QUERY; namespace mobject { @@ -40,27 +51,31 @@ namespace mobject } - - /** create or retrieve a default-configured port asset. - */ - template<> - shared_ptr - DefsManager::operator() (const Query& capabilities) + + template + shared_ptr + DefsManager::operator() (const Query& capabilities) { - UNIMPLEMENTED ("query for default port with capabilities"); + shared_ptr res = cinelerra::ConfigRules::instance().resolve (capabilities); + + if (!res) + throw cinelerra::error::Config ( str(format("The following Query could not be resolved: %s.") + % capabilities) + , CINELERRA_ERROR_CAPABILITY_QUERY ); + else + return res; } + + + /***************************************************************/ + /* explicit template instantiations for querying various Types */ + /***************************************************************/ - /** create or retrieve a default-configured processing pattern. - */ - template<> - shared_ptr - DefsManager::operator() (const Query& capabilities) - { - UNIMPLEMENTED ("query for default processing pattern with capabilities"); - } - + template shared_ptr DefsManager::operator ()(const Query&); + template PProcPatt DefsManager::operator ()(const Query&); } // namespace mobject::session } // namespace mobject + diff --git a/src/proc/mobject/session/defsmanager.hpp b/src/proc/mobject/session/defsmanager.hpp index ccc75d6ac..b48411058 100644 --- a/src/proc/mobject/session/defsmanager.hpp +++ b/src/proc/mobject/session/defsmanager.hpp @@ -27,10 +27,6 @@ #include "common/query.hpp" -//#include -//#include - -//using std::vector; #include @@ -63,6 +59,12 @@ namespace mobject template shared_ptr operator() (const cinelerra::Query&); +// template +// < class TAR, ///< the target to query for +// template class SMP ///< smart pointer class to wrap the result +// > +// SMP operator() (const cinelerra::Query&); + };