dlvhex
2.5.0
|
Implements a lookup table for ordinary atoms. More...
#include <include/dlvhex2/OrdinaryAtomTable.h>
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 OrdinaryAtom & | getByID (ID id) const throw () |
Retrieve by ID. | |
const OrdinaryAtom & | getByAddress (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. |
Implements a lookup table for ordinary atoms.
Definition at line 49 of file OrdinaryAtomTable.h.
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.
std::pair< OrdinaryAtomTable::AddressIterator, OrdinaryAtomTable::AddressIterator > OrdinaryAtomTable::getAllByAddress | ( | ) | const throw () [inline] |
Get all ordinary atoms in the table.
NOTE: you may need to lock the mutex also while iterating!
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.
addr | Address of the ordinary atom to retrieve. |
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.
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.
atom | Atom to retrieve; must be in the table. |
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.
addr | Address of the ordinary atom to retrieve. |
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.
atom | Atom to retrieve; must be in the table. |
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.
text | String representation of the ordinary atom to retrieve. |
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.
tuple | Tuple representation of the ordinary atom to retrieve. |
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().
std::pair< OrdinaryAtomTable::PredicateIterator, OrdinaryAtomTable::PredicateIterator > OrdinaryAtomTable::getRangeByPredicateID | ( | ID | id | ) | const throw () [inline] |
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).
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.
atom | Atom to retrieve; must be in the table. |
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().