diff --git a/src/common/query/mockconfigrules.cpp b/src/common/query/mockconfigrules.cpp index 15181c24e..29286e920 100644 --- a/src/common/query/mockconfigrules.cpp +++ b/src/common/query/mockconfigrules.cpp @@ -65,16 +65,23 @@ namespace cinelerra Query query(caps); Ptr obj = Struct::create (query); - return AnyPair(query, obj); + return AnyPair(query.asKey(), obj); } } - /** hard coded answers to configuration queries */ + /** hard coded answers to configuration queries. + * @note while filling the table re-entrace + * will be quite common, so the order of + * creating the objects is important. + */ void MockTable::fill_mock_table () { + INFO (config, "creating mock answers for some config queries..."); + isInit_ = true; // allow re-entrance + // for baiscporttest.cpp --------- answer_->insert (entry_Struct ("stream(teststream)")); } @@ -86,11 +93,11 @@ namespace cinelerra WARN (config, "using a mock implementation of the ConfigQuery interface"); } + MockTable::MockTable () - : answer_(new Tab()) - { - fill_mock_table (); - } + : answer_(new Tab()), + isInit_(false) + { } @@ -109,6 +116,7 @@ namespace cinelerra MockTable::fetch_from_table_for (const string& queryStr) { static const any NOTFOUND; + if (!isInit_) fill_mock_table(); Tab::iterator i = answer_->find (queryStr); if (i == answer_->end()) diff --git a/src/common/query/mockconfigrules.hpp b/src/common/query/mockconfigrules.hpp index 5e256a3b5..7b6ce6374 100644 --- a/src/common/query/mockconfigrules.hpp +++ b/src/common/query/mockconfigrules.hpp @@ -67,10 +67,10 @@ namespace cinelerra /** a traits-class to define the smart-ptr to wrap the result */ template - struct WrapReturn { typedef shared_ptr Wrapper; }; + struct WrapReturn { typedef shared_ptr Wrapper; }; template<> - struct WrapReturn { typedef PProcPatt Wrapper; }; + struct WrapReturn { typedef PProcPatt Wrapper; }; /** @@ -83,6 +83,7 @@ namespace cinelerra typedef boost::scoped_ptr PTab; PTab answer_; + bool isInit_; protected: MockTable (); diff --git a/src/proc/asset/port.cpp b/src/proc/asset/port.cpp index 08b7dd38f..e7a998f40 100644 --- a/src/proc/asset/port.cpp +++ b/src/proc/asset/port.cpp @@ -46,6 +46,7 @@ namespace asset Port::Port (PProcPatt& wiring, string portID, wstring shortDesc, wstring longDesc) : Struct (createPortIdent (wiring,portID,shortDesc,longDesc)), portID_ (portID), + wiringTemplate(wiring), shortDesc (shortDesc), longDesc (longDesc) { diff --git a/src/proc/asset/port.hpp b/src/proc/asset/port.hpp index c42af656b..7fd23fe32 100644 --- a/src/proc/asset/port.hpp +++ b/src/proc/asset/port.hpp @@ -53,8 +53,8 @@ namespace asset */ class Port : public Struct { - PProcPatt wiringTemplate; string portID_; + PProcPatt wiringTemplate; public: wstring shortDesc; diff --git a/src/proc/asset/structfactoryimpl.hpp b/src/proc/asset/structfactoryimpl.hpp index 50b45c21f..ae53e645a 100644 --- a/src/proc/asset/structfactoryimpl.hpp +++ b/src/proc/asset/structfactoryimpl.hpp @@ -62,8 +62,8 @@ namespace asset template<> Symbol Traits::namePrefix = "port-"; template<> Symbol Traits::catFolder = "ports"; - template<> Symbol Traits::namePrefix = "patt-"; - template<> Symbol Traits::catFolder = "build-templates"; + template<> Symbol Traits::namePrefix = "patt-"; + template<> Symbol Traits::catFolder = "build-templates"; @@ -121,7 +121,7 @@ namespace asset template STRU* fabricate (const Query& caps) { - throw cinelerra::error::Config ( str(format("The following Query could not be resolved: %s.") % caps) + throw cinelerra::error::Config ( str(format("The following Query could not be resolved: %s.") % caps.asKey()) , CINELERRA_ERROR_CAPABILITY_QUERY ); } @@ -135,12 +135,13 @@ namespace asset StructFactoryImpl::fabricate (const Query& caps) { TODO ("actually extract properties/capabilities from the query..."); + TODO ("make sure AssetManager detects dublicates (it doesn't currently)"); return new Track (createIdent (caps)); } template<> - ProcPatt* - StructFactoryImpl::fabricate (const Query& caps) + const ProcPatt* + StructFactoryImpl::fabricate (const Query& caps) { TODO ("actually extract properties/capabilities from the query..."); return new ProcPatt (createIdent (caps)); diff --git a/src/proc/mobject/session/defsmanager.cpp b/src/proc/mobject/session/defsmanager.cpp index 71e7f8549..f5688bbfd 100644 --- a/src/proc/mobject/session/defsmanager.cpp +++ b/src/proc/mobject/session/defsmanager.cpp @@ -61,7 +61,7 @@ namespace mobject if (!res) throw cinelerra::error::Config ( str(format("The following Query could not be resolved: %s.") - % capabilities) + % capabilities.asKey()) , CINELERRA_ERROR_CAPABILITY_QUERY ); else return res; diff --git a/wiki/renderengine.html b/wiki/renderengine.html index 31914ac20..f86d20ff0 100644 --- a/wiki/renderengine.html +++ b/wiki/renderengine.html @@ -797,7 +797,7 @@ Error: #f88 &rarr; [[Configuration Rules system|ConfigRules]] -
+
Many features can be implemented by specifically configuring and wiring some unspecific components. Rather than tie the client code in need of some given feature to these configuration internals, in Cinelerra-3 the client can //query // for some kind of object providing the //needed capabilities. // Right from start (summer 2007), Ichthyo had the intention to implement such a feature using sort of a ''declarative database'', e.g. by embedding a Prolog system. By adding rules to the basic session configuration, users should be able to customize the semi-automatic part of Cinelerra's behaviour to great extent.
 
 [[Configuration Queries|ConfigQuery]] are used at various places, when creating and adding new objects, as well when building or optimizing the render engine node network.
@@ -816,6 +816,8 @@ Actually posing such an configuration query, for example to the [[Defaults Manag
 !Implementation
 At start and for debugging/testing, there is an ''dummy'' implementation using a map with predefined queries and answers. But for the real system, the idea is to embed a ''YAP Prolog'' engine to run the queries. This includes the task of defining and loading a set of custom predicates, so the rule system can interact with the object oriented execution environment, for example by transforming some capability predicate into virtual calls to a corresponding object interface. We need a way for objects to declare some capability predicates, together with a functor that can be executed on an object instance (and further parameters) in the cause of the evaluation of some configuration query. Type safety and diagnostics play an important role here, because effectively the rule base is a pool of code open for arbitray additions from the user session.
 &rarr; [[considerations for a Prolog based implementation|QueryImplProlog]]
+&rarr; see {{{src/common/query/mockconfigrules.cpp}}} for the table with the hard wired (mock) answers
+