dlvhex  2.5.0
RuleTable Class Reference

Lookup table for rules. More...

#include <include/dlvhex2/RuleTable.h>

Inheritance diagram for RuleTable:
Collaboration diagram for RuleTable:

Public Types

typedef Container::index
< impl::AddressTag >::type 
AddressIndex
typedef Container::index
< impl::KindTag >::type 
KindIndex
typedef Container::index
< impl::ElementTag >::type 
ElementIndex
typedef AddressIndex::iterator AddressIterator
typedef ElementIndex::iterator ElementIterator

Public Member Functions

const RulegetByID (ID id) const throw ()
 Retrieve by ID.
ID getIDByElement (const Rule &rule) const throw ()
 Get the ID of the rule.
ID storeAndGetID (const Rule &rule) throw ()
 Stores rule.
void clear ()
 Clears the table.
void update (const Rule &oldStorage, Rule &newStorage) throw ()
 Update a rule in the table.
std::ostream & print (std::ostream &o, RegistryPtr reg) const throw ()
 Prints the table in human-readable format.
std::pair< AddressIterator,
AddressIterator
getAllByAddress () const throw ()
 Get range over all atoms sorted by address.

Detailed Description

Lookup table for rules.

Definition at line 51 of file RuleTable.h.


Member Typedef Documentation

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

Definition at line 87 of file RuleTable.h.

typedef AddressIndex::iterator RuleTable::AddressIterator

Definition at line 90 of file RuleTable.h.

typedef Container::index<impl::ElementTag>::type RuleTable::ElementIndex

Definition at line 89 of file RuleTable.h.

typedef ElementIndex::iterator RuleTable::ElementIterator

Definition at line 91 of file RuleTable.h.

typedef Container::index<impl::KindTag>::type RuleTable::KindIndex

Definition at line 88 of file RuleTable.h.


Member Function Documentation

void RuleTable::clear ( ) [inline]

Clears the table.

Definition at line 209 of file RuleTable.h.

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

Get range over all atoms sorted by address.

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

Returns:
Pair of a begin and end iterator representing all rules in the table.

Definition at line 234 of file RuleTable.h.

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

const Rule & RuleTable::getByID ( ID  id) const throw () [inline]

Retrieve by ID.

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

Parameters:
idID of the rule to retrieve.
Returns:
Rule corresponding to id.

Definition at line 147 of file RuleTable.h.

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

Referenced by BOOST_AUTO_TEST_CASE(), and RawPrinter::print().

ID RuleTable::getIDByElement ( const Rule rule) const throw () [inline]

Get the ID of the rule.

Parameters:
ruleRule whose ID shall be retrieved.
Returns:
ID of rule.

Definition at line 161 of file RuleTable.h.

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

Referenced by Registry::storeRule().

std::ostream & RuleTable::print ( std::ostream &  o,
RegistryPtr  reg 
) const throw ()

Prints the table in human-readable format.

Implementation in Registry.cpp!

Parameters:
oStream to print to.
regRegistry used to resolve IDs.
Returns:
o.

Definition at line 182 of file Registry.cpp.

Referenced by Registry::print().

ID RuleTable::storeAndGetID ( const Rule rule) throw () [inline]

Stores rule.

Assert that rule did not exist in table.

Parameters:
ruleRule to store.
Returns:
ID of the stored rule.

Definition at line 180 of file RuleTable.h.

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

Referenced by BOOST_AUTO_TEST_CASE(), and Registry::storeRule().

void RuleTable::update ( const Rule oldStorage,
Rule newStorage 
) throw () [inline]

Update a rule in the table.

oldStorage must be from getByID() or from *const_iterator.

Parameters:
oldStorageOld rule.
newStorageNew rule.

Definition at line 216 of file RuleTable.h.

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


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