-
Notifications
You must be signed in to change notification settings - Fork 2
/
algebratransformer.h
107 lines (89 loc) · 2.17 KB
/
algebratransformer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#pragma once
#include "algebra.h"
namespace sparqlxx
{
struct AlgebraTransformer
{
virtual auto operator()(Algebra::Op&& o) -> Algebra::Op;
virtual auto transform(Algebra::Null&& n) -> Algebra::Op
{
return n;
}
virtual auto transform(Algebra::Basic&& b) -> Algebra::Op
{
return b;
}
virtual auto transform(Algebra::Quad&& q) -> Algebra::Op
{
return q;
}
virtual auto transform(Algebra::Join&& op) -> Algebra::Op
{
for (auto& subop : op.ops)
*subop = (*this)(std::move(*subop));
return op;
}
virtual auto transform(Algebra::LeftJoin&& op) -> Algebra::Op
{
*op.a = (*this)(std::move(*op.a));
*op.b = (*this)(std::move(*op.b));
return op;
}
virtual auto transform(Algebra::Minus&& op) -> Algebra::Op
{
*op.a = (*this)(std::move(*op.a));
*op.b = (*this)(std::move(*op.b));
return op;
}
virtual auto transform(Algebra::Union&& op) -> Algebra::Op
{
*op.a = (*this)(std::move(*op.a));
*op.b = (*this)(std::move(*op.b));
return op;
}
virtual auto transform(Algebra::Graph&& op) -> Algebra::Op
{
*op.data = (*this)(std::move(*op.data));
return op;
}
virtual auto transform(Algebra::Service&& op) -> Algebra::Op
{
*op.data = (*this)(std::move(*op.data));
return op;
}
virtual auto transform(Algebra::Filter&& op) -> Algebra::Op
{
*op.data = (*this)(std::move(*op.data));
return op;
}
virtual auto transform(Algebra::Extend&& op) -> Algebra::Op
{
*op.data = (*this)(std::move(*op.data));
return op;
}
virtual auto transform(Algebra::Project&& op) -> Algebra::Op
{
*op.data = (*this)(std::move(*op.data));
return op;
}
virtual auto transform(Algebra::Distinct&& op) -> Algebra::Op
{
*op.data = (*this)(std::move(*op.data));
return op;
}
virtual auto transform(Algebra::Reduced&& op) -> Algebra::Op
{
*op.data = (*this)(std::move(*op.data));
return op;
}
virtual auto transform(Algebra::Slice&& op) -> Algebra::Op
{
*op.data = (*this)(std::move(*op.data));
return op;
}
};
inline auto AlgebraTransformer::operator()(Algebra::Op&& o) -> Algebra::Op
{
return o.call([this](auto& op){return transform(std::move(op));});
}
}