DetectorGraph  2.0
Public Types | Public Member Functions | List of all members
DetectorGraph::Graph Class Reference

Implements a graph of Topics & Detectors with Input/Output APIs. More...

Collaboration diagram for DetectorGraph::Graph:

Public Types

typedef std::list< Vertex * > VertexPtrContainer
 

Public Member Functions

 Graph ()
 Constructor. More...
 
virtual ~Graph ()
 Destructor. More...
 
template<class TTopicState >
Topic< TTopicState > * ResolveTopic ()
 Find/add a topic in the detector graph. More...
 
template<class TTopicState >
void PushData (const TTopicState &aTopicState)
 Push data to a specific topic in the graph. More...
 
ErrorType EvaluateGraph ()
 Evaluate the whole graph. More...
 
bool HasDataPending ()
 Returns true if there is data pending evaluation. More...
 
bool EvaluateIfHasDataPending ()
 Evaluates Graph if data is pending and returns true if so. More...
 
void AddVertex (Vertex *aVertex)
 
void RemoveVertex (Vertex *aVertex)
 
TopicRegistryGetTopicRegistry ()
 
const VertexPtrContainerGetVertices () const
 
const std::list< ptr::shared_ptr< const TopicState > > & GetOutputList () const
 Returns the list of topicstates published in the last Evaluation. More...
 
ErrorType TopoSortGraph ()
 Determine the right order to process the vertices by topological sort. More...
 

Detailed Description

Implements a graph of Topics & Detectors with Input/Output APIs.

Application's Graphs can be built using Aggregation or Composition with this class.

Detectors are added to the graph and the graph is responsible for creating the necessary Topics to satisfy all dependencies.

Below are a couple of example of how to setup Graph with Detectors:

Graph:

Typical control flow:

This class also maintains an Inversion of Control container (TopicRegistry) for Topics. The IoC container is basically a "repository" of singleton topics.

Definition at line 127 of file graph.hpp.

Member Typedef Documentation

◆ VertexPtrContainer

Definition at line 134 of file graph.hpp.

Constructor & Destructor Documentation

◆ Graph()

DetectorGraph::Graph::Graph ( )

Constructor.

Does nothing really

Definition at line 23 of file graph.cpp.

◆ ~Graph()

DetectorGraph::Graph::~Graph ( )
virtual

Destructor.

When a Graph is destroyed, it deletes all the pending graph dispatchers, detectors, and topics (even if they're not referred to by any detectors).

Definition at line 31 of file graph.cpp.

Member Function Documentation

◆ AddVertex()

void DetectorGraph::Graph::AddVertex ( Vertex aVertex)

Definition at line 58 of file graph.cpp.

◆ EvaluateGraph()

ErrorType DetectorGraph::Graph::EvaluateGraph ( )

Evaluate the whole graph.

Definition at line 133 of file graph.cpp.

◆ EvaluateIfHasDataPending()

bool DetectorGraph::Graph::EvaluateIfHasDataPending ( )

Evaluates Graph if data is pending and returns true if so.

This method is a convenience combination of HasDataPending() and EvaluateGraph() that makes it a bit cleaner to implement simple evaluation loops. It assumes that EvaluateGraph() always succeeds; it'll fail a DG_ASSERT otherwise.

Definition at line 80 of file graph.cpp.

◆ GetOutputList()

const std::list< ptr::shared_ptr< const TopicState > > & DetectorGraph::Graph::GetOutputList ( ) const

Returns the list of topicstates published in the last Evaluation.

It returns a list of references (valid only in between evaluations) to the topicstates that changed during the last call to EvaluateGraph()

Definition at line 338 of file graph.cpp.

◆ GetTopicRegistry()

TopicRegistry & DetectorGraph::Graph::GetTopicRegistry ( )

Definition at line 102 of file graph.cpp.

◆ GetVertices()

const VertexPtrContainer& DetectorGraph::Graph::GetVertices ( ) const
inline

Definition at line 221 of file graph.hpp.

◆ HasDataPending()

bool DetectorGraph::Graph::HasDataPending ( )

Returns true if there is data pending evaluation.

This can be useful when implementing a 'flush & evaluate all data' pattern because calls to EvaluateGraph() remove only single TopicState from the input queue at a time for each evaluation of the graph.

Definition at line 97 of file graph.cpp.

◆ PushData()

template<class TTopicState >
void DetectorGraph::Graph::PushData ( const TTopicState &  aTopicState)
inline

Push data to a specific topic in the graph.

This method is used to input data into the graph and it's the only API to do so.

Definition at line 187 of file graph.hpp.

◆ RemoveVertex()

void DetectorGraph::Graph::RemoveVertex ( Vertex aVertex)

Definition at line 69 of file graph.cpp.

◆ ResolveTopic()

template<class TTopicState >
Topic<TTopicState>* DetectorGraph::Graph::ResolveTopic ( )
inline

Find/add a topic in the detector graph.

If the topic to resolve already exists, return it. Otherwise, registering a new topic and then return it.

Returns
A unique topic of type TTopic in this graph.

Definition at line 160 of file graph.hpp.

◆ TopoSortGraph()

ErrorType DetectorGraph::Graph::TopoSortGraph ( )

Determine the right order to process the vertices by topological sort.

Definition at line 222 of file graph.cpp.


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