m2etis  0.4
DecisionTreePreProcessVisitor.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_DECISIONTREEPREPROCESSVISITOR_H__
23 #define __M2ETIS_PUBSUB_FILTER_DECISIONTREEPREPROCESSVISITOR_H__
24 
27 
34 namespace m2etis {
35 namespace pubsub {
36 namespace filter {
37 
38  template<typename EventType, typename NetworkType>
39  class DecisionTreePreProcessVisitor : public FilterVisitor<EventType> {
40  public:
41  DecisionTreePreProcessVisitor(boost::shared_ptr<DecisionTreeNode<EventType, NetworkType> > * v) : current_decision_tree_node_ptr_(v) {
42  }
43 
45  }
46 
47  // not allowed for OrExp
48  virtual void Visit(const FilterExp<EventType> *) override {
49  M2ETIS_THROW_API("DecisionTreeProcessVisitor", "FilterExp not allowed in decision tree filter strategy.");
50  }
51 
52  virtual void Visit(const AndExp<EventType> *) override {
53  }
54 
55  virtual void Visit(const OrExp<EventType> * orexp) override {
56  M2ETIS_THROW_API("DecisionTreeProcessVisitor", "OrExp not allowed in decision tree filter strategy.");
57  }
58 
59  virtual void Visit(const Predicate<EventType> * equals_predicate) override {
60  // order of preprocess algorithm differs from description in aguilera´s paper
61  // because in follow the attribute type of the next node is not known
62  attribute_type_information.decision_tree_node_ptr_ = current_decision_tree_node_ptr_;
63 
64  equals_predicate->getAttributeType(*this);
65 
66  current_decision_tree_node_ptr_ = attribute_type_information.decision_tree_node_ptr_;
67  }
68 
70  auto decision_tree_ptr = new DecisionTreeFilter<EventType, NetworkType>();
71  attribute_type_information(filter, decision_tree_ptr);
72  delete decision_tree_ptr;
73  }
74 
76  auto decision_tree_ptr = new DecisionTreeFilter<EventType, NetworkType>();
77  attribute_type_information(filter, decision_tree_ptr);
78  delete decision_tree_ptr;
79  }
80 
82 
83  boost::shared_ptr<DecisionTreeNode<EventType, NetworkType> > * get_current_decision_tree_node_ptr() {
84  return current_decision_tree_node_ptr_;
85  }
86 
87  private:
88  // this is the pointer to the shared_ptr in the map of the parent node
89  // the attribute type is not known until accessing the next node, respectively
90  boost::shared_ptr<DecisionTreeNode<EventType, NetworkType> > * current_decision_tree_node_ptr_;
91 
92  AttributeTypeInformation<EventType, NetworkType> attribute_type_information;
93  };
94  // class DecisionTreePreProcessVisitor
95 
96 } /* namespace filter */
97 } /* namespace pubsub */
98 } /* namespace m2etis */
99 
100 #endif /* __M2ETIS_PUBSUB_FILTER_DECISIONTREEPREPROCESSVISITOR_H__ */
101 
virtual void getAttributeType(const EqualsAttributeFilter< EventType, int > *filter)
virtual void Visit(const OrExp< EventType > *orexp) override
virtual void Visit(const FilterExp< EventType > *) override
virtual void Visit(const AndExp< EventType > *) override
virtual void getAttributeType(const EqualsAttributeFilter< EventType, std::string > *filter)
boost::shared_ptr< DecisionTreeNode< EventType, NetworkType > > * get_current_decision_tree_node_ptr()
DecisionTreePreProcessVisitor(boost::shared_ptr< DecisionTreeNode< EventType, NetworkType > > *v)
#define M2ETIS_THROW_API(module, message)
throws on wrong API usage
Definition: Exceptions.h:40
virtual void getAttributeType(FilterVisitor< EventType > &visitor) const =0
virtual void Visit(const Predicate< EventType > *equals_predicate) override