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:
- Simple / bare-bones:
OverheatingDetector detector(&graph);
This is the simplest way to build graphs and is used throughout unit tests.
- Aggregation example using automatic storage for graph & detectors:
class MyApplication
{
public:
MyApplication() : mGraph(), mFooDetector(&mGraph), mBarDetector(&mGraph)
{
}
FooDetector mFooDetector;
BarDetector mBarDetector;
};
- Composition using dynamic allocation of detectors:
{
public:
FooBarGraph()
{
mFooDetector = new FooDetector(this);
mBarDetector = new BarDetector(this);
}
~FooBarGraph()
{
delete mFooDetector;
delete mBarDetector;
}
FooDetector* mFooDetector;
BarDetector* mBarDetector;
};
This option offers a lot of flexibility at construction time and makes graph ownership of detectors more obvious.
Graph:
- Owns all vertices (Topics and Detectors)
- Provides the data input API (PushData<T>) (into topics)
- Provides the data output API (GetOutputList) (from topics)
- Provides an API for graph evaluation (EvaluateGraph)
- Maintains the Graph's topological sort across graph changes topology changes
- Creates Topics as needed to satisfy all Detector's dependencies
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.
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.