Lumiera  0.pre.03
»edit your freedom«
AdviceLink Class Reference

#include "common/advice.hpp"

Description

Advice Collaboration partner, internally connected to the AdviceSystem.

Both advice::Request and advice::Provision are linked in this way to an internal index datastructure, which allows to carry out the actual advice exchange and collaboration.

Definition at line 194 of file advice.hpp.

Public Member Functions

 AdviceLink (Binding const &binding)
 
- Public Member Functions inherited from PointOfAdvice
 PointOfAdvice (Binding const &binding)
 
Binding::Matcher getMatcher () const
 
const PointOfAdvicegetSolution () const
 
void setSolution (PointOfAdvice *solution=0)
 

Protected Types

typedef void() DeleterFunc(void *)
 

Protected Member Functions

void deregisterRequest ()
 
void discardSolutions ()
 when advice is retracted explicitly, after removing the provision index entry we also need to re-process any requests which happen to match our binding... More...
 
void publishProvision (PointOfAdvice *)
 when the Provision actually sets advice data, this is copied into an internal buffer within the AdviceSystem. More...
 
void publishRequestBindingChange (HashVal)
 
void registerRequest ()
 
- Protected Member Functions inherited from PointOfAdvice
void setBindingPattern (Binding const &binding)
 define or re-define the binding, which specifically labels this attachment to the advice system. More...
 

Static Protected Member Functions

static void * getBuffer (size_t)
 allocate raw storage for a buffer holding the actual piece of advice. More...
 
static void manageAdviceData (PointOfAdvice *, DeleterFunc *)
 Store a descriptor record to take ownership of the given allocation. More...
 
static void releaseBuffer (void *, size_t)
 

Member Function Documentation

◆ publishProvision()

void publishProvision ( PointOfAdvice newProvision)
protected

when the Provision actually sets advice data, this is copied into an internal buffer within the AdviceSystem.

We then use the Index to remember the presence of this advice data and to detect possible matches with existing advice::Request entries.

Parameters
adviceDatapointer to the copied data, actually pointing to an ActiveProvision<AD>
Returns
pointer to an superseded old provision entry, which the caller then needs to de-allocate. The caller is assumed to know the actual type and thus the size of the entry to deallocate. Returning NULL in case no old entry exists.

Definition at line 322 of file advice.cpp.

References lumiera::advice::anonymous_namespace{advice.cpp}::aSys.

◆ discardSolutions()

void discardSolutions ( )
protected

when advice is retracted explicitly, after removing the provision index entry we also need to re-process any requests which happen to match our binding...

Returns
pointer to the existing provision entry, to be deallocated by the caller, which is assumed to know it's exact type.

Definition at line 340 of file advice.cpp.

◆ getBuffer()

void * getBuffer ( size_t  siz)
staticprotected

allocate raw storage for a buffer holding the actual piece of advice.

We need to manage this internally, as the original advice::Provision may go out of scope, while the advice information as such remains valid.

Note
the special twist is the size of the buffer depending on the actual advice type, which type information we need to erase for tracking all advice provisions and requests through an generic index datastructure.
Exceptions
error::Fatalon allocation failure

Definition at line 280 of file advice.cpp.

References lumiera::advice::anonymous_namespace{advice.cpp}::aSys.

◆ manageAdviceData()

void manageAdviceData ( PointOfAdvice entry,
DeleterFunc *  how_to_delete 
)
staticprotected

Store a descriptor record to take ownership of the given allocation.

Problem is we need to know the exact size of the advice value holder, which information is available initially, when the advice data is copied into the system. The knowledge about the size of the allocation is embodied into the deleter function. This allows later to discard entries without needing to know their exact type.

Definition at line 301 of file advice.cpp.

+ Inheritance diagram for AdviceLink:
+ Collaboration diagram for AdviceLink:

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