dlvhex  2.5.0
ComfortAtom Struct Reference

String-based Atom object (comfort interface). More...

#include <include/dlvhex2/ComfortPluginInterface.h>

Inheritance diagram for ComfortAtom:
Collaboration diagram for ComfortAtom:

Public Member Functions

const std::string & toString () const
 Return string representation (cached).
bool operator< (const ComfortAtom &other) const
 Compare atoms.
std::ostream & print (std::ostream &o) const
 Print atom (using ostream_printable<T>).
const std::string & getPredicate () const
 Return predicate symbol.
const ComfortTuple getArguments () const
 Return arguments of the atom as ComfortTerm.
const ComfortTerm getArgument (int index) const
 Return a single argument of the atom as ComfortTerm.
unsigned getArity () const
 Retrieves the arity of the atom.
unsigned isStrongNegated () const
 Checks if the atom is a strongly negated one.
void setArgument (int index, ComfortTerm arg)
 Reassignes an argument of the atom.
void setArguments (ComfortTuple args)
 Reassignes all arguments of the atom.
 ComfortAtom ()
 Constructor.
 ComfortAtom (ComfortTerm pred, ComfortTuple args, bool stronglyNegated=false)
 Constructor.
bool unifiesWith (const ComfortAtom &other) const
 Check whether one atom unifies with another one.

Data Fields

ComfortTuple tuple
 Content of the atom, represented as tuple.

Protected Member Functions

void calculateStrVal () const
 Calculate cached string representation.

Protected Attributes

std::string strval
 Cached string representation.

Detailed Description

String-based Atom object (comfort interface).

This atom object stores atoms consisting of ComfortTerms.

You can stream instances of this class into std::ostream&.

Note that strong negation, e.g., `-a' or `-b(c,d)' currently has undefined behavior with comfort interface, as strong negation is implemented as a plugin with auxiliaries.

Definition at line 280 of file ComfortPluginInterface.h.


Constructor & Destructor Documentation

Constructor.

Definition at line 386 of file ComfortPluginInterface.h.

ComfortAtom::ComfortAtom ( ComfortTerm  pred,
ComfortTuple  args,
bool  stronglyNegated = false 
) [inline]

Constructor.

Parameters:
predPredicate. args Arguments.
Trueto create a strongly negated atom.

Definition at line 392 of file ComfortPluginInterface.h.


Member Function Documentation

void ComfortAtom::calculateStrVal ( ) const [protected]

Calculate cached string representation.

Definition at line 139 of file ComfortPluginInterface.cpp.

References strval, and tuple.

const ComfortTerm ComfortAtom::getArgument ( int  index) const [inline]

Return a single argument of the atom as ComfortTerm.

Parameters:
indexIndex of the argument to retrieve.
Returns:
Argument index of the atom as ComfortTerm.

Definition at line 343 of file ComfortPluginInterface.h.

const ComfortTuple ComfortAtom::getArguments ( ) const [inline]

Return arguments of the atom as ComfortTerm.

Returns:
Arguments of the atom as ComfortTerm.

Definition at line 330 of file ComfortPluginInterface.h.

unsigned ComfortAtom::getArity ( ) const [inline]

Retrieves the arity of the atom.

Parameters:
Arityof the atom.

Definition at line 351 of file ComfortPluginInterface.h.

const std::string& ComfortAtom::getPredicate ( ) const [inline]

Return predicate symbol.

Returns:
Predicate symbol of the atom as string.

Definition at line 320 of file ComfortPluginInterface.h.

unsigned ComfortAtom::isStrongNegated ( ) const [inline]

Checks if the atom is a strongly negated one.

Returns:
True if the atom is strongly negated and false otherwise.

Definition at line 358 of file ComfortPluginInterface.h.

References ComfortTerm::strval.

bool ComfortAtom::operator< ( const ComfortAtom other) const [inline]

Compare atoms.

We require this for storing ComfortAtom in sets.

Parameters:
otherAtom to compare to.
Returns:
True if this atom is smaller than other and false otherwise.

Definition at line 304 of file ComfortPluginInterface.h.

References tuple.

std::ostream & ComfortAtom::print ( std::ostream &  o) const

Print atom (using ostream_printable<T>).

Non-virtual on purpose. (see Printhelpers.h)

Parameters:
oStream to print to.
Returns:
o.

Definition at line 160 of file ComfortPluginInterface.cpp.

References toString().

void ComfortAtom::setArgument ( int  index,
ComfortTerm  arg 
) [inline]

Reassignes an argument of the atom.

Parameters:
indexIndex of the argument to reassign.
argNew value.

Definition at line 368 of file ComfortPluginInterface.h.

void ComfortAtom::setArguments ( ComfortTuple  args) [inline]

Reassignes all arguments of the atom.

Parameters:
argsNew values.

Definition at line 375 of file ComfortPluginInterface.h.

const std::string& ComfortAtom::toString ( ) const [inline]

Return string representation (cached).

Returns:
String representation.

Definition at line 294 of file ComfortPluginInterface.h.

Referenced by print().

bool ComfortAtom::unifiesWith ( const ComfortAtom other) const

Check whether one atom unifies with another one.

Parameters:
otherAtom to compare to.
Returns:
True if this atom unifies with other and false otherwise.

Definition at line 66 of file ComfortPluginInterface.cpp.

References DBGLOG, DBGLOG_SCOPE, printvector(), and tuple.


Field Documentation

std::string ComfortAtom::strval [mutable, protected]

Cached string representation.

Definition at line 412 of file ComfortPluginInterface.h.

Referenced by calculateStrVal().

Content of the atom, represented as tuple.

First term is predicate, other terms are arguments.

Definition at line 288 of file ComfortPluginInterface.h.

Referenced by calculateStrVal(), operator<(), TestCAtom::retrieve(), ComfortPluginAtom::retrieve(), TestSetMinusAtom::retrieve(), and unifiesWith().


The documentation for this struct was generated from the following files: