dlvhex
2.5.0
|
String-based PluginAtom interface (comfort interface). More...
#include <include/dlvhex2/ComfortPluginInterface.h>
Data Structures | |
struct | ComfortQuery |
Query class which provides the input of an external atom call. More... | |
Public Types | |
typedef std::set< ComfortTuple > | ComfortAnswer |
Answer type. | |
Public Member Functions | |
ComfortPluginAtom (const std::string &predicate, bool monotonic=false) | |
Constructor. | |
virtual | ~ComfortPluginAtom () |
Destructor. | |
virtual void | retrieve (const ComfortQuery &q, ComfortAnswer &a)=0 |
Retrieve answer to a query (external computation happens here). | |
Protected Member Functions | |
virtual void | retrieve (const Query &q, Answer &a) |
Implementation of non-comfort interface. |
String-based PluginAtom interface (comfort interface).
This is similar to the interface in the dlvhex 1.X and does not require knowledge of the dlvhex 2.X system of IDs and Registry.
Definition at line 524 of file ComfortPluginInterface.h.
typedef std::set<ComfortTuple> ComfortPluginAtom::ComfortAnswer |
Answer type.
As answer tuples are not sorted, and duplicates are irrelevant, this type can be a set, which allows to do a more sloppy implementation of ComfortPluginAtom::retrieve().
Definition at line 562 of file ComfortPluginInterface.h.
ComfortPluginAtom::ComfortPluginAtom | ( | const std::string & | predicate, |
bool | monotonic = false |
||
) | [inline] |
Constructor.
As in PluginAtom, your constructor must set predicate and monotonicity, and use addInput...() methods to define inputs and must use setOutputArity().
predicate | External predicate to be defined by this class. |
monotonic | True to indicate that the external atom is monotonic in all input parameters. |
Definition at line 573 of file ComfortPluginInterface.h.
virtual ComfortPluginAtom::~ComfortPluginAtom | ( | ) | [inline, virtual] |
Destructor.
Definition at line 579 of file ComfortPluginInterface.h.
virtual void ComfortPluginAtom::retrieve | ( | const ComfortQuery & | q, |
ComfortAnswer & | a | ||
) | [pure virtual] |
Retrieve answer to a query (external computation happens here).
This function implements the external atom computation. See also documentation of Query and Answer classes.
Answer tuples must conform to the content of the pattern tuple in Query:
q | See ComfortPluginAtom::ComfortQuery. |
a | See ComfortPluginAtom::ComfortAnswer. |
Implemented in TestOddAtom, TestEvenAtom, TestMinusOneAtom, TestSetMinusAtom, TestCAtom, TestBAtom, and TestAAtom.
Referenced by retrieve().
void ComfortPluginAtom::retrieve | ( | const Query & | q, |
Answer & | a | ||
) | [protected, virtual] |
Implementation of non-comfort interface.
* convert ID-based query to ComfortQuery * call comfort-retrieve * convert ComfortAnswer to ID-based answer tuples
This maps the comfort retrieve() and comfort data types to the non-comfort retriefe() and dlvhex core data types.
This method will never need to be overloaded.
q | See ComfortPluginAtom::ComfortQuery. |
a | See ComfortPluginAtom::ComfortAnswer. |
Reimplemented from PluginAtom.
Definition at line 356 of file ComfortPluginInterface.cpp.
References DBGLOG, DBGLOG_SCOPE, PluginAtom::Answer::get(), PluginAtom::getRegistry(), ComfortPluginAtom::ComfortQuery::input, PluginAtom::Query::input, ComfortInterpretation::insert(), ComfortPluginAtom::ComfortQuery::interpretation, PluginAtom::Query::interpretation, ID::MAINKIND_ATOM, ComfortPluginAtom::ComfortQuery::pattern, PluginAtom::Query::pattern, printrange(), printset(), retrieve(), ID::SUBKIND_ATOM_ORDINARYG, Atom::tuple, and ComfortAtom::tuple.