diff --git a/src/common/configrules.cpp b/src/common/configrules.cpp index 3213df15a..794f402d9 100644 --- a/src/common/configrules.cpp +++ b/src/common/configrules.cpp @@ -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::instance; + Singleton ConfigRules::instance; } // namespace cinelerra diff --git a/src/common/configrules.hpp b/src/common/configrules.hpp index 265cae29e..fe716a423 100644 --- a/src/common/configrules.hpp +++ b/src/common/configrules.hpp @@ -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 () {} + virtual ~ConfigRules() {} public: - static Singleton instance; + static Singleton 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 TypeHandler + { + static const TY NIL; + + template + TY find (Pred capability); + + template + TY make (Pred capability, TY& refObj =NIL); + }; + + template + class QueryHandler + { + TY resolve (Query q); + }; diff --git a/src/common/query/mockconfigrules.hpp b/src/common/query/mockconfigrules.hpp index 4d942dd29..3bcf98969 100644 --- a/src/common/query/mockconfigrules.hpp +++ b/src/common/query/mockconfigrules.hpp @@ -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; - - public: - }; - - + namespace query { + /** + * Generic query interface for retrieving objects matching + * some capability query + */ + class MockConfigRules : public ConfigRules + { + protected: + MockConfigRules (); + friend class cinelerra::singleton::StaticCreate; + + public: + }; + } // namespace query