dlvhex  2.5.0
OrdinaryAtomTable Class Reference

Implements a lookup table for ordinary atoms. More...

#include <include/dlvhex2/OrdinaryAtomTable.h>

Inheritance diagram for OrdinaryAtomTable:
Collaboration diagram for OrdinaryAtomTable:

Public Types

typedef Container::index
< impl::AddressTag >::type 
AddressIndex
typedef Container::index
< impl::TextTag >::type 
TextIndex
typedef Container::index
< impl::TupleTag >::type 
TupleIndex
typedef Container::index
< impl::PredicateTag >::type 
PredicateIndex
typedef AddressIndex::iterator AddressIterator
typedef PredicateIndex::iterator PredicateIterator

Public Member Functions

const OrdinaryAtomgetByID (ID id) const throw ()
 Retrieve by ID.
const OrdinaryAtomgetByAddress (IDAddress addr) const throw ()
 Retrieve by address (ignore kind).
ID getIDByAddress (IDAddress addr) const throw ()
 Retrieve ID by address (ignore kind).
ID getIDByString (const std::string &text) const throw ()
 Given string, look if already stored.
ID getIDByTuple (const Tuple &tuple) const throw ()
 Given tuple, look if already stored.
ID getIDByStorage (const OrdinaryAtom &atom) const throw ()
 Get ID given storage retrieved by other means.
IDAddress getIDAddressByStorage (const OrdinaryAtom &atom) const throw ()
 Get IDAddress of given storage retrieved by other means.
ID storeAndGetID (const OrdinaryAtom &atom) throw ()
 Store atom, assuming it does not exist.
std::pair< PredicateIterator,
PredicateIterator
getRangeByPredicateID (ID id) const throw ()
 Get all ordinary atoms with certain predicate id.
std::pair< AddressIterator,
AddressIterator
getAllByAddress () const throw ()
 Get all ordinary atoms in the table.

Detailed Description

Implements a lookup table for ordinary atoms.

Definition at line 49 of file OrdinaryAtomTable.h.


Member Typedef Documentation

typedef Container::index<impl::AddressTag>::type OrdinaryAtomTable::AddressIndex

Definition at line 81 of file OrdinaryAtomTable.h.

typedef AddressIndex::iterator OrdinaryAtomTable::AddressIterator

Definition at line 86 of file OrdinaryAtomTable.h.

typedef Container::index<impl::PredicateTag>::type OrdinaryAtomTable::PredicateIndex

Definition at line 85 of file OrdinaryAtomTable.h.

typedef PredicateIndex::iterator OrdinaryAtomTable::PredicateIterator

Definition at line 87 of file OrdinaryAtomTable.h.

typedef Container::index<impl::TextTag>::type OrdinaryAtomTable::TextIndex

Definition at line 83 of file OrdinaryAtomTable.h.

typedef Container::index<impl::TupleTag>::type OrdinaryAtomTable::TupleIndex

Definition at line 84 of file OrdinaryAtomTable.h.


Member Function Documentation

Get all ordinary atoms in the table.

NOTE: you may need to lock the mutex also while iterating!

Parameters:
idPredicate ID.
Returns:
Pair of begin and end iterator representing all atoms in the table.

Definition at line 332 of file OrdinaryAtomTable.h.

References Table< ValueT, IndexT >::container, and Table< ValueT, IndexT >::mutex.

const OrdinaryAtom & OrdinaryAtomTable::getByAddress ( IDAddress  addr) const throw () [inline]

Retrieve by address (ignore kind).

Assert that address exists in table.

Parameters:
addrAddress of the ordinary atom to retrieve.
Returns:
Ordinary atom corresponding to addr.

Definition at line 186 of file OrdinaryAtomTable.h.

References Table< ValueT, IndexT >::container, and Table< ValueT, IndexT >::mutex.

Referenced by getIDByAddress(), Registry::printAtomForUser(), TestPlugin::SumNonZeroAtom::retrieve(), and TestPlugin::ProductionRequirementsAtom::retrieve().

const OrdinaryAtom & OrdinaryAtomTable::getByID ( ID  id) const throw () [inline]

Retrieve by ID.

Assert that id.kind is correct for OrdinaryGroundAtom. Assert that ID exists in table.

Parameters:
idTerm ID.
Returns:
Ordinary atom corresponding to id.

Definition at line 170 of file OrdinaryAtomTable.h.

References Table< ValueT, IndexT >::container, and Table< ValueT, IndexT >::mutex.

Referenced by BOOST_AUTO_TEST_CASE(), Registry::getOutVariablesInID(), Registry::getVariablesInID(), Registry::lookupOrdinaryAtom(), RawPrinter::print(), and RawPrinter::printWithoutPrefix().

IDAddress OrdinaryAtomTable::getIDAddressByStorage ( const OrdinaryAtom atom) const throw () [inline]

Get IDAddress of given storage retrieved by other means.

Storage must have originated from iterator from here.

Parameters:
atomAtom to retrieve; must be in the table.
Returns:
IDAddress of
Parameters:
atom.

Definition at line 273 of file OrdinaryAtomTable.h.

References Table< ValueT, IndexT >::container, and Table< ValueT, IndexT >::mutex.

ID OrdinaryAtomTable::getIDByAddress ( IDAddress  addr) const throw () [inline]

Retrieve ID by address (ignore kind).

Assert that address exists in table.

Parameters:
addrAddress of the ordinary atom to retrieve.
Returns:
Ordinary atom corresponding to addr.

Definition at line 200 of file OrdinaryAtomTable.h.

References getByAddress(), and Atom::kind.

Referenced by Registry::printAtomForUser(), and TestPlugin::ProductionRequirementsAtom::retrieve().

ID OrdinaryAtomTable::getIDByStorage ( const OrdinaryAtom atom) const throw () [inline]

Get ID given storage retrieved by other means.

Storage must have originated from iterator from here.

Parameters:
atomAtom to retrieve; must be in the table.
Returns:
ID of
Parameters:
atom.

Definition at line 254 of file OrdinaryAtomTable.h.

References Table< ValueT, IndexT >::container, and Table< ValueT, IndexT >::mutex.

ID OrdinaryAtomTable::getIDByString ( const std::string &  text) const throw () [inline]

Given string, look if already stored.

Parameters:
textString representation of the ordinary atom to retrieve.
Returns:
ID_FAIL if not stored, otherwise return ID.

Definition at line 210 of file OrdinaryAtomTable.h.

References Table< ValueT, IndexT >::container, ID_FAIL(), and Table< ValueT, IndexT >::mutex.

Referenced by BOOST_AUTO_TEST_CASE().

ID OrdinaryAtomTable::getIDByTuple ( const Tuple tuple) const throw () [inline]

Given tuple, look if already stored.

Parameters:
tupleTuple representation of the ordinary atom to retrieve.
Returns:
ID_FAIL if not stored, otherwise return ID.

Definition at line 232 of file OrdinaryAtomTable.h.

References Table< ValueT, IndexT >::container, ID_FAIL(), and Table< ValueT, IndexT >::mutex.

Referenced by BOOST_AUTO_TEST_CASE().

Get all ordinary atoms with certain predicate id.

NOTE: you may need to lock the mutex also while iterating! If you intend to use this method frequently, consider to use a PredicateMask instead for better efficiency (iteration is slow).

Parameters:
idPredicate ID.
Returns:
Pair of begin and end iterator representing all atoms in the table with the given predicate.

Definition at line 320 of file OrdinaryAtomTable.h.

References Table< ValueT, IndexT >::container, and Table< ValueT, IndexT >::mutex.

ID OrdinaryAtomTable::storeAndGetID ( const OrdinaryAtom atom) throw () [inline]

Store atom, assuming it does not exist.

Assert that atom did not exist in table.

Parameters:
atomAtom to retrieve; must be in the table.
Returns:
ID of
Parameters:
atom.

Definition at line 288 of file OrdinaryAtomTable.h.

References Table< ValueT, IndexT >::container, Table< ValueT, IndexT >::mutex, and ID::PROPERTY_AUX.

Referenced by BOOST_AUTO_TEST_CASE().


The documentation for this class was generated from the following file: