Tracker.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <swarmio/Endpoint.h>
4 #include <swarmio/data/Variant.pb.h>
5 #include <swarmio/data/telemetry/SubscribeRequest.pb.h>
6 #include <map>
7 #include <string>
8 
10 {
16  class Tracker final
17  {
18  private:
19 
24  const Node* _node;
25 
30  uint64_t _identifier;
31 
36  data::telemetry::SubscribeRequest _request;
37 
42  std::atomic<uint32_t> _currentTick;
43 
48  std::atomic<bool> _valid;
49 
50  public:
51 
59  Tracker(const Node* node, uint64_t identifier, const data::telemetry::SubscribeRequest& request)
60  : _identifier(identifier), _request(request), _node(node), _currentTick(0), _valid(true) { }
61 
62 
68  uint64_t GetIdentifier() const
69  {
70  return _identifier;
71  }
72 
78  const Node* GetNode() const
79  {
80  return _node;
81  }
82 
88  const data::telemetry::SubscribeRequest& GetRequest() const
89  {
90  return _request;
91  }
92 
98  uint32_t GetTick() const
99  {
100  return _currentTick;
101  }
102 
109  {
110  return _currentTick++;
111  }
112 
118  bool IsValid() const
119  {
120  return _valid;
121  }
122 
127  void Invalidate()
128  {
129  _valid = false;
130  }
131  };
132 }
data::telemetry::SubscribeRequest _request
The original subscribe request.
Definition: Tracker.h:36
const Node * GetNode() const
Get target node.
Definition: Tracker.h:78
uint32_t GetAndIncrementTick()
Increment current tick and return value.
Definition: Tracker.h:108
std::atomic< uint32_t > _currentTick
Tick counter for the updates.
Definition: Tracker.h:42
const data::telemetry::SubscribeRequest & GetRequest() const
Get original request.
Definition: Tracker.h:88
Telemetry Service can subscribe to receive updates from remote nodes on named values.
Definition: Tracker.h:16
const Node * _node
Subscriber.
Definition: Tracker.h:24
Tracker(const Node *node, uint64_t identifier, const data::telemetry::SubscribeRequest &request)
Construct a new Tracker object.
Definition: Tracker.h:59
bool IsValid() const
Is the tracker still valid?
Definition: Tracker.h:118
uint64_t GetIdentifier() const
Get original message identifier.
Definition: Tracker.h:68
uint32_t GetTick() const
Get current tick.
Definition: Tracker.h:98
void Invalidate()
Mark the tracker as invalid.
Definition: Tracker.h:127
std::atomic< bool > _valid
Is the tracker still valid.
Definition: Tracker.h:48
Represents a Node the Endpoint knows about and can send messages to.
uint64_t _identifier
The identifier of the original request.
Definition: Tracker.h:30


swarmros
Author(s):
autogenerated on Fri Apr 3 2020 03:42:48