early draft how the Prolog interface /could/ be...
(need to draft it in order to provide a mock implementation)
This commit is contained in:
parent
430f38ab2f
commit
b0be36c8fb
3 changed files with 67 additions and 18 deletions
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
|
||||
#include "common/configrules.hpp"
|
||||
#include "common/query/mockconfigrules.hpp"
|
||||
//#include "common/util.hpp"
|
||||
#include "nobugcfg.h"
|
||||
|
||||
|
|
@ -38,7 +39,7 @@ namespace cinelerra
|
|||
|
||||
|
||||
/** storage for the Singleton instance factory */
|
||||
Singleton<ConfigRules> ConfigRules::instance;
|
||||
Singleton<query::MockConfigRules> ConfigRules::instance;
|
||||
|
||||
|
||||
} // namespace cinelerra
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@
|
|||
namespace cinelerra
|
||||
{
|
||||
using std::string;
|
||||
namespace query { class MockConfigRules; }
|
||||
|
||||
|
||||
/**
|
||||
* Generic query interface for retrieving objects matching
|
||||
|
|
@ -62,16 +64,62 @@ namespace cinelerra
|
|||
class ConfigRules
|
||||
{
|
||||
protected:
|
||||
ConfigRules ();
|
||||
friend class cinelerra::singleton::StaticCreate<ConfigRules>;
|
||||
ConfigRules () {}
|
||||
virtual ~ConfigRules() {}
|
||||
|
||||
public:
|
||||
static Singleton<ConfigRules> instance;
|
||||
static Singleton<query::MockConfigRules> instance;
|
||||
|
||||
// TODO: find out what operations we need to support here for the »real solution« (using Prolog)
|
||||
};
|
||||
|
||||
|
||||
namespace query
|
||||
{
|
||||
// The intention is to support the following style of Prolog code
|
||||
//
|
||||
// retrieve(T) :- type(T, track), find(T), capabilities(T).
|
||||
// retrieve(T) :- type(T, track), make(T), capabilities(T).
|
||||
//
|
||||
// capabilities(T) :- stream(T,mpeg).
|
||||
// stream(T, mpeg) :- type(T, track), type(P, port), retrieve(P), place_to(P, T).
|
||||
//
|
||||
// The type guard is inserted auomatically, while the predicate implementations for
|
||||
// find/1, make/1, stream/2, and place_to/2 are to be provided by the target types.
|
||||
|
||||
class Resolver
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
typedef const char * const Symbol;
|
||||
|
||||
template
|
||||
< const Symbol SYM, // Predicate symbol
|
||||
typename SIG = bool(string) // Signature
|
||||
>
|
||||
class Pred
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
template<class TY>
|
||||
class TypeHandler
|
||||
{
|
||||
static const TY NIL;
|
||||
|
||||
template<Symbol SYM, typename SIG>
|
||||
TY find (Pred<SYM,SIG> capability);
|
||||
|
||||
template<Symbol SYM, typename SIG>
|
||||
TY make (Pred<SYM,SIG> capability, TY& refObj =NIL);
|
||||
};
|
||||
|
||||
template<class TY>
|
||||
class QueryHandler
|
||||
{
|
||||
TY resolve (Query<TY> q);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -48,23 +48,23 @@ namespace cinelerra
|
|||
{
|
||||
using std::string;
|
||||
|
||||
/**
|
||||
* Generic query interface for retrieving objects matching
|
||||
* some capability query
|
||||
*/
|
||||
class MockConfigRules
|
||||
{
|
||||
protected:
|
||||
MockConfigRules ();
|
||||
friend class cinelerra::singleton::StaticCreate<MockConfigRules>;
|
||||
|
||||
public:
|
||||
};
|
||||
|
||||
|
||||
|
||||
namespace query
|
||||
{
|
||||
|
||||
/**
|
||||
* Generic query interface for retrieving objects matching
|
||||
* some capability query
|
||||
*/
|
||||
class MockConfigRules : public ConfigRules
|
||||
{
|
||||
protected:
|
||||
MockConfigRules ();
|
||||
friend class cinelerra::singleton::StaticCreate<MockConfigRules>;
|
||||
|
||||
public:
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace query
|
||||
|
|
|
|||
Loading…
Reference in a new issue