DetectorGraph  2.0
graphinputdispatcher.hpp
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 #ifndef DETECTORGRAPH_INCLUDE_GRAPHINPUTDISPATCHER_HPP_
16 #define DETECTORGRAPH_INCLUDE_GRAPHINPUTDISPATCHER_HPP_
17 
18 #include "topic.hpp"
19 #include "vertex.hpp"
20 
21 namespace DetectorGraph
22 {
23 /**
24  * @brief _Internal_ - Provide interface for a GraphInputDispatcher
25  */
27 {
28 public:
30  virtual void Dispatch() = 0;
31 };
32 /**
33  * @brief _Internal_ - Push data to the graph
34  *
35  * It pushes data to a specific topic through a graphInputDispatcher.
36  * The pending data will be evaluated in the next round.
37  */
38 template<class T>
40 {
41 public:
42  GraphInputDispatcher(Topic<T>& aTopic, const T& aData)
43 : mTopic(aTopic)
44 , mData(aData)
45  {
46  }
47 
48  void Dispatch()
49  {
50  mTopic.Publish(mData);
51  }
52 private:
53  Topic<T>& mTopic;
54  const T mData;
55 };
56 
57 } // namespace DetectorGraph
58 
59 #endif // DETECTORGRAPH_INCLUDE_GRAPHINPUTDISPATCHER_HPP_
Internal - Provide interface for a GraphInputDispatcher
GraphInputDispatcher(Topic< T > &aTopic, const T &aData)
Manage data and its handler.
Definition: topic.hpp:84
Internal - Push data to the graph