Lumiera  0.pre.03
»edit your freedom«
Index< POA > Class Template Reference

#include "common/advice/index.hpp"

Description

template<class POA>
class lumiera::advice::Index< POA >

Index datastructure for organising advice solutions.

Based on two hashtables for advice provisions and requests, the index allows to add, modify and remove entities of these two kinds. Each of these mutating operations immediately re-computes the advice solutions and publishes the results by invoking the setSolution() function on the corresponding PointOfAdvice entity.

Note
element identity is defined in terms of pointing to the same memory location of a POA (point of advice). Thus e.g. #hasProvision means this index holds an entry pointing to exactly this given data entity.
the implementation of modifying a Request entry explicitly relies on that definition of equality.
the diagnostic API is mainly intended for unit testing and not implemented with focus on performance.
Exception safety
Adding new registrations might throw error::Fatal or bad_alloc. The addition in this case has no effect and the index remains valid. The other mutating operations are NO_THROW, given that Binding::Matcher is a POD and std::vector fulfils the guarantee for POD content elements.

Definition at line 141 of file index.hpp.

Public Member Functions

void addProvision (POA &entry)
 
void addRequest (POA &entry)
 
void clear ()
 
bool hasProvision (POA const &refEntry) const
 
bool hasRequest (POA const &refEntry) const
 
bool isValid () const
 validity self-check More...
 
void modifyProvision (POA const &oldRef, POA &newEntry)
 
void modifyRequest (HashVal oKey, POA &entry)
 
size_t provision_count () const
 
void removeProvision (POA const &refEntry)
 
void removeRequest (POA const &refEntry)
 
size_t request_count () const
 
size_t size () const
 

Classes

struct  Cluster
 
struct  Entry
 
struct  ProvisionCluster
 
struct  RequestCluster
 

Private Types

typedef EntryList::iterator EIter
 
typedef vector< EntryEntryList
 
typedef unordered_map< HashVal, ProvisionClusterPTable
 
typedef unordered_map< HashVal, RequestClusterRTable
 

Private Member Functions

void verify_Entry (Entry const &, HashVal) const
 
void verify_Request (Entry const &, HashVal) const
 

Static Private Member Functions

template<class IT >
static size_t sumClusters (IT ii)
 internal: sum element count over all clusters in the given hashtable
 

Private Attributes

PTable provisionEntries_
 
RTable requestEntries_
 

Member Function Documentation

◆ modifyRequest()

void modifyRequest ( HashVal  oKey,
POA &  entry 
)
inline
Note
explicitly relying on the implementation of == which checks only the memory location of the Request. Thus we can use the already modified Request to find the old entry within the index pointing to this Request.
Parameters
oKeythe binding hash value prior to modification

Definition at line 355 of file index.hpp.

Referenced by AdviceSystem::discardEntry().

+ Here is the caller graph for this function:

◆ clear()

void clear ( )
inline
Warning
calling this effectively detaches any existing advice information, but doesn't clean up storage of advice provisions incorporated within the advice system in general.

Definition at line 419 of file index.hpp.

◆ isValid()

bool isValid ( ) const

validity self-check

Advice index self-verification: traverses the tables to check each entry is valid.

Moreover, when a advice request has a stored solution which points back into the current advice provisions, this solution will be re-computed with the current data to prove it's still valid.

Note
expensive operation

Definition at line 519 of file index.hpp.

Referenced by Index< lumiera::advice::PointOfAdvice >::clear().

+ Here is the caller graph for this function:
+ Inheritance diagram for Index< POA >:
+ Collaboration diagram for Index< POA >:

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