22 #ifndef __M2ETIS_PUBSUB_PARTITION_DIRECTBROADCASTPARTITION_H__
23 #define __M2ETIS_PUBSUB_PARTITION_DIRECTBROADCASTPARTITION_H__
36 template<
typename NetworkType,
typename EventType>
54 if (partition_filter_vector_.empty()) {
58 for (std::vector<int>::size_type i = 0; i < partition_filter_vector_.size(); ++i) {
59 ret.push_back(
int(i));
64 std::vector<int>::size_type
getPublishTree(
const PayloadPtr message,
const typename NetworkType::Key &
self) {
65 std::vector<int>::size_type i = 0;
67 if (
self == current_filter.second) {
76 std::vector<unsigned int> overlapping_trees;
77 if (partition_filter_vector_.empty()) {
78 overlapping_trees.push_back(0);
79 return overlapping_trees;
81 unsigned int tree_index = 0;
83 for (std::pair<boost::shared_ptr<
filter::FilterExp<EventType>>,
typename NetworkType::Key> partition_filter : partition_filter_vector_) {
84 overlapping_trees.push_back(tree_index);
87 return overlapping_trees;
90 boost::shared_ptr<filter::FilterExp<EventType>>
getPredicate(
size_t id) {
91 assert(
id < partition_filter_vector_.size());
92 return partition_filter_vector_[id].first;
101 partition_filter_vector_.push_back(std::make_pair(predicate, root));
105 partition_filter_vector_.erase(partition_filter_vector_.begin() + int64_t(
id));
111 void changeRoot(
size_t id,
typename NetworkType::Key & root) {
112 partition_filter_vector_[id].second = root;
116 std::stringstream ss;
117 ss <<
"DBParition with " << partition_filter_vector_.size() <<
" elements: (";
118 for (
unsigned int i = 0; i < partition_filter_vector_.size(); i++) {
119 ss <<
"(" << partition_filter_vector_[i].second.toStr() <<
", " << partition_filter_vector_[i].first->toString() <<
"), ";
126 std::vector<std::pair<boost::shared_ptr<filter::FilterExp<EventType>>,
typename NetworkType::Key> > partition_filter_vector_;
void changeRoot(size_t id, typename NetworkType::Key &root)
static const bool DYNAMIC_PARTITION
boost::shared_ptr< filter::FilterExp< EventType > > getPredicate(size_t id)
returns the predicate for the given partition id (dynamic)
std::vector< int > getTreeNames()
returns amount of partitions this strategy contains (static & dynamic)
void removePartition(size_t id)
removes the partition with the given id (dynamic)
bool createPartition(const typename NetworkType::Key &root)
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)
boost::shared_ptr< EventType > PayloadPtr
std::vector< int >::size_type getPublishTree(const PayloadPtr message, const typename NetworkType::Key &self)
returns the tree index the given node with the given payload should publish on (static & dynamic) ...
DirectBroadcastPartition()
void createRendezvousPartition(const typename NetworkType::Key &rendezvous)
creates a base partition for the RP (dynamic)
virtual ~DirectBroadcastPartition()
void addPartition(boost::shared_ptr< filter::FilterExp< EventType >> predicate, const typename NetworkType::Key &root)
std::vector< unsigned int > getSubscribeTrees(boost::shared_ptr< filter::FilterExp< EventType > > dynamic_filter)
void changePredicate(size_t, boost::shared_ptr< filter::FilterExp< EventType >>)
changes the filter predicate for the partition with the given id (dynamic)