MADARA  3.4.1
CounterFilter.cpp
Go to the documentation of this file.
1 #include "CounterFilter.h"
3 
4 namespace utility = madara::utility;
6 
8  : initialized_(false), packets_(0), first_message_(-1), last_message_(-1)
9 {
10 }
11 
13 
15  knowledge::KnowledgeMap& /*records*/,
16  const transport::TransportContext& transport_context,
17  knowledge::Variables& /*vars*/)
18 {
19  Integer cur_time = (Integer)transport_context.get_current_time();
20 
21  if (!initialized_)
22  {
23  this->initialized_ = true;
24  this->first_message_ = cur_time;
25  }
26 
27  ++this->packets_;
28  this->last_message_ = cur_time;
29 }
madara::knowledge::KnowledgeRecord::Integer Integer
madara::knowledge::KnowledgeRecord::Integer Integer
virtual ~CounterFilter()
Destructor.
virtual void filter(knowledge::KnowledgeMap &records, const transport::TransportContext &transport_context, knowledge::Variables &vars)
Adds to the counter.
Provides an interface for external functions into the MADARA KaRL variable settings.
Definition: Variables.h:53
Provides context about the transport.
uint64_t get_current_time(void) const
Gets the current timestamp.
::std::map< std::string, KnowledgeRecord > KnowledgeMap
Provides utility functions and classes for common tasks and needs.
Definition: IteratorImpl.h:15