DetectorGraph  2.0
subscriptiondispatcher.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_SUBSCRIPTIONDISPATCHER_HPP_
16 #define DETECTORGRAPH_INCLUDE_SUBSCRIPTIONDISPATCHER_HPP_
17 
18 #include "topic.hpp"
19 #include "vertex.hpp"
20 
21 namespace DetectorGraph
22 {
23 /**
24  * @brief _Internal_ - Provide interface for a SubscriptionDispatcher
25  */
27 {
28 public:
30  virtual Vertex* GetTopicVertex() = 0;
31  virtual void Dispatch() = 0;
32 };
33 /**
34  * @brief _Internal_ - Implements the data-out edge from a topic to one of its subscriber.
35  *
36  * Topics aggregate data and provide functionality do dispatch data but does
37  * not embody the programmatic link between topic and subscriber - this class
38  * does that.
39  */
40 template<class T>
42 {
43 public:
44  /**
45  * @brief Constructor
46  *
47  * @param aTopic a specific topic this dispatcher manages
48  * @param aSubscriber a subscriber to consume the data
49  */
51  {
52  mTopic = aTopic;
53  mSubscriber = aSubscriber;
54  }
55 
56  void Dispatch()
57  {
58  mTopic->DispatchIntoSubscriber(mSubscriber);
59  }
60 
62  {
63  return mTopic;
64  }
65 private:
66  Topic<T>* mTopic;
67  SubscriberInterface<T>* mSubscriber;
68 };
69 
70 } // namespace DetectorGraph
71 
72 #endif // DETECTORGRAPH_INCLUDE_SUBSCRIPTIONDISPATCHER_HPP_
SubscriptionDispatcher(Topic< T > *aTopic, SubscriberInterface< T > *aSubscriber)
Constructor.
Manage data and its handler.
Definition: topic.hpp:84
Internal - Implements the data-out edge from a topic to one of its subscriber.
Internal - Provide interface for a SubscriptionDispatcher
A Pure interface that declares the Subscriber behavior.
Define behaviors of a vertex in a graph.
Definition: vertex.hpp:37