summaryrefslogtreecommitdiffstats
path: root/src/optimize/RBAAbstractCollector.hpp
blob: a77db511d945c43890b9ff93d65636a0b5e7bb79 (plain)
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/**
 * Copyright (c) 2019 DENSO CORPORATION.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Abstract search class header file
 */

#ifndef RBAABSTRACTCOLLECTOR_HPP
#define RBAABSTRACTCOLLECTOR_HPP

#include <set>

#include "RBAExpressionVisitor.hpp"
#include "RBAExpression.hpp"

namespace rba
{
class RBAModelImpl;
class RBARuleObject;

class RBAAbstractCollector : public RBAExpressionVisitor
{
 public:
  RBAAbstractCollector(RBAModelImpl* const model);
  RBAAbstractCollector(const RBAAbstractCollector&)=default;
  RBAAbstractCollector(RBAAbstractCollector&&)=default;
  RBAAbstractCollector& operator=(const RBAAbstractCollector&)=default;
  RBAAbstractCollector& operator=(RBAAbstractCollector&&)=default;
  virtual ~RBAAbstractCollector()=default;

  // area status
  void visit(RBAIsDisplayed& exp) override;
  void visit(RBADisplayingContent& exp) override;
  void visit(RBAAllocatedContent& exp) override;
  void visit(RBAIsHidden& exp) override;
  void visit(RBAContentValue& exp) override;
  void visit(RBAGetContentsList& exp) override;
  void visit(RBAActiveContents& exp) override;

  // display content status
  void visit(RBAIsActive& exp) override;
  void visit(RBAIsVisible& exp) override;
  void visit(RBAStateValue& exp) override;
  void visit(RBAHasBeenDisplayed& exp) override;
  void visit(RBAHasComeEarlierThan& exp) override;
  void visit(RBAHasComeLaterThan& exp) override;
  void visit(RBAGetAllocatables& exp) override;
  void visit(RBAActiveState& exp) override;

  // zone status
  void visit(RBAIsOutputted& exp) override;
  void visit(RBAOutputtingSound& exp) override;
  // allocatedContent is common with area
  void visit(RBAIsMuted& exp) override;
  void visit(RBAIsAttenuated& exp) override;
  // contentValue is common with area
  // contentsList is common with area

  // sound content status
  // isActive is common with display content
  void visit(RBAIsSounding& exp) override;
  // stateValue is common with display content
  // hasComeEarlierThan is common with display content
  // hasComeLaterThan is common with display content
  // allocatables is common with display content
  // activeState is common with display content

  // scene
  void visit(RBAIsOn& exp) override;
  void visit(RBAGetProperty& exp) override;

  void visit(RBAIsTypeOfOperator& exp) override;

  // operator
  void visit(RBAAndOperator& exp) override;
  void visit(RBAOrOperator& exp) override;
  void visit(RBANotOperator& exp) override;
  void visit(RBAImpliesOperator& exp) override;
  void visit(RBAIsEqualToOperator& exp) override;
  void visit(RBAObjectCompare& exp) override;
  void visit(RBAIsGreaterThanOperator& exp) override;
  void visit(RBAIsGreaterThanEqualOperator& exp) override;
  void visit(RBAIsLowerThanOperator& exp) override;
  void visit(RBAIsLowerThanEqualOperator& exp) override;

  // Quantification symbol
  void visit(RBAForAllOperator& exp) override;
  void visit(RBAExistsOperator& exp) override;

  // Built-in definition expression
  void visit(RBAAllInstanceOfArea& exp) override;
  void visit(RBAAllInstanceOfViewContent& exp) override;
  void visit(RBAAllInstanceOfZone& exp) override;
  void visit(RBAAllInstanceOfSoundContent& exp) override;

  // statement
  void visit(RBAIfStatement& exp) override;
  void visit(RBALetStatement& exp) override;

  // modifier
  void visit(RBAPreviousModifier& exp) override;

  // operator
  void visit(RBAMaxOperator& exp) override;
  void visit(RBAMinOperator& exp) override;
  void visit(RBASelectOperator& exp) override;
  void visit(RBASizeOperator& exp) override;

  // object reference
  void visit(RBAObjectReference& exp) override;
  void visit(RBASetOfOperator& exp) override;

 protected:
  void visitLetStatement(RBAExpression& exp) ;

  // getter, setter
  std::set<const RBARuleObject*>& getLetVal();
  void addLetVal(const RBARuleObject* const obj);
  bool isVisitsLetStatement() const;
  bool isLhs() const;
  void setLhs(const bool lhs);
  bool isPositive() const;
  RBAModelImpl* getModel() const;
  bool isPreviousModifier() const;

 private:
  // Object that can be taken as the evaluation result of letStatement
  std::set<const RBARuleObject*> letVal_;
  // Model referenced in getReferenceObject()
  RBAModelImpl* model_;
  // True when searching the left side
  // Otherwise, false
  bool isLhs_;
  // true when in Expression under (pre)
  // Otherwise, false
  bool isPreviousModifier_;
  // True if not inverted with Not
  // False if inverted with Not
  bool isPositive_;
  // true when searching through letStatement
  // Otherwise, false
  bool visitsLetStatement_;
};

} /* namespace rba */

#endif /* RBAABSTRACTCOLLECTOR_HPP */