m2etis  0.4
BaseFilter.h
Go to the documentation of this file.
1 /*
2  Copyright (2016) Michael Baer, Daniel Bonrath, All rights reserved.
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15  */
16 
22 #ifndef __M2ETIS_PUBSUB_FILTER_BASEFILTER_H__
23 #define __M2ETIS_PUBSUB_FILTER_BASEFILTER_H__
24 
25 #include <string>
26 
29 
30 #include "boost/shared_ptr.hpp"
31 
41 namespace m2etis {
42 namespace pubsub {
43 namespace filter {
44 
45  template<typename EventType, typename NetworkType>
46  class BaseFilter {
47  public:
48  typedef boost::shared_ptr<EventType> PayloadPtr;
50  }
51  virtual ~BaseFilter() {
52  }
53 
54  // return type for getUnsubscribePayload:
57  UNSUBSCRIBEFROMTREE, // if last filter has been deregistered, unsubscribe from the tree
58  CANCELUNSUBSCRIBE // filter has been deregsitered, but a subscriber of this node has registered
59  // the same filter, so the unsubscribe message must not be forwarded (if the filter strategy can detect this,
60  // otherwise forward unsubscribe message with an appropriate filter info)
61  };
62 
66  virtual void getSubscribePayload(boost::shared_ptr<FilterExp<EventType> > filter, bool is_periodic_resubscribe, typename message::FilterInfo::Ptr filterInfo) = 0;
67 
71  virtual void getUnsubscribePayload(typename message::FilterInfo::Ptr filterInfo) = 0;
72 
83  virtual FilterUnsubscribeInformation getUnsubscribePayload(typename message::FilterInfo::Ptr filterInfo, boost::shared_ptr<FilterExp<EventType> > filter) = 0;
84 
88  virtual std::string getPublishPayload(const PayloadPtr message_text) const = 0;
89 
93  virtual std::string processSubscribePayload(const typename NetworkType::Key & sender_key, typename message::FilterInfo::Ptr filterInfo) = 0;
94 
98  virtual void processUnsubscribePayload(const typename NetworkType::Key & sender_key, typename message::FilterInfo::Ptr filterInfo) = 0;
99 
104  virtual void processRoutingStrategyUnsubscribeNotification(const typename NetworkType::Key & sender_key) = 0;
105 
110  virtual bool match(const typename NetworkType::Key & to, typename message::FilterInfo::Ptr filterInfo, PayloadPtr event) = 0;
111 
116  virtual bool match(PayloadPtr event) = 0;
117 
118  virtual void setSelf(const typename NetworkType::Key & self) = 0;
119  };
120 
121 } /* namespace filter */
122 } /* namespace pubsub */
123 } /* namespace m2etis */
124 
125 #endif /* __M2ETIS_PUBSUB_FILTER_BASEFILTER_H__ */
126 
virtual void setSelf(const typename NetworkType::Key &self)=0
boost::shared_ptr< EventType > PayloadPtr
Definition: BaseFilter.h:48
boost::shared_ptr< FilterInfo > Ptr
Definition: FilterInfo.h:35
virtual std::string processSubscribePayload(const typename NetworkType::Key &sender_key, typename message::FilterInfo::Ptr filterInfo)=0
processes the set of received filters from sender
virtual void getSubscribePayload(boost::shared_ptr< FilterExp< EventType > > filter, bool is_periodic_resubscribe, typename message::FilterInfo::Ptr filterInfo)=0
processes the new filter
virtual void processUnsubscribePayload(const typename NetworkType::Key &sender_key, typename message::FilterInfo::Ptr filterInfo)=0
removes all filters of the sender with the key given
virtual std::string getPublishPayload(const PayloadPtr message_text) const =0
prefilter or preprocess the message and give other nodes a hint (currently not used) ...
virtual bool match(const typename NetworkType::Key &to, typename message::FilterInfo::Ptr filterInfo, PayloadPtr event)=0
matches against dynamic filters of subscriber call this function to filter before forwarding event to...
virtual void processRoutingStrategyUnsubscribeNotification(const typename NetworkType::Key &sender_key)=0
removes all filters of the sender with the key given intended for routing strategies to signal purged...
virtual void getUnsubscribePayload(typename message::FilterInfo::Ptr filterInfo)=0
removes all filters