DetectorGraph  2.0
Public Member Functions | Protected Attributes | List of all members
DetectorGraph::FuturePublisher< T > Class Template Reference

Publish data to the graph for future evaluation. More...

Collaboration diagram for DetectorGraph::FuturePublisher< T >:

Public Member Functions

 FuturePublisher ()
 
void SetGraph (Graph *aGraph)
 
void PublishOnFutureEvaluation (const T &aData)
 Publish a new version of T to the Graph for future evaluation. More...
 

Protected Attributes

GraphmGraph
 

Detailed Description

template<class T>
class DetectorGraph::FuturePublisher< T >

Publish data to the graph for future evaluation.

Detectors inherit from a FuturePublisher<T> to implement the behavior of being a Publisher of T for a future/next evaluation. This differs from a normal Publisher in a very fundamental way, it enables a detector to publish something to an upstream topic - thus constructing a feedback loop. Normally, publishing to an upstream topic would create a directed cycle in the graph thus making it impossible to be topologically sorted.

Using FuturePublisher a detector can implement a feedback loop while still making sure the topological nature of graph evaluation is preserved.

A class FooDetector acquires the "FuturePublisher of BarTopicState" behavior by inheriting FuturePublisher templated to BarTopicState.

This is a template class and so it must be kept minimal to prevent code bloat. This class serves a tiny purpose:

The only requirement to use the FuturePublisher functionality is to call Detector::SetupFuturePublishing from the inheriting Detector's constructor:

Below is an example:

class ResetDetector : public DetectorGraph::Detector
{
public:
ResetDetector(DetectorGraph::Graph* graph) : DetectorGraph::Detector(graph)
{
Subscribe<EventCount>(this);
SetupFuturePublishing<Reset>(this);
}
void Evaluate(const EventCount& aEventCount)
{
if (aEventCount.count >= kMaxCount)
{
}
}
static const int kMaxCount = 5;
};

When implementing feedback loops in a graph one should also consider DetectorGraph::Lag as in some cases it's more general and extensible.

Definition at line 61 of file futurepublisher.hpp.

Constructor & Destructor Documentation

◆ FuturePublisher()

template<class T>
DetectorGraph::FuturePublisher< T >::FuturePublisher ( )
inline

Definition at line 65 of file futurepublisher.hpp.

Member Function Documentation

◆ PublishOnFutureEvaluation()

template<class T>
void DetectorGraph::FuturePublisher< T >::PublishOnFutureEvaluation ( const T &  aData)
inline

Publish a new version of T to the Graph for future evaluation.

Definition at line 77 of file futurepublisher.hpp.

◆ SetGraph()

template<class T>
void DetectorGraph::FuturePublisher< T >::SetGraph ( Graph aGraph)
inline

Definition at line 69 of file futurepublisher.hpp.

Member Data Documentation

◆ mGraph

template<class T>
Graph* DetectorGraph::FuturePublisher< T >::mGraph
protected

Definition at line 84 of file futurepublisher.hpp.


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