MADARA  3.2.3
CounterFilter.cpp
Go to the documentation of this file.
1 #include "CounterFilter.h"
3 
4 namespace utility = madara::utility;
6 
8  : initialized_ (false),
9  packets_ (0), first_message_ (-1), last_message_ (-1)
10 {
11 }
12 
14 {
15 }
16 
17 
18 void
20  knowledge::KnowledgeMap & /*records*/,
21  const transport::TransportContext & transport_context,
22  knowledge::Variables & /*vars*/)
23 {
24  Integer cur_time = (Integer) transport_context.get_current_time ();
25 
26  if (!initialized_)
27  {
28  this->initialized_ = true;
29  this->first_message_ = cur_time;
30  }
31 
32  ++this->packets_;
33  this->last_message_ = cur_time;
34 }
madara::knowledge::KnowledgeRecord::Integer Integer
knowledge::KnowledgeRecord::Integer last_message_
The time of the last clear of the peer_list.
Definition: CounterFilter.h:97
knowledge::KnowledgeRecord::Integer first_message_
The time to keep record of a peer.
Definition: CounterFilter.h:92
Provides context about the transport.
bool initialized_
Tracks if the first timer has been initialized.
Definition: CounterFilter.h:82
uint64_t get_current_time(void) const
Gets the current timestamp.
madara::knowledge::KnowledgeRecord::Integer Integer
::std::map< std::string, KnowledgeRecord > KnowledgeMap
knowledge::KnowledgeRecord::Integer packets_
A map of discovered peers.
Definition: CounterFilter.h:87
virtual void filter(knowledge::KnowledgeMap &records, const transport::TransportContext &transport_context, knowledge::Variables &vars)
Adds to the counter.
Provides utility functions and classes for common tasks and needs.
Definition: IteratorImpl.h:14
Provides an interface for external functions into the MADARA KaRL variable settings.
virtual ~CounterFilter()
Destructor.