make the MockConfigQuery reentrant.
Basic asset::Struct factory now running (utilizing the MockConfigQuery). basicporttest.cpp not yet running, but get some lines ahead :-P
This commit is contained in:
parent
d33242b8cb
commit
c77e245f54
7 changed files with 29 additions and 16 deletions
|
|
@ -65,16 +65,23 @@ namespace cinelerra
|
|||
|
||||
Query<STRU> 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<const ProcPatt> ("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())
|
||||
|
|
|
|||
|
|
@ -67,10 +67,10 @@ namespace cinelerra
|
|||
|
||||
/** a traits-class to define the smart-ptr to wrap the result */
|
||||
template<class TY>
|
||||
struct WrapReturn { typedef shared_ptr<TY> Wrapper; };
|
||||
struct WrapReturn { typedef shared_ptr<TY> Wrapper; };
|
||||
|
||||
template<>
|
||||
struct WrapReturn<const ProcPatt> { typedef PProcPatt Wrapper; };
|
||||
struct WrapReturn<ProcPatt> { typedef PProcPatt Wrapper; };
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -83,6 +83,7 @@ namespace cinelerra
|
|||
typedef boost::scoped_ptr<Tab> PTab;
|
||||
|
||||
PTab answer_;
|
||||
bool isInit_;
|
||||
|
||||
protected:
|
||||
MockTable ();
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ namespace asset
|
|||
*/
|
||||
class Port : public Struct
|
||||
{
|
||||
PProcPatt wiringTemplate;
|
||||
string portID_;
|
||||
PProcPatt wiringTemplate;
|
||||
|
||||
public:
|
||||
wstring shortDesc;
|
||||
|
|
|
|||
|
|
@ -62,8 +62,8 @@ namespace asset
|
|||
template<> Symbol Traits<Port>::namePrefix = "port-";
|
||||
template<> Symbol Traits<Port>::catFolder = "ports";
|
||||
|
||||
template<> Symbol Traits<ProcPatt>::namePrefix = "patt-";
|
||||
template<> Symbol Traits<ProcPatt>::catFolder = "build-templates";
|
||||
template<> Symbol Traits<const ProcPatt>::namePrefix = "patt-";
|
||||
template<> Symbol Traits<const ProcPatt>::catFolder = "build-templates";
|
||||
|
||||
|
||||
|
||||
|
|
@ -121,7 +121,7 @@ namespace asset
|
|||
template<class STRU>
|
||||
STRU* fabricate (const Query<STRU>& 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<Track>& 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<ProcPatt>& caps)
|
||||
const ProcPatt*
|
||||
StructFactoryImpl::fabricate (const Query<const ProcPatt>& caps)
|
||||
{
|
||||
TODO ("actually extract properties/capabilities from the query...");
|
||||
return new ProcPatt (createIdent (caps));
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -797,7 +797,7 @@ Error: #f88</pre>
|
|||
&rarr; [[Configuration Rules system|ConfigRules]]
|
||||
</pre>
|
||||
</div>
|
||||
<div title="ConfigRules" modifier="Ichthyostega" modified="200801202311" created="200801171352" tags="overview spec" changecount="7">
|
||||
<div title="ConfigRules" modifier="Ichthyostega" modified="200802130339" created="200801171352" tags="overview spec" changecount="8">
|
||||
<pre>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
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
<div title="Controller" modifier="Ichthyostega" modified="200712090624" created="200706220319" tags="def" changecount="4">
|
||||
|
|
|
|||
Loading…
Reference in a new issue