m2etis  0.4
GeneralBooleanExpressionsPreProcessVisitor.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_GENERALBOOLEANEXPRESSIONSPREPROCESSVISITOR_H__
23 #define __M2ETIS_PUBSUB_FILTER_GENERALBOOLEANEXPRESSIONSPREPROCESSVISITOR_H__
24 
25 #include <set>
26 
28 
29 namespace m2etis {
30 namespace pubsub {
31 namespace filter {
32 
33  template<typename EventType, typename NetworkType>
34  class GeneralBooleanExpressionsPreProcessVisitor : public FilterVisitor<EventType> {
35  public:
36  GeneralBooleanExpressionsPreProcessVisitor(std::vector<std::shared_ptr<PredicateIndex<EventType> > > * predicate_indexes, std::map<PredicateIdentifierFactory::PredicateID, std::multiset<SubscriptionIdentifierFactory::SubscriptionID> > * predicate_subscription_association_table, SubscriptionIdentifierFactory::SubscriptionID current_subscription_id, PredicateIdentifierFactory * predicate_identifier_factory) : predicate_indexes_(predicate_indexes), predicate_subscription_association_table_(predicate_subscription_association_table), current_subscription_id_(current_subscription_id), predicate_identifier_factory_(predicate_identifier_factory) {
37  }
38 
40  }
41 
42  virtual void Visit(const FilterExp<EventType> *) override {
43  M2ETIS_THROW_API("GeneralBooleanExpressionsPreProcessVisitor", "FilterExp not allowed in general boolean expressions filter strategy.");
44  }
45 
46  virtual void Visit(const AndExp<EventType> *) override {
47  // not needed for predicate indexing
48  }
49 
50  virtual void Visit(const OrExp<EventType> * orexp) override {
51  // not needed for predicate indexing
52  }
53 
54  virtual void Visit(const Predicate<EventType> * current_predicate) override {
55  attribute_type_information.predicate_indexes_ = predicate_indexes_;
56  attribute_type_information.predicate_subscription_association_table_ = predicate_subscription_association_table_;
57  attribute_type_information.predicate_identifier_factory_ = predicate_identifier_factory_;
58  attribute_type_information.current_subscription_id_ = current_subscription_id_;
59 
60  current_predicate->getAttributeType(*this);
61  }
62 
64  auto general_boolean_expressions_ptr = new GeneralBooleanExpressionsFilter<EventType, NetworkType>();
65  attribute_type_information(filter, general_boolean_expressions_ptr);
66  delete general_boolean_expressions_ptr;
67  }
68 
69  virtual void getAttributeType(const GreaterThanAttributeFilter<EventType, int> * filter) override {
70  auto general_boolean_expressions_ptr = new GeneralBooleanExpressionsFilter<EventType, NetworkType>();
71  attribute_type_information(filter, general_boolean_expressions_ptr);
72  delete general_boolean_expressions_ptr;
73  }
74 
75  virtual void getAttributeType(const LessThanAttributeFilter<EventType, std::string> * filter) override {
76  auto general_boolean_expressions_ptr = new GeneralBooleanExpressionsFilter<EventType, NetworkType>();
77  attribute_type_information(filter, general_boolean_expressions_ptr);
78  delete general_boolean_expressions_ptr;
79  }
80 
81  virtual void getAttributeType(const LessThanAttributeFilter<EventType, int> * filter) override {
82  auto general_boolean_expressions_ptr = new GeneralBooleanExpressionsFilter<EventType, NetworkType>();
83  attribute_type_information(filter, general_boolean_expressions_ptr);
84  delete general_boolean_expressions_ptr;
85  }
86 
87  virtual void getAttributeType(const EqualsAttributeFilter<EventType, std::string> * filter) override {
88  auto general_boolean_expressions_ptr = new GeneralBooleanExpressionsFilter<EventType, NetworkType>();
89  attribute_type_information(filter, general_boolean_expressions_ptr);
90  delete general_boolean_expressions_ptr;
91  } // getAttribute Type for EqualsAttributeFilter and string
92 
93  virtual void getAttributeType(const EqualsAttributeFilter<EventType, int> * filter) override {
94  auto general_boolean_expressions_ptr = new GeneralBooleanExpressionsFilter<EventType, NetworkType>();
95  attribute_type_information(filter, general_boolean_expressions_ptr);
96  delete general_boolean_expressions_ptr;
97  } // getAttributeType for EqualsAttributeFilter and int
98 
100  auto general_boolean_expressions_ptr = new GeneralBooleanExpressionsFilter<EventType, NetworkType>();
101  attribute_type_information(filter, general_boolean_expressions_ptr);
102  delete general_boolean_expressions_ptr;
103  }
104 
105  virtual void getAttributeType(const NotEqualsAttributeFilter<EventType, int> * filter) override {
106  auto general_boolean_expressions_ptr = new GeneralBooleanExpressionsFilter<EventType, NetworkType>();
107  attribute_type_information(filter, general_boolean_expressions_ptr);
108  delete general_boolean_expressions_ptr;
109  }
110 
112 
113  private:
114  // reference to predicate_indexes in filter class:
115  std::vector<std::shared_ptr<PredicateIndex<EventType> > > * predicate_indexes_;
116 
117  std::map<PredicateIdentifierFactory::PredicateID, std::multiset<SubscriptionIdentifierFactory::SubscriptionID> > * predicate_subscription_association_table_;
118  SubscriptionIdentifierFactory::SubscriptionID current_subscription_id_;
119  PredicateIdentifierFactory * predicate_identifier_factory_;
120 
121  AttributeTypeInformation<EventType, NetworkType> attribute_type_information;
122  };
123  // class GeneralBooleanExpressionsPreProcessVisitor
124 
125 } /* namespace filter */
126 } /* namespace pubsub */
127 } /* namespace m2etis */
128 
129 #endif /* __M2ETIS_PUBSUB_FILTER_GENERALBOOLEANEXPRESSIONSPREPROCESSVISITOR_H__ */
130 
virtual void getAttributeType(const NotEqualsAttributeFilter< EventType, int > *filter) override
virtual void getAttributeType(const LessThanAttributeFilter< EventType, std::string > *filter) override
virtual void getAttributeType(const GreaterThanAttributeFilter< EventType, std::string > *filter) override
virtual void getAttributeType(const LessThanAttributeFilter< EventType, int > *filter) override
virtual void getAttributeType(const GreaterThanAttributeFilter< EventType, int > *filter) override
GeneralBooleanExpressionsPreProcessVisitor(std::vector< std::shared_ptr< PredicateIndex< EventType > > > *predicate_indexes, std::map< PredicateIdentifierFactory::PredicateID, std::multiset< SubscriptionIdentifierFactory::SubscriptionID > > *predicate_subscription_association_table, SubscriptionIdentifierFactory::SubscriptionID current_subscription_id, PredicateIdentifierFactory *predicate_identifier_factory)
virtual void getAttributeType(const NotEqualsAttributeFilter< EventType, std::string > *filter) override
virtual void getAttributeType(const EqualsAttributeFilter< EventType, std::string > *filter) override
virtual void getAttributeType(const EqualsAttributeFilter< EventType, int > *filter) override
virtual void Visit(const Predicate< EventType > *current_predicate) override
#define M2ETIS_THROW_API(module, message)
throws on wrong API usage
Definition: Exceptions.h:40
virtual void getAttributeType(FilterVisitor< EventType > &visitor) const =0