DetectorGraph
2.0
|
A unit of logic in a DetectorGraph. More...
Public Member Functions | |
Detector (Graph *graph) | |
Constructor. More... | |
virtual | ~Detector () |
Destructor. More... | |
virtual VertexType | GetVertexType () const |
Returns kDetectorVertex to identify this subclass of Vertex. More... | |
void | ProcessVertex () |
Consume data in the topics. More... | |
![]() | |
Vertex () | |
virtual | ~Vertex () |
VertexSearchState | GetState () const |
void | SetState (VertexSearchState aNewState) |
void | InsertEdge (Vertex *aVertex) |
void | RemoveEdge (Vertex *aVertex) |
VertexPtrContainer & | GetOutEdges () |
void | MarkFutureEdge (Vertex *aVertex) |
VertexPtrContainer & | GetInEdges () |
VertexPtrContainer & | GetFutureOutEdges () |
VertexPtrContainer & | GetFutureInEdges () |
const char * | GetName () const |
Protected Member Functions | |
template<class TTopicState > | |
void | Subscribe (SubscriberInterface< TTopicState > *aSubscriber) |
Setup an subscription on a specific topic. More... | |
template<class TTopic > | |
void | SetupPublishing (Publisher< TTopic > *aPublisher) |
Setup an advertisement on a specific topic. More... | |
template<class TTopic > | |
void | SetupFuturePublishing (FuturePublisher< TTopic > *aFuturePublisher) |
Setup an future advertisement on a specific topic. More... | |
template<class TTopic > | |
void | SetupTimeoutPublishing (TimeoutPublisher< TTopic > *aTimeoutPublisher, TimeoutPublisherService *aTimeoutPublisherService) |
Setup an timeout advertisement on a specific topic. More... | |
template<class TTopic > | |
void | SetupPeriodicPublishing (const uint64_t aPeriodInMilliseconds, TimeoutPublisherService *aTimeoutPublisherService) |
Setup an periodic advertisement on a specific topic. More... | |
virtual void | BeginEvaluation () |
Called before any calls to SubscriberInterface::Evaluate. More... | |
virtual void | CompleteEvaluation () |
Called after all calls to SubscriberInterface::Evaluate. More... | |
Additional Inherited Members | |
![]() | |
enum | VertexSearchState { kVertexClear, kVertexProcessing, kVertexDone } |
Enum used for topological sort & traverse context keeping. More... | |
enum | VertexType { kTopicVertex, kDetectorVertex, kTestVertex } |
typedef std::list< Vertex * > | VertexPtrContainer |
![]() | |
VertexSearchState | mState |
VertexPtrContainer | mOutEdges |
VertexPtrContainer | mInEdges |
VertexPtrContainer | mFutureOutEdges |
VertexPtrContainer | mFutureInEdges |
A unit of logic in a DetectorGraph.
Detectors are compartmentalized algorithm with clear inputs & outputs. It has fixed input types (Subscriptions) and fixed output types (Publishing).
A new detector is implemented by a new class that:
Detectors should be designed to be modular & finely grained. Note that there's a trade-off between granularity & practicality/overhead and sometimes it's easier to find the sweet spot by designing TopicStates that provide intuitive intermediary state representations and then design the detectors afterwards.
For example, a trivial 'temperature threshold' detector could be:
For a complete example, go to Hello World
More complex Detectors will subscribe & publish to multiple different topics.
Detectors can also implement BeginEvaluation() and CompleteEvaluation() methods if performing a summary across multiple Evaluate() calls - with calls to Publish() from within CompleteEvaluation().
Definition at line 68 of file detector.hpp.
DetectorGraph::Detector::Detector | ( | Graph * | graph | ) |
Constructor.
A Detector is always created within a Graph. The detector is "attached" to the graph during construction. Also, during construction a subclass must make the necessary calls to:
Definition at line 20 of file detector.cpp.
|
virtual |
Destructor.
Destruction of a Detector removes it from the graph it's contained. It also removes it's own subscription dispatchers and the 'out' edges pointing to this detector owned by the topics it subscribes to.
Definition at line 25 of file detector.cpp.
|
protectedvirtual |
Called before any calls to SubscriberInterface::Evaluate.
See more at ProcessVertex()
Definition at line 53 of file detector.cpp.
|
protectedvirtual |
Called after all calls to SubscriberInterface::Evaluate.
See more at ProcessVertex()
Definition at line 58 of file detector.cpp.
|
inlinevirtual |
Returns kDetectorVertex to identify this subclass of Vertex.
Implements DetectorGraph::Vertex.
Definition at line 99 of file detector.hpp.
|
virtual |
Consume data in the topics.
Executes the evaluation of this detector. This entails:
Implements DetectorGraph::Vertex.
Definition at line 38 of file detector.cpp.
|
inlineprotected |
Setup an future advertisement on a specific topic.
This method must be called at the constructor of a detector; once per FuturePublisher<T>
implementation it contains.
Definition at line 148 of file detector.hpp.
|
inlineprotected |
Setup an periodic advertisement on a specific topic.
This method must be called at the constructor of a detector;
Definition at line 173 of file detector.hpp.
|
inlineprotected |
Setup an advertisement on a specific topic.
This method must be called at the constructor of a detector; once per Publisher<T>
implementation it contains.
Definition at line 135 of file detector.hpp.
|
inlineprotected |
Setup an timeout advertisement on a specific topic.
This method must be called at the constructor of a detector; once per TimeoutPublisher<T>
implementation it contains.
Definition at line 161 of file detector.hpp.
|
inlineprotected |
Setup an subscription on a specific topic.
This method must be called at the constructor of a detector; once per SubscriberInterface<T>
interfaces it implements.
Definition at line 120 of file detector.hpp.