DetectorGraph
2.0
include
subscriberinterface.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_SUBSCRIBERINTERFACE_HPP_
16
#define DETECTORGRAPH_INCLUDE_SUBSCRIBERINTERFACE_HPP_
17
18
namespace
DetectorGraph
19
{
20
21
/**
22
* @brief A Pure interface that declares the Subscriber behavior
23
*
24
* Detectors inherit from a number of versions of this interface
25
* to declare their input set.
26
*
27
* A class `FooDetector` acquires the "Subscriber of BarTopicState"
28
* behavior by inheriting `SubscriberInterface` templated to `BarTopicState`.
29
*
30
* @code
31
class FooDetector :
32
public Detector,
33
public SubscriberInterface<BarTopicState>
34
{
35
// ...
36
}
37
* @endcode
38
*
39
* This interface serves a tiny purpose:
40
* - Abstracts the interface of Subscriber to a Topic into a type-safe method.
41
* - Document in a clear way the Subscriptions of a Detector.
42
*
43
* To enable the subscription Detectors must call Detector::Subscribe from the inheriting
44
* Detector's constructor:
45
* @code
46
class FooDetector :
47
public Detector,
48
public SubscriberInterface<BarTopicState>
49
{
50
FooDetector(Graph* graph) : Detector(graph)
51
{
52
Subscribe<BarTopicState>(this);
53
}
54
}
55
* @endcode
56
*
57
*/
58
template
<
class
T>
59
class
SubscriberInterface
60
{
61
public
:
62
/**
63
* @brief Pure-virtual method that should Evaluate a piece of input data.
64
*/
65
virtual
void
Evaluate
(
const
T&) = 0;
66
};
67
68
}
// namespace DetectorGraph
69
70
#endif // DETECTORGRAPH_INCLUDE_SUBSCRIBERINTERFACE_HPP_
DetectorGraph::SubscriberInterface::Evaluate
virtual void Evaluate(const T &)=0
Pure-virtual method that should Evaluate a piece of input data.
DetectorGraph::SubscriberInterface
A Pure interface that declares the Subscriber behavior.
Definition:
subscriberinterface.hpp:59
DetectorGraph
Definition:
detector.hpp:28
Generated by
1.8.13