22 #ifndef __M2ETIS_PUBSUB_FILTER_ATTRIBUTETYPEINFORMATION_H__
23 #define __M2ETIS_PUBSUB_FILTER_ATTRIBUTETYPEINFORMATION_H__
39 #include "boost/make_shared.hpp"
79 template<
typename EventType,
typename NetworkType>
88 if (!*decision_tree_node_ptr_) {
97 decision_tree_node_ptr_ = &(dont_care_subnode_ptr_);
102 auto result_subnode_iterator = result_subnodes.find(equals_predicate->
get_constants()[0]);
104 if (result_subnode_iterator != result_subnodes.end()) {
106 decision_tree_node_ptr_ = &(result_subnode_iterator->second);
109 result_subnodes[equals_predicate->
get_constants()[0]] = boost::shared_ptr<DecisionTreeNode<EventType, NetworkType> >();
111 decision_tree_node_ptr_ = &(result_subnodes[equals_predicate->
get_constants()[0]]);
125 decision_tree_node_ptr_ = &(dont_care_subnode_ptr_);
130 auto result_subnode_iterator = result_subnodes.find(equals_predicate->
get_constants()[0]);
132 if (result_subnode_iterator != result_subnodes.end()) {
135 decision_tree_node_ptr_ = &(result_subnode_iterator->second);
140 decision_tree_node_ptr_ =
nullptr;
148 M2ETIS_THROW_API(
"AttributeTypeInformation",
"function called for AttributeFilter. Should be called for special kind.");
153 bool has_predicate =
false;
155 for (
auto predicate_index : (*predicate_indexes_)) {
156 if ((predicate_index)->get_operator() ==
EQUALS && (predicate_index)->get_attribute_id() == equals_predicate->
get_attribute_id()) {
158 has_predicate =
true;
161 auto new_predicate_id = equals_predicate_index->
addPredicate(equals_predicate);
165 if (predicate_subscription_association_table_->find(new_predicate_id) == predicate_subscription_association_table_->end()) {
166 (*predicate_subscription_association_table_)[new_predicate_id] = std::multiset<SubscriptionIdentifierFactory::SubscriptionID>{current_subscription_id_};
168 (*predicate_subscription_association_table_)[new_predicate_id].insert(current_subscription_id_);
173 if (!has_predicate) {
175 auto equals_predicate_index = std::make_shared<EqualsPredicateIndex<EventType, AttributeType> >(equals_predicate->
get_attribute_id(), predicate_identifier_factory_);
177 predicate_indexes_->push_back(equals_predicate_index);
179 auto new_predicate_id = equals_predicate_index->addPredicate(equals_predicate);
181 (*predicate_subscription_association_table_)[new_predicate_id] = std::multiset<SubscriptionIdentifierFactory::SubscriptionID>{current_subscription_id_};
187 bool has_predicate =
false;
189 for (
auto predicate_index : (*predicate_indexes_)) {
190 if ((predicate_index)->get_operator() ==
NOTEQUALS && (predicate_index)->get_attribute_id() == notequals_predicate->
get_attribute_id()) {
192 has_predicate =
true;
195 auto new_predicate_id = notequals_predicate_index->
addPredicate(notequals_predicate);
199 if (predicate_subscription_association_table_->find(new_predicate_id) == predicate_subscription_association_table_->end()) {
200 (*predicate_subscription_association_table_)[new_predicate_id] = std::multiset<SubscriptionIdentifierFactory::SubscriptionID>{current_subscription_id_};
202 (*predicate_subscription_association_table_)[new_predicate_id].insert(current_subscription_id_);
207 if (!has_predicate) {
209 auto notequals_predicate_index = std::make_shared<NotEqualsPredicateIndex<EventType, AttributeType> >(notequals_predicate->
get_attribute_id(), predicate_identifier_factory_);
211 predicate_indexes_->push_back(notequals_predicate_index);
213 auto new_predicate_id = notequals_predicate_index->addPredicate(notequals_predicate);
215 (*predicate_subscription_association_table_)[new_predicate_id] = std::multiset<SubscriptionIdentifierFactory::SubscriptionID>{current_subscription_id_};
221 bool has_predicate =
false;
222 for (
auto predicate_index : (*predicate_indexes_)) {
223 if ((predicate_index)->get_operator() ==
GREATERTHAN && (predicate_index)->get_attribute_id() == greater_than_predicate->
get_attribute_id()) {
227 has_predicate =
true;
230 auto new_predicate_id = greaterthan_predicate_index->
addPredicate(greater_than_predicate);
234 if (predicate_subscription_association_table_->find(new_predicate_id) == predicate_subscription_association_table_->end()) {
235 (*predicate_subscription_association_table_)[new_predicate_id] = std::multiset<SubscriptionIdentifierFactory::SubscriptionID>{current_subscription_id_};
237 (*predicate_subscription_association_table_)[new_predicate_id].insert(current_subscription_id_);
242 if (!has_predicate) {
244 auto greater_than_predicate_index = std::make_shared<GreaterThanPredicateIndex<EventType, AttributeType> >(greater_than_predicate->
get_attribute_id(), predicate_identifier_factory_);
246 predicate_indexes_->push_back(greater_than_predicate_index);
248 auto new_predicate_id = greater_than_predicate_index->addPredicate(greater_than_predicate);
250 (*predicate_subscription_association_table_)[new_predicate_id] = std::multiset<SubscriptionIdentifierFactory::SubscriptionID>{current_subscription_id_};
256 bool has_predicate =
false;
257 for (
auto predicate_index : (*predicate_indexes_)) {
258 if ((predicate_index)->get_operator() ==
LESSTHAN && (predicate_index)->get_attribute_id() == less_than_predicate->
get_attribute_id()) {
260 has_predicate =
true;
263 auto new_predicate_id = lessthan_predicate_index->
addPredicate(less_than_predicate);
267 if (predicate_subscription_association_table_->find(new_predicate_id) == predicate_subscription_association_table_->end()) {
268 (*predicate_subscription_association_table_)[new_predicate_id] = std::multiset<SubscriptionIdentifierFactory::SubscriptionID>{current_subscription_id_};
270 (*predicate_subscription_association_table_)[new_predicate_id].insert(current_subscription_id_);
275 if (!has_predicate) {
277 auto less_than_predicate_index = std::make_shared<LessThanPredicateIndex<EventType, AttributeType> >(less_than_predicate->
get_attribute_id(), predicate_identifier_factory_);
279 predicate_indexes_->push_back(less_than_predicate_index);
281 auto new_predicate_id = less_than_predicate_index->addPredicate(less_than_predicate);
283 (*predicate_subscription_association_table_)[new_predicate_id] = std::multiset<SubscriptionIdentifierFactory::SubscriptionID>{current_subscription_id_};
290 boost::shared_ptr<DecisionTreeNode<EventType, NetworkType> > * decision_tree_node_ptr_;
293 std::vector<std::shared_ptr<PredicateIndex<EventType> > > * predicate_indexes_;
294 std::map<PredicateIdentifierFactory::PredicateID, std::multiset<SubscriptionIdentifierFactory::SubscriptionID> > * predicate_subscription_association_table_;
PredicateIdentifierFactory::PredicateID addPredicate(const LessThanAttributeFilter< EventType, AttributeType > *less_than_attribute_filter)
PredicateIdentifierFactory::PredicateID addPredicate(const EqualsAttributeFilter< EventType, AttributeType > *equals_attribute_filter)
PredicateIdentifierFactory::PredicateID addPredicate(const GreaterThanAttributeFilter< EventType, AttributeType > *greater_than_attribute_filter)
const std::vector< AttributeType > get_constants() const
PredicateIdentifierFactory::PredicateID addPredicate(const NotEqualsAttributeFilter< EventType, AttributeType > *notequals_attribute_filter)
AttributeName get_attribute_id() const
#define M2ETIS_THROW_API(module, message)
throws on wrong API usage