DetectorGraph  2.0
detector.cpp
Go to the documentation of this file.
1 // Copyright 2017 Nest Labs, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "detector.hpp"
16 
17 namespace DetectorGraph
18 {
19 
20 Detector::Detector(Graph* graph) : mGraph(graph)
21 {
22  mGraph->AddVertex(this);
23 }
24 
26 {
27 #if !defined(BUILD_FEATURE_DETECTORGRAPH_CONFIG_LITE)
28  // Remove self as out edge on topics
29  for (unsigned idx = 0; idx != mDispatchersContainer.GetSize(); ++idx)
30  {
31  mDispatchersContainer.GetDispatchers()[idx]->GetTopicVertex()->RemoveEdge(this);
32  }
33  mOutEdges.clear();
34  mGraph->RemoveVertex(this);
35 #endif
36 }
37 
39 {
41  {
42  this->BeginEvaluation();
43  for (unsigned idx = 0; idx != mDispatchersContainer.GetSize(); ++idx)
44  {
45  mDispatchersContainer.GetDispatchers()[idx]->Dispatch();
46  }
47  this->CompleteEvaluation();
48 
50  }
51 }
52 
54 {
55  // Empty
56 }
57 
59 {
60  // Empty
61 }
62 
63 }
void ProcessVertex()
Consume data in the topics.
Definition: detector.cpp:38
VertexPtrContainer mOutEdges
Definition: vertex.hpp:143
Implements a graph of Topics & Detectors with Input/Output APIs.
Definition: graph.hpp:127
SubscriptionDispatcherInterface *const (& GetDispatchers() const)[DetectorGraphConfig::kMaxNumberOfInEdges]
void RemoveEdge(Vertex *aVertex)
Definition: vertex.hpp:92
virtual void BeginEvaluation()
Called before any calls to SubscriberInterface::Evaluate.
Definition: detector.cpp:53
VertexSearchState GetState() const
Definition: vertex.hpp:71
void AddVertex(Vertex *aVertex)
Definition: graph.cpp:58
virtual void CompleteEvaluation()
Called after all calls to SubscriberInterface::Evaluate.
Definition: detector.cpp:58
Detector(Graph *graph)
Constructor.
Definition: detector.cpp:20
void SetState(VertexSearchState aNewState)
Definition: vertex.hpp:76
void RemoveVertex(Vertex *aVertex)
Definition: graph.cpp:69
virtual ~Detector()
Destructor.
Definition: detector.cpp:25