forked from opencog/atomspace
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce MeetLink as non Set-using version of GetLink
This partly resolves issues opencog#2530 and opencog#1502
- Loading branch information
Showing
6 changed files
with
136 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* MeetLink.cc | ||
* | ||
* Copyright (C) 2019 Linas Vepstas | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License v3 as | ||
* published by the Free Software Foundation and including the | ||
* exceptions at http://opencog.org/wiki/Licenses | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public | ||
* License along with this program; if not, write to: | ||
* Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
|
||
#include <opencog/util/oc_assert.h> | ||
#include <opencog/atoms/atom_types/NameServer.h> | ||
#include <opencog/atoms/core/UnorderedLink.h> | ||
#include <opencog/query/Satisfier.h> | ||
|
||
#include "MeetLink.h" | ||
|
||
using namespace opencog; | ||
|
||
void MeetLink::init(void) | ||
{ | ||
Type t = get_type(); | ||
if (not nameserver().isA(t, MEET_LINK)) | ||
{ | ||
const std::string& tname = nameserver().getTypeName(t); | ||
throw InvalidParamException(TRACE_INFO, | ||
"Expecting a MeetLink, got %s", tname.c_str()); | ||
} | ||
} | ||
|
||
MeetLink::MeetLink(const HandleSeq&& hseq, Type t) | ||
: PatternLink(std::move(hseq), t) | ||
{ | ||
init(); | ||
} | ||
|
||
/* ================================================================= */ | ||
|
||
QueueValuePtr MeetLink::do_execute(AtomSpace* as, bool silent) | ||
{ | ||
if (nullptr == as) as = _atom_space; | ||
|
||
SatisfyingSet sater(as); | ||
this->satisfy(sater); | ||
|
||
return sater.get_result_queue(); | ||
} | ||
|
||
ValuePtr MeetLink::execute(AtomSpace* as, bool silent) | ||
{ | ||
return do_execute(as, silent); | ||
} | ||
|
||
DEFINE_LINK_FACTORY(MeetLink, MEET_LINK) | ||
|
||
/* ===================== END OF FILE ===================== */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* opencog/atoms/pattern/MeetLink.h | ||
* | ||
* Copyright (C) 2019 Linas Vepstas | ||
* All Rights Reserved | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License v3 as | ||
* published by the Free Software Foundation and including the exceptions | ||
* at http://opencog.org/wiki/Licenses | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program; if not, write to: | ||
* Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
#ifndef _OPENCOG_MEET_LINK_H | ||
#define _OPENCOG_MEET_LINK_H | ||
|
||
#include <opencog/atoms/pattern/PatternLink.h> | ||
|
||
namespace opencog | ||
{ | ||
/** \addtogroup grp_atomspace | ||
* @{ | ||
*/ | ||
class MeetLink : public PatternLink | ||
{ | ||
protected: | ||
void init(void); | ||
virtual QueueValuePtr do_execute(AtomSpace*, bool silent); | ||
|
||
public: | ||
MeetLink(const HandleSeq&&, Type=MEET_LINK); | ||
|
||
MeetLink(const MeetLink&) = delete; | ||
MeetLink operator=(const MeetLink&) = delete; | ||
|
||
virtual bool is_executable() const { return true; } | ||
virtual ValuePtr execute(AtomSpace*, bool silent=false); | ||
|
||
static Handle factory(const Handle&); | ||
}; | ||
|
||
typedef std::shared_ptr<MeetLink> MeetLinkPtr; | ||
static inline MeetLinkPtr MeetLinkCast(const Handle& h) | ||
{ AtomPtr a(h); return std::dynamic_pointer_cast<MeetLink>(a); } | ||
static inline MeetLinkPtr MeetLinkCast(AtomPtr a) | ||
{ return std::dynamic_pointer_cast<MeetLink>(a); } | ||
|
||
#define createMeetLink std::make_shared<MeetLink> | ||
|
||
/** @}*/ | ||
} | ||
|
||
#endif // _OPENCOG_MEET_LINK_H |