22 #ifndef __M2ETIS_PUBSUB_FILTER_DECISIONTREEFILTER_H__
23 #define __M2ETIS_PUBSUB_FILTER_DECISIONTREEFILTER_H__
35 #include "boost/shared_ptr.hpp"
64 template<
typename EventType,
typename NetworkType>
82 filter->Accept(decision_tree_preprocess_visitor);
93 has_new_subscription_ =
true;
95 fInfo->dynamic_filter_ = decision_tree_;
97 fInfo->isUnsubscribe_ =
false;
103 decision_tree_ = boost::shared_ptr<DecisionTreeNode<EventType, NetworkType> >();
106 fInfo->dynamic_filter_ = boost::shared_ptr<DecisionTreeNode<EventType, NetworkType> >();
112 filter->Accept(decision_tree_walker_visitor);
119 if (!(decision_tree_->hasSubscription(self_))) {
122 fInfo->dynamic_filter_ = boost::shared_ptr<DecisionTreeNode<EventType, NetworkType> >();
137 fInfo->unsubscribe_filter_ = filter;
138 fInfo->isUnsubscribe_ =
true;
149 if (fInfo->isUnsubscribe_) {
153 fInfo->unsubscribe_filter_->Accept(decision_tree_walker_visitor);
165 if (!decision_tree_) {
166 decision_tree_ = fInfo->dynamic_filter_;
168 decision_tree_->merge(fInfo->dynamic_filter_, sender);
171 has_new_subscription_ =
true;
177 decision_tree_->removeSubscriber(sender);
182 decision_tree_->removeSubscriber(sender);
187 static std::set<typename NetworkType::Key> matching_subscribers;
189 if (!event || current_event_ != event || has_new_subscription_) {
191 matching_subscribers.clear();
192 has_new_subscription_ =
false;
193 current_event_ = event;
194 decision_tree_->visit(*event, matching_subscribers);
197 return (matching_subscribers.find(to) == matching_subscribers.end() ?
false :
true);
205 void setSelf(
const typename NetworkType::Key &
self) {
211 typename NetworkType::Key self_;
221 boost::shared_ptr<DecisionTreeNode<EventType, NetworkType> > decision_tree_;
224 bool has_new_subscription_;
225 boost::shared_ptr<EventType> current_event_;
virtual std::string getPublishPayload(const typename BaseFilter< EventType, NetworkType >::PayloadPtr message_text) const override
BaseFilter< EventType, NetworkType >::FilterUnsubscribeInformation getUnsubscribePayload(typename message::FilterInfo::Ptr filterInfo, boost::shared_ptr< FilterExp< EventType > > filter)
deregisters individual filter returns information whether to
virtual ~DecisionTreeFilter()
void setSelf(const typename NetworkType::Key &self)
bool match(typename BaseFilter< EventType, NetworkType >::PayloadPtr event)
virtual void processUnsubscribePayload(const typename NetworkType::Key &sender, typename message::FilterInfo::Ptr filterInfo) override
removes all filters of the sender with the key given
bool match(const typename NetworkType::Key &to, typename message::FilterInfo::Ptr filterInfo, typename BaseFilter< EventType, NetworkType >::PayloadPtr event)
FilterUnsubscribeInformation
boost::shared_ptr< DecisionTreeFilterInfo< EventType, NetworkType > > Ptr
boost::shared_ptr< DecisionTreeNode< EventType, NetworkType > > * get_current_decision_tree_node_ptr()
boost::shared_ptr< EventType > PayloadPtr
boost::shared_ptr< FilterInfo > Ptr
virtual void processRoutingStrategyUnsubscribeNotification(const typename NetworkType::Key &sender) override
removes all filters of the sender with the key given intended for routing strategies to signal purged...
boost::shared_ptr< DecisionTreeNode< EventType, NetworkType > > * get_current_decision_tree_node_ptr()
message::DecisionTreeFilterInfo< EventType, NetworkType > FilterInfoType
virtual std::string processSubscribePayload(const typename NetworkType::Key &sender, typename message::FilterInfo::Ptr filterInfo) override
processes the set of received filters from sender
#define M2ETIS_LOG_ERROR(module, message)
virtual void getUnsubscribePayload(typename message::FilterInfo::Ptr filterInfo) override
removes all filters
virtual void getSubscribePayload(boost::shared_ptr< FilterExp< EventType > > filter, bool is_periodic_resubscribe, typename message::FilterInfo::Ptr filterInfo) override
processes the new filter