22 #ifndef __M2ETIS_PUBSUB_FILTER_BRUTEFORCEFILTER_H__
23 #define __M2ETIS_PUBSUB_FILTER_BRUTEFORCEFILTER_H__
33 #include "boost/make_shared.hpp"
34 #include "boost/shared_ptr.hpp"
47 template<
typename EventType,
typename NetworkType>
67 dynamic_filters_[
self_].insert(filter);
70 auto filters = std::set<boost::shared_ptr<FilterExp<EventType>>>();
72 for (
auto key_filters_pair : dynamic_filters_) {
73 for (
auto current_filter : key_filters_pair.second) {
74 filters.insert(current_filter);
79 fInfo->dynamic_filter_ = filters;
80 fInfo->isUnsubscribe_ =
false;
84 dynamic_filters_.clear();
87 fInfo->dynamic_filter_ = std::set<boost::shared_ptr<FilterExp<EventType>>>();
91 removeFilter(
self_, filter);
93 if (dynamic_filters_[
self_].empty()) {
96 fInfo->dynamic_filter_ = std::set<boost::shared_ptr<FilterExp<EventType>>>();
101 bool isFilterFound =
false;
104 for (
auto keySubscriptionPair : dynamic_filters_) {
105 for (
auto registered_filter : keySubscriptionPair.second) {
106 if (*registered_filter == *filter) {
107 isFilterFound =
true;
118 fInfo->dynamic_filter_ = std::set<boost::shared_ptr<FilterExp<EventType> > >({filter});
119 fInfo->isUnsubscribe_ =
true;
131 if (fInfo->isUnsubscribe_) {
135 removeFilter(sender_key, *(fInfo->dynamic_filter_.begin()));
139 dynamic_filters_[sender_key] = fInfo->dynamic_filter_;
145 dynamic_filters_.erase(sender_key);
149 dynamic_filters_.erase(sender_key);
153 for (
auto filter_of_recipient : (dynamic_filters_[to])) {
156 filter_of_recipient->Accept(dynamic_filter_visitor);
170 virtual void setSelf(
const typename NetworkType::Key &
self)
override {
175 void removeFilter(
const typename NetworkType::Key & key, boost::shared_ptr<
FilterExp<EventType> > filter) {
177 for (
auto filter_iter = dynamic_filters_[key].begin(); filter_iter != dynamic_filters_[key].end(); ++filter_iter) {
178 if (**filter_iter == *filter) {
179 dynamic_filters_[key].erase(filter_iter);
193 std::map<typename NetworkType::Key, std::set<boost::shared_ptr<FilterExp<EventType> > > > dynamic_filters_;
virtual std::string processSubscribePayload(const typename NetworkType::Key &sender_key, typename message::FilterInfo::Ptr filterInfo) override
processes the set of received filters from sender
virtual void processUnsubscribePayload(const typename NetworkType::Key &sender_key, typename message::FilterInfo::Ptr filterInfo) override
removes all filters of the sender with the key given
virtual void setSelf(const typename NetworkType::Key &self) override
virtual BaseFilter< EventType, NetworkType >::FilterUnsubscribeInformation getUnsubscribePayload(typename message::FilterInfo::Ptr filterInfo, boost::shared_ptr< FilterExp< EventType >> filter) override
boost::shared_ptr< BruteForceFilterInfo< EventType > > Ptr
FilterUnsubscribeInformation
boost::shared_ptr< EventType > PayloadPtr
boost::shared_ptr< FilterInfo > Ptr
virtual std::string getPublishPayload(const typename BaseFilter< EventType, NetworkType >::PayloadPtr message_text) const override
BruteForceFilter()
Constructor.
virtual void getUnsubscribePayload(typename message::FilterInfo::Ptr filterInfo) override
removes all filters
#define M2ETIS_LOG_ERROR(module, message)
virtual ~BruteForceFilter()
virtual void getSubscribePayload(boost::shared_ptr< FilterExp< EventType >> filter, bool, typename message::FilterInfo::Ptr filterInfo) override
message::BruteForceFilterInfo< EventType > FilterInfoType
virtual void processRoutingStrategyUnsubscribeNotification(const typename NetworkType::Key &sender_key) override
removes all filters of the sender with the key given intended for routing strategies to signal purged...
virtual bool match(const typename NetworkType::Key &to, typename message::FilterInfo::Ptr filterInfo, typename BaseFilter< EventType, NetworkType >::PayloadPtr event) override
virtual bool match(typename BaseFilter< EventType, NetworkType >::PayloadPtr event) override