OmniSciDB  c0231cc57d
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RelRexDagVisitor.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc.
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 
28 #pragma once
29 
30 #include "../RelAlgDag.h"
31 #include "TypeHandler.h"
32 
33 #include <array>
34 
36  public:
37  virtual ~RelRexDagVisitor() = default;
38  virtual void visit(RelAlgNode const*);
39  virtual void visit(RexScalar const*);
40 
41  protected:
42  virtual void visit(RelAggregate const*) {}
43  virtual void visit(RelCompound const*);
44  virtual void visit(RelFilter const*);
45  virtual void visit(RelJoin const*);
46  virtual void visit(RelLeftDeepInnerJoin const*);
47  virtual void visit(RelLogicalUnion const*) {}
48  virtual void visit(RelLogicalValues const*);
49  virtual void visit(RelModify const*) {}
50  virtual void visit(RelProject const*);
51  virtual void visit(RelScan const*) {}
52  virtual void visit(RelSort const*) {}
53  virtual void visit(RelTableFunction const*);
54  virtual void visit(RelTranslatedJoin const*);
55 
56  virtual void visit(RexAbstractInput const*) {}
57  virtual void visit(RexCase const*);
58  virtual void visit(RexFunctionOperator const*);
59  virtual void visit(RexInput const*);
60  virtual void visit(RexLiteral const*) {}
61  virtual void visit(RexOperator const*);
62  virtual void visit(RexRef const*) {}
63  virtual void visit(RexSubQuery const*);
64  virtual void visit(RexWindowFunctionOperator const*);
65 
66  void castAndVisit(RelAlgNode const*);
67 
68  private:
69  template <typename T, typename U>
70  void cast(T const* node) {
71  visit(dynamic_cast<U const*>(node));
72  }
73 
74  template <typename T, size_t N>
75  using Handlers = std::array<TypeHandler<RelRexDagVisitor, T>, N>;
76 
77  template <typename T, typename... Ts>
78  static Handlers<T, sizeof...(Ts)> make_handlers();
79 };
virtual void visit(RelScan const *)
void cast(T const *node)
virtual void visit(RelAlgNode const *)
virtual void visit(RexRef const *)
virtual void visit(RexAbstractInput const *)
std::array< TypeHandler< RelRexDagVisitor, T >, N > Handlers
static Handlers< T, sizeof...(Ts)> make_handlers()
virtual void visit(RexLiteral const *)
virtual void visit(RelAggregate const *)
void castAndVisit(RelAlgNode const *)
constexpr unsigned N
Definition: Utm.h:110
virtual ~RelRexDagVisitor()=default
virtual void visit(RelLogicalUnion const *)
virtual void visit(RelSort const *)
Sortable utility struct for visitor patterns.
virtual void visit(RelModify const *)