diff --git a/opencog/query/PatternSCM.cc b/opencog/query/PatternSCM.cc index ea61c333e51..a41f8493225 100644 --- a/opencog/query/PatternSCM.cc +++ b/opencog/query/PatternSCM.cc @@ -5,10 +5,13 @@ * Copyright (c) 2008, 2014 Linas Vepstas */ +#include #include #include #include +#include "BindLink.h" +#include "PatternMatch.h" #include "PatternSCM.h" using namespace opencog; @@ -30,3 +33,30 @@ Handle PatternWrap::wrapper(Handle h) return Handle::UNDEFINED; #endif } + +// ======================================================== + +PatternSCM::PatternSCM(void) +{ + // Run implication, assuming that the argument is a handle to + // an BindLink containing variables and an ImplicationLink. + _binders.push_back(new PatternWrap(bindlink, "cog-bind")); + + // Identical to do_bindlink above, except that it only returns the + // first match. + _binders.push_back(new PatternWrap(single_bindlink, "cog-bind-single")); + + // Run implication, assuming that the argument is a handle to + // an BindLink containing variables and an ImplicationLink + _binders.push_back(new PatternWrap(crisp_logic_bindlink, "cog-bind-crisp")); + + // Mystery function + _binders.push_back(new PatternWrap(pln_bindlink, "cog-bind-pln")); +} + +PatternSCM::~PatternSCM() +{ + foreach (PatternWrap* pw, _binders) + delete pw; +} + diff --git a/opencog/query/PatternSCM.h b/opencog/query/PatternSCM.h index b0894ecfe64..cb30003a8ff 100644 --- a/opencog/query/PatternSCM.h +++ b/opencog/query/PatternSCM.h @@ -25,6 +25,16 @@ class PatternWrap PatternWrap(Handle (*)(AtomSpace*, Handle), const char*); }; +class PatternSCM +{ + private: + std::vector _binders; + public: + PatternSCM(void); + ~PatternSCM(); +}; + + } #endif // _OPENCOG_PATTERN_SCM_H diff --git a/opencog/query/QueryModule.cc b/opencog/query/QueryModule.cc index c3e5861b819..d0b58516acc 100644 --- a/opencog/query/QueryModule.cc +++ b/opencog/query/QueryModule.cc @@ -5,8 +5,6 @@ * Copyright (c) 2008 Linas Vepstas */ -#include "BindLink.h" -#include "PatternMatch.h" #include "PatternSCM.h" #include "QueryModule.h" @@ -14,30 +12,16 @@ using namespace opencog; DECLARE_MODULE(QueryModule); -QueryModule::QueryModule(CogServer& cs) : Module(cs) +QueryModule::QueryModule(CogServer& cs) : Module(cs), _pat(NULL) { } QueryModule::~QueryModule() { - foreach(PatternWrap *pw: _binders) - delete pw; + delete _pat; } void QueryModule::init(void) { - // Run implication, assuming that the argument is a handle to - // an BindLink containing variables and an ImplicationLink. - _binders.push_back(new PatternWrap(bindlink, "cog-bind")); - - // Identical to do_bindlink above, except that it only returns the - // first match. - _binders.push_back(new PatternWrap(single_bindlink, "cog-bind-single")); - - // Run implication, assuming that the argument is a handle to - // an BindLink containing variables and an ImplicationLink - _binders.push_back(new PatternWrap(crisp_logic_bindlink, "cog-bind-crisp")); - - // Mystery function - _binders.push_back(new PatternWrap(pln_bindlink, "cog-bind-pln")); + _pat = new PatternSCM(); } diff --git a/opencog/query/QueryModule.h b/opencog/query/QueryModule.h index 18b962270d0..520d8cc2ace 100644 --- a/opencog/query/QueryModule.h +++ b/opencog/query/QueryModule.h @@ -17,7 +17,7 @@ namespace opencog { class QueryModule : public Module { private: - std::vector _binders; + PatternSCM* _pat; public: QueryModule(CogServer&); virtual ~QueryModule();