本文整理汇总了C++中Answer::use方法的典型用法代码示例。如果您正苦于以下问题:C++ Answer::use方法的具体用法?C++ Answer::use怎么用?C++ Answer::use使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Answer
的用法示例。
在下文中一共展示了Answer::use方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saturate_oatom
void
ArgSemExtAtom::retrieve(const Query& query, Answer& answer) throw (PluginError)
{
assert(query.input.size() == 6);
RegistryPtr reg = getRegistry();
// check if pspoil is true
{
// id of constant of saturate/spoil predicate
ID saturate_pred = query.input[4];
// get id of 0-ary atom
OrdinaryAtom saturate_oatom(ID::MAINKIND_ATOM | ID::SUBKIND_ATOM_ORDINARYG);
saturate_oatom.tuple.push_back(saturate_pred);
ID saturate_atom = reg->storeOrdinaryGAtom(saturate_oatom);
DBGLOG(DBG,"got saturate_pred=" << saturate_pred << " and saturate_atom=" << saturate_atom);
// check if atom <saturate_pred> is true in interpretation
bool saturate = query.interpretation->getFact(saturate_atom.address);
LOG(DBG,"ArgSemExtAtom called with pos saturate=" << saturate);
if( saturate )
{
// always return true
answer.get().push_back(Tuple());
return;
}
}
// check if nspoil is true
{
// id of constant of saturate/spoil predicate
ID saturate_pred = query.input[5];
// get id of 0-ary atom
OrdinaryAtom saturate_oatom(ID::MAINKIND_ATOM | ID::SUBKIND_ATOM_ORDINARYG);
saturate_oatom.tuple.push_back(saturate_pred);
ID saturate_atom = reg->storeOrdinaryGAtom(saturate_oatom);
DBGLOG(DBG,"got saturate_pred=" << saturate_pred << " and saturate_atom=" << saturate_atom);
// check if atom <saturate_pred> is true in interpretation
bool saturate = query.interpretation->getFact(saturate_atom.address);
LOG(DBG,"ArgSemExtAtom called with neg saturate=" << saturate);
if( saturate )
{
// always return false
answer.use();
return;
}
}
// get arguments
const std::string& semantics = reg->getTermStringByID(query.input[0]);
ID argRelId = query.input[1];
ID attRelId = query.input[2];
ID extRelId = query.input[3];
// assemble facts from input
std::stringstream s;
{
// add argumentation framework (att, arg) as predicates att/2 and arg/1
// (ignore predicate name of given atoms)
// TODO: we could do this more efficiently using extctx.edb->setFact(...); and not by parsing
// arguments
{
PredicateMask& argMask = getPredicateMask(argRelId, reg);
argMask.updateMask();
InterpretationPtr argInt(new Interpretation(*query.interpretation));
argInt->bit_and(*argMask.mask());
for(auto begend = argInt->trueBits(); begend.first != begend.second; ++begend.first++)
{
auto bit_it = begend.first;
const OrdinaryAtom& atom = argInt->getAtomToBit(bit_it);
assert(atom.tuple.size() == 2);
s << "arg(" << printToString<RawPrinter>(atom.tuple[1], reg) << ").\n";
}
}
// attacks
{
PredicateMask& attMask = getPredicateMask(attRelId, reg);
attMask.updateMask();
InterpretationPtr attInt(new Interpretation(*query.interpretation));
attInt->bit_and(*attMask.mask());
for(auto begend = attInt->trueBits(); begend.first != begend.second; ++begend.first++)
{
auto bit_it = begend.first;
const OrdinaryAtom& atom = attInt->getAtomToBit(bit_it);
assert(atom.tuple.size() == 3);
s << "att(" << printToString<RawPrinter>(atom.tuple[1], reg) << "," << printToString<RawPrinter>(atom.tuple[2], reg) << ").\n";
}
}
// extension to check
{
PredicateMask& extMask = getPredicateMask(extRelId, reg);
//.........这里部分代码省略.........