PerceMon
s4u.hpp
1#pragma once
2
3#ifndef __PERCEMON_S4U_HPP__
4#define __PERCEMON_S4U_HPP__
5
6#include <memory>
7#include <optional>
8#include <stdexcept>
9#include <string>
10#include <variant>
11#include <vector>
12
13#include <exception>
14
15#include "percemon/ast/ast.hpp"
16
17namespace percemon::ast {
18
19struct SpArea {
20 SpatialExpr arg;
21 double scale = 1.0;
22
23 SpArea(SpatialExpr arg_, double scale_ = 1.0) : arg{std::move(arg_)}, scale{scale_} {}
24
25 SpArea& operator*=(const double rhs) {
26 this->scale *= rhs;
27 return *this;
28 };
29 friend SpArea operator*(const SpArea& lhs, const double rhs) {
30 return SpArea{lhs.arg, lhs.scale * rhs};
31 }
32 friend SpArea operator*(const double lhs, const SpArea& rhs) { return rhs * lhs; }
33};
34
36 SpArea lhs;
37 ComparisonOp op;
38 std::variant<double, SpArea> rhs;
39
40 CompareSpArea() = delete;
41 CompareSpArea(SpArea lhs_, ComparisonOp op_, std::variant<double, SpArea> rhs_) :
42 lhs{std::move(lhs_)}, op{op_}, rhs{std::move(rhs_)} {
43 if (op == ComparisonOp::EQ || op == ComparisonOp::NE) {
44 throw std::invalid_argument(
45 "Cannot use relational operators ==, != to compare SpArea(id)");
46 }
47 };
48};
49CompareSpArea operator>(const SpArea& lhs, const double rhs);
50CompareSpArea operator>=(const SpArea& lhs, const double rhs);
51CompareSpArea operator<(const SpArea& lhs, const double rhs);
52CompareSpArea operator<=(const SpArea& lhs, const double rhs);
53CompareSpArea operator>(const double lhs, const SpArea& rhs);
54CompareSpArea operator>=(const double lhs, const SpArea& rhs);
55CompareSpArea operator<(const double lhs, const SpArea& rhs);
56CompareSpArea operator<=(const double lhs, const SpArea& rhs);
57CompareSpArea operator>(const SpArea& lhs, const SpArea& rhs);
58CompareSpArea operator>=(const SpArea& lhs, const SpArea& rhs);
59CompareSpArea operator<(const SpArea& lhs, const SpArea& rhs);
60CompareSpArea operator<=(const SpArea& lhs, const SpArea& rhs);
61
62struct Complement {
63 SpatialExpr arg;
64 Complement() = delete;
65 Complement(SpatialExpr arg_) : arg{std::move(arg_)} {};
66};
67
68struct Intersect {
69 std::vector<SpatialExpr> args;
70 Intersect() = delete;
71 Intersect(const std::vector<SpatialExpr>& args_) : args{args_} {
72 if (args_.size() < 2) {
73 throw std::invalid_argument(
74 "It doesn't make sense to have an Intersect operator with < 2 operands");
75 }
76 };
77};
78
79struct Union {
80 std::vector<SpatialExpr> args;
81 Union() = delete;
82 Union(const std::vector<SpatialExpr>& args_) : args{args_} {
83 if (args_.size() < 2) {
84 throw std::invalid_argument(
85 "It doesn't make sense to have an Union operator with < 2 operands");
86 }
87 };
88};
89
90struct Interior {
91 SpatialExpr arg;
92 Interior() = delete;
93 Interior(SpatialExpr arg_) : arg{std::move(arg_)} {};
94};
95
96struct Closure {
97 SpatialExpr arg;
98 Closure() = delete;
99 Closure(SpatialExpr arg_) : arg{std::move(arg_)} {};
100};
101
102struct SpExists {
103 SpatialExpr arg;
104 SpExists() = delete;
105 SpExists(SpatialExpr arg_) : arg{std::move(arg_)} {};
106};
107
108struct SpForall {
109 SpatialExpr arg;
110 SpForall() = delete;
111 SpForall(SpatialExpr arg_) : arg{std::move(arg_)} {};
112};
113
115 SpatialExpr arg;
116
117 SpPrevious() = delete;
118 SpPrevious(SpatialExpr arg_) : arg{std::move(arg_)} {};
119};
120
121struct SpAlways {
122 std::optional<FrameInterval> interval = {};
123 SpatialExpr arg;
124
125 SpAlways() = delete;
126 SpAlways(SpatialExpr arg_) : arg{std::move(arg_)} {};
127 SpAlways(FrameInterval i, SpatialExpr arg_) : interval{i}, arg{std::move(arg_)} {};
128};
129
131 std::optional<FrameInterval> interval = {};
132 SpatialExpr arg;
133
134 SpSometimes() = delete;
135 SpSometimes(SpatialExpr arg_) : arg{std::move(arg_)} {};
136 SpSometimes(FrameInterval i, SpatialExpr arg_) : interval{i}, arg{std::move(arg_)} {};
137};
138
139struct SpSince {
140 std::optional<FrameInterval> interval = {};
141 std::pair<SpatialExpr, SpatialExpr> args;
142
143 SpSince() = delete;
144 SpSince(const SpatialExpr& arg0, const SpatialExpr& arg1) :
145 args{std::make_pair(arg0, arg1)} {};
146 SpSince(FrameInterval i, const SpatialExpr& arg0, const SpatialExpr& arg1) :
147 interval{i}, args{std::make_pair(arg0, arg1)} {};
148};
149
150struct SpBackTo {
151 std::optional<FrameInterval> interval = {};
152 std::pair<SpatialExpr, SpatialExpr> args;
153
154 SpBackTo() = delete;
155 SpBackTo(const SpatialExpr& arg0, const SpatialExpr& arg1) :
156 args{std::make_pair(arg0, arg1)} {};
157 SpBackTo(FrameInterval i, const SpatialExpr& arg0, const SpatialExpr& arg1) :
158 interval{i}, args{std::make_pair(arg0, arg1)} {};
159};
160
161} // namespace percemon::ast
162
163#endif /* end of include guard: __PERCEMON_S4U_HPP__ */
Definition: s4u.hpp:96
Definition: s4u.hpp:35
Definition: s4u.hpp:62
Definition: s4u.hpp:90
Definition: s4u.hpp:68
Definition: s4u.hpp:121
Definition: s4u.hpp:19
Definition: s4u.hpp:150
Definition: s4u.hpp:102
Definition: s4u.hpp:108
Definition: s4u.hpp:114
Definition: s4u.hpp:139
Definition: s4u.hpp:130
Definition: s4u.hpp:79
Definition: functions.hpp:36