3 #ifndef _MADARA_FILTERS_DYNAMIC_PREDICATE_FILTER_H_
4 #define _MADARA_FILTERS_DYNAMIC_PREDICATE_FILTER_H_
33 const std::string& string_vector_name =
"predicates.allowed")
52 std::vector<std::string> predicates;
70 if (predicates.size() > 0)
73 for (
auto record = records.begin(); record != records.end();)
76 bool accepted_predicate =
false;
77 for (
auto predicate : predicates)
85 accepted_predicate =
true;
88 else if (record->first == predicate)
90 accepted_predicate =
true;
95 if (!accepted_predicate)
99 "DynamicPredicateFilter::filter: "
100 "removing variable %s\n",
101 record->first.c_str())
103 record = records.erase(record);
#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 removing variables with any unwanted predicates.
DynamicPredicateFilter(const std::string &string_vector_name="predicates.allowed")
Constructor.
knowledge::containers::StringVector predicates_
A map of discovered peers.
virtual ~DynamicPredicateFilter()=default
Destructor.
std::string name
The string vector name to bind to inside the knowledge base.
bool initialized_
Tracks if the predicate vector has been initialized.
virtual void filter(knowledge::KnowledgeMap &records, const transport::TransportContext &, knowledge::Variables &vars)
Removes records not in a list of allowed predicates.
Provides an interface for external functions into the MADARA KaRL variable settings.
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.
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
MADARA_EXPORT bool ends_with(const std::string &input, const std::string &ending)
Check if input contains a pattern at the end.
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.