3 #ifndef _MADARA_FILTERS_DYNAMIC_PREFIX_PRINT_H_
4 #define _MADARA_FILTERS_DYNAMIC_PREFIX_PRINT_H_
56 std::stringstream buffer;
57 buffer <<
"DynamicPrefixFilter Arguments:\n";
60 buffer <<
" Operation Type: ";
65 buffer <<
" Send Bandwidth: ";
70 buffer <<
" Receive Bandwidth: ";
75 buffer <<
" Update Time: ";
80 buffer <<
" Current Time: ";
85 buffer <<
" Knowledge Domain: ";
90 buffer <<
" Originator: ";
94 buffer <<
" Updates:\n";
96 std::vector<std::string> prefixes;
114 for (
auto record : records)
117 bool accepted_prefix =
false;
119 if (prefixes.size() > 0)
121 for (
auto prefix : prefixes)
125 accepted_prefix =
true;
131 accepted_prefix =
true;
135 if (!accepted_prefix)
139 "DynamicPrefixPrint::filter: "
140 "not printing variable %s\n",
141 record.first.c_str())
146 buffer <<
" " << record.first <<
" = ";
147 buffer << record.second.to_string() <<
"\n";
151 vars.
print(buffer.str(), 0);
#define madara_logger_ptr_log(loggering, level,...)
Fast version of the madara::logger::log method for Logger pointers.
Abstract base class for implementing aggregate record filters via a functor interface.
Filter for printing variables as they arrive and excluding prefixes that are unwanted via a user-spec...
std::string name
The string vector name to bind to inside the knowledge base.
virtual ~DynamicPrefixPrint()=default
Destructor.
DynamicPrefixPrint(const std::string &string_vector_name=".prefixes")
Constructor.
knowledge::containers::StringVector prefixes_
A map of discovered peers.
bool initialized_
Tracks if the prefix vector has been initialized.
virtual void filter(knowledge::KnowledgeMap &records, const transport::TransportContext &transport_context, knowledge::Variables &vars)
Prints records and transport context information.
Provides an interface for external functions into the MADARA KaRL variable settings.
void print(unsigned int level=0) const
Prints all variables and values in the context.
This class stores a vector of strings inside of KaRL.
void set_name(const std::string &var_name, KnowledgeBase &knowledge, int size=-1)
Sets the variable name that this refers to.
void copy_to(KnowledgeVector &target) const
Copies the vector elements to an STL vector of Knowledge Records.
void resize(int size=-1, bool delete_vars=true)
Resizes the vector.
Provides context about the transport.
uint64_t get_send_bandwidth(void) const
Gets the send/rebroadcast bandwidth in bytes per second.
const std::string & get_domain(void) const
Returns the network domain.
int64_t get_operation(void) const
Get operation that the context is performing.
uint64_t get_current_time(void) const
Gets the current timestamp.
const std::string & get_originator(void) const
Returns the current message originator.
uint64_t get_receive_bandwidth(void) const
Gets the receive bandwidth in bytes per second.
uint64_t get_message_time(void) const
Gets the message timestamp.
T get(const KnowledgeRecord &kr)
Get the value of a KnowlegeRecord.
::std::map< std::string, KnowledgeRecord > KnowledgeMap
MADARA_EXPORT utility::Refcounter< logger::Logger > global_logger
std::string MADARA_EXPORT get_operation_type(int type)
Return the type of operation (usually from TransportContext)
MADARA_EXPORT bool begins_with(const std::string &input, const std::string &prefix)
Check if input contains prefix at the beginning.
Copyright(c) 2020 Galois.