Skip to content

Commit

Permalink
Restore some of the older code, python needs it
Browse files Browse the repository at this point in the history
  • Loading branch information
linas committed Dec 23, 2014
1 parent 513d3e5 commit 84913d2
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 20 deletions.
30 changes: 30 additions & 0 deletions opencog/query/PatternSCM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
* Copyright (c) 2008, 2014 Linas Vepstas <[email protected]>
*/

#include <opencog/util/foreach.h>
#include <opencog/atomspace/AtomSpace.h>
#include <opencog/guile/SchemePrimitive.h>
#include <opencog/guile/SchemeSmob.h>

#include "BindLink.h"
#include "PatternMatch.h"
#include "PatternSCM.h"

using namespace opencog;
Expand All @@ -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;
}

10 changes: 10 additions & 0 deletions opencog/query/PatternSCM.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ class PatternWrap
PatternWrap(Handle (*)(AtomSpace*, Handle), const char*);
};

class PatternSCM
{
private:
std::vector<PatternWrap*> _binders;
public:
PatternSCM(void);
~PatternSCM();
};


}

#endif // _OPENCOG_PATTERN_SCM_H
Expand Down
22 changes: 3 additions & 19 deletions opencog/query/QueryModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,23 @@
* Copyright (c) 2008 Linas Vepstas <[email protected]>
*/

#include "BindLink.h"
#include "PatternMatch.h"
#include "PatternSCM.h"
#include "QueryModule.h"

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();
}
2 changes: 1 addition & 1 deletion opencog/query/QueryModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace opencog {
class QueryModule : public Module
{
private:
std::vector<PatternWrap*> _binders;
PatternSCM* _pat;
public:
QueryModule(CogServer&);
virtual ~QueryModule();
Expand Down

0 comments on commit 84913d2

Please sign in to comment.