m2etis  0.4
BasePartition.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_PARTITION_BASEPARTITION_H__
23 #define __M2ETIS_PUBSUB_PARTITION_BASEPARTITION_H__
24 
25 #include "boost/assign/list_of.hpp"
26 
27 namespace m2etis {
28 namespace pubsub {
29 namespace partition {
30 
31  template <typename NetworkType, typename EventType>
32  class BasePartition {
33  public:
34  typedef boost::shared_ptr<EventType> PayloadPtr;
35 
37  }
38 
39  virtual ~BasePartition() {}
40 
44  virtual void createRendezvousPartition(const typename NetworkType::Key & rendezvous) = 0;
45 
49  virtual std::vector<int> getTreeNames() = 0;
50 
54  virtual std::vector<int>::size_type getPublishTree(const PayloadPtr message, const typename NetworkType::Key & self) = 0;
55 
59  virtual std::vector<unsigned int> getSubscribeTrees(boost::shared_ptr<filter::FilterExp<EventType>> dynamic_filter) = 0;
60 
64  virtual boost::shared_ptr<filter::FilterExp<EventType>> getPredicate(size_t id) = 0;
65 
69  virtual bool createPartition(const typename NetworkType::Key & root) = 0;
70 
74  virtual void addPartition(boost::shared_ptr<filter::FilterExp<EventType> > predicate, const typename NetworkType::Key & root) = 0;
75 
79  virtual void removePartition(size_t id) = 0;
80 
84  virtual void changePredicate(size_t id, boost::shared_ptr<filter::FilterExp<EventType>> predicates) = 0;
85 
86  virtual void changeRoot(size_t id, typename NetworkType::Key & root) = 0;
87 
88  virtual std::string toString() {
89  return "BasePartition";
90  }
91  };
92 
93 } /* namespace partition */
94 } /* namespace pubsub */
95 } /* namespace m2etis */
96 
97 #endif /* __M2ETIS_PUBSUB_PARTITION_BASEPARTITION_H__ */
98 
virtual void createRendezvousPartition(const typename NetworkType::Key &rendezvous)=0
creates a base partition for the RP (dynamic)
virtual boost::shared_ptr< filter::FilterExp< EventType > > getPredicate(size_t id)=0
returns the predicate for the given partition id (dynamic)
virtual std::vector< int >::size_type getPublishTree(const PayloadPtr message, const typename NetworkType::Key &self)=0
returns the tree index the given node with the given payload should publish on (static & dynamic) ...
boost::shared_ptr< EventType > PayloadPtr
Definition: BasePartition.h:34
virtual void changePredicate(size_t id, boost::shared_ptr< filter::FilterExp< EventType >> predicates)=0
changes the filter predicate for the partition with the given id (dynamic)
virtual void removePartition(size_t id)=0
removes the partition with the given id (dynamic)
virtual void addPartition(boost::shared_ptr< filter::FilterExp< EventType > > predicate, const typename NetworkType::Key &root)=0
adds a new partition to the strategy at nodes not being RP (dynamic)
virtual void changeRoot(size_t id, typename NetworkType::Key &root)=0
virtual std::vector< unsigned int > getSubscribeTrees(boost::shared_ptr< filter::FilterExp< EventType >> dynamic_filter)=0
returns the tree indices of all trees matching the predicate to subscribe on (static & dynamic) ...
virtual bool createPartition(const typename NetworkType::Key &root)=0
can create a new partition for this channel if a new node (root) joins, return true, if a new partition was created, otherwise false (dynamic)
virtual std::vector< int > getTreeNames()=0
returns amount of partitions this strategy contains (static & dynamic)