Choreonoid  1.8
MprBasicStatements.h
Go to the documentation of this file.
1 #ifndef CNOID_MANIPULATOR_PLUGIN_MPR_BASIC_STATEMENTS_H
2 #define CNOID_MANIPULATOR_PLUGIN_MPR_BASIC_STATEMENTS_H
3 
4 #include "MprStatement.h"
6 #include <cnoid/GeneralId>
7 #include "exportdecl.h"
8 
9 namespace cnoid {
10 
11 class MprPositionList;
12 
13 class CNOID_EXPORT MprEmptyStatement : public MprStatement
14 {
15 public:
17  virtual std::string label(int index) const override;
18  virtual bool read(MprProgram* program, const Mapping& archive) override;
19  virtual bool write(Mapping& archive) const override;
20 
21 protected:
23  virtual Referenced* doClone(CloneMap* cloneMap) const override;
24 };
25 
27 
28 
29 class CNOID_EXPORT MprDummyStatement : public MprEmptyStatement
30 {
31 public:
33  virtual std::string label(int index) const override;
34  virtual bool write(Mapping& archive) const override;
35 
36 protected:
38  virtual Referenced* doClone(CloneMap* cloneMap) const override;
39 };
40 
42 
43 
44 class CNOID_EXPORT MprCommentStatement : public MprStatement
45 {
46 public:
48  virtual std::string label(int index) const override;
49 
50  void setComment(const std::string& comment){ comment_ = comment; }
51  const std::string& comment() const { return comment_; }
52 
53  virtual bool read(MprProgram* program, const Mapping& archive) override;
54  virtual bool write(Mapping& archive) const override;
55 
56 protected:
58  virtual Referenced* doClone(CloneMap* cloneMap) const override;
59 
60 private:
61  std::string comment_;
62 };
63 
65 
66 
67 class CNOID_EXPORT MprGroupStatement : public MprStructuredStatement
68 {
69 public:
71  virtual std::string label(int index) const override;
72 
73  const std::string& groupName() const { return groupName_; }
74  void setGroupName(const std::string& name) { groupName_ = name; }
75 
76  virtual bool read(MprProgram* program, const Mapping& archive) override;
77  virtual bool write(Mapping& archive) const override;
78 
79 protected:
80  MprGroupStatement(const MprGroupStatement& org, CloneMap* cloneMap);
81  virtual Referenced* doClone(CloneMap* cloneMap) const override;
82 
83 private:
84  std::string groupName_;
85 };
86 
88 
89 
90 class CNOID_EXPORT MprConditionStatement : public MprStructuredStatement
91 {
92 public:
93  const std::string condition() const { return condition_; }
94  void setCondition(const std::string& condition) { condition_ = condition; }
95 
96  virtual bool read(MprProgram* program, const Mapping& archive) override;
97  virtual bool write(Mapping& archive) const override;
98 
99 protected:
102 
103 private:
104  std::string condition_;
105 };
106 
108 
109 
110 class CNOID_EXPORT MprIfStatement : public MprConditionStatement
111 {
112 public:
113  MprIfStatement();
114  virtual std::string label(int index) const override;
115 
116  virtual bool read(MprProgram* program, const Mapping& archive) override;
117  virtual bool write(Mapping& archive) const override;
118 
119 protected:
120  MprIfStatement(const MprIfStatement& org, CloneMap* cloneMap);
121  virtual Referenced* doClone(CloneMap* cloneMap) const override;
122 };
123 
125 
126 
127 class CNOID_EXPORT MprElseStatement : public MprStructuredStatement
128 {
129 public:
131  virtual std::string label(int index) const override;
132 
133  virtual bool read(MprProgram* program, const Mapping& archive) override;
134  virtual bool write(Mapping& archive) const override;
135 
136 protected:
137  MprElseStatement(const MprElseStatement& org, CloneMap* cloneMap);
138  virtual Referenced* doClone(CloneMap* cloneMap) const override;
139 };
140 
142 
143 
144 class CNOID_EXPORT MprWhileStatement : public MprConditionStatement
145 {
146 public:
148  virtual std::string label(int index) const override;
149 
150  virtual bool read(MprProgram* program, const Mapping& archive) override;
151  virtual bool write(Mapping& archive) const override;
152 
153 protected:
154  MprWhileStatement(const MprWhileStatement& org, CloneMap* cloneMap);
155  virtual Referenced* doClone(CloneMap* cloneMap) const override;
156 };
157 
159 
160 
161 class CNOID_EXPORT MprCallStatement : public MprStatement
162 {
163 public:
165  virtual std::string label(int index) const override;
166 
167  const std::string& programName() const { return programName_; }
168  void setProgramName(const std::string& name) { programName_ = name; }
169 
170  virtual bool read(MprProgram* program, const Mapping& archive) override;
171  virtual bool write(Mapping& archive) const override;
172 
173 protected:
175  virtual Referenced* doClone(CloneMap* cloneMap) const override;
176 
177 private:
193  std::string programName_;
194 };
195 
197 
198 
199 class MprVariable;
200 class MprVariableSet;
201 
202 class CNOID_EXPORT MprAssignStatement : public MprStatement
203 {
204 public:
206 
207  virtual std::string label(int index) const override;
208 
209  const std::string variableExpression() const { return variableExpression_; }
210  void setVariableExpression(const std::string& expression) { variableExpression_ = expression; }
211 
212  const std::string valueExpression() const { return valueExpression_; }
213  void setValueExpression(const std::string& expression) { valueExpression_ = expression; }
214 
215  virtual bool read(MprProgram* program, const Mapping& archive) override;
216  virtual bool write(Mapping& archive) const override;
217 
218 protected:
220  virtual Referenced* doClone(CloneMap* cloneMap) const override;
221 
222 private:
223  std::string variableExpression_;
224  std::string valueExpression_;
225 };
226 
228 
229 
230 class CNOID_EXPORT MprSignalStatement : public MprStatement
231 {
232 public:
234  virtual std::string label(int index) const override;
235 
236  int signalIndex() const { return signalIndex_; }
237  void setSignalIndex(int index){ signalIndex_ = index; }
238 
239  bool on() const { return on_; }
240  void on(bool on){ on_ = on; }
241 
242  virtual bool read(MprProgram* program, const Mapping& archive) override;
243  virtual bool write(Mapping& archive) const override;
244 
245 protected:
247  virtual Referenced* doClone(CloneMap* cloneMap) const override;
248 
249 private:
250  int signalIndex_;
251  bool on_;
252 
253 };
254 
256 
257 
258 class CNOID_EXPORT MprWaitStatement : public MprStatement
259 {
260 public:
262  virtual std::string label(int index) const override;
263 
264  enum ConditionType { SignalInput };
265 
266  int conditionType() const { return conditionType_; }
267  void setConditionType(int type) { conditionType_ = type; }
268 
269  int signalIndex() const { return signalIndex_; }
270  void setSignalIndex(int index) { signalIndex_ = index; }
271  bool signalStateCondition() const { return signalStateCondition_; }
272  void setSignalStateCondition(bool state) { signalStateCondition_ = state; }
273 
274  virtual bool read(MprProgram* program, const Mapping& archive) override;
275  virtual bool write(Mapping& archive) const override;
276 
277 protected:
279  virtual Referenced* doClone(CloneMap* cloneMap) const override;
280 
281 private:
282  int conditionType_;
283  int signalIndex_;
284  bool signalStateCondition_;
285 };
286 
288 
289 
290 class CNOID_EXPORT MprDelayStatement : public MprStatement
291 {
292 public:
294 
295  virtual std::string label(int index) const override;
296 
297  double time() const { return time_; }
298  void setTime(double t){ time_ = t; }
299 
300  virtual bool read(MprProgram* program, const Mapping& archive) override;
301  virtual bool write(Mapping& archive) const override;
302 
303 protected:
305  virtual Referenced* doClone(CloneMap* cloneMap) const override;
306 
307 private:
308  double time_;
309 };
310 
312 
313 }
314 
315 #endif
cnoid::MprVariable
Definition: MprVariable.h:15
cnoid::Mapping
Definition: ValueTree.h:253
cnoid::MprStructuredStatement
Definition: MprStructuredStatement.h:10
cnoid::MprCallStatement
Definition: MprBasicStatements.h:161
cnoid::MprWaitStatement::setConditionType
void setConditionType(int type)
Definition: MprBasicStatements.h:267
cnoid::write
Listing * write(Mapping *mapping, const std::string &key, const Eigen::MatrixBase< Derived > &x)
Definition: EigenArchive.h:145
cnoid::MprAssignStatement::valueExpression
const std::string valueExpression() const
Definition: MprBasicStatements.h:212
cnoid::MprCommentStatement::setComment
void setComment(const std::string &comment)
Definition: MprBasicStatements.h:50
cnoid::MprAssignStatement::variableExpression
const std::string variableExpression() const
Definition: MprBasicStatements.h:209
cnoid::MprCallStatement::programName
const std::string & programName() const
Definition: MprBasicStatements.h:167
cnoid::MprWaitStatement::signalIndex
int signalIndex() const
Definition: MprBasicStatements.h:269
cnoid::MprCallStatementPtr
ref_ptr< MprCallStatement > MprCallStatementPtr
Definition: MprBasicStatements.h:196
cnoid::MprElseStatement
Definition: MprBasicStatements.h:127
cnoid::MprEmptyStatementPtr
ref_ptr< MprEmptyStatement > MprEmptyStatementPtr
Definition: MprBasicStatements.h:26
cnoid::MprDelayStatement
Definition: MprBasicStatements.h:290
cnoid::MprGroupStatement
Definition: MprBasicStatements.h:67
cnoid::MprWaitStatement::conditionType
int conditionType() const
Definition: MprBasicStatements.h:266
cnoid::read
bool read(const Mapping *mapping, const std::string &key, Eigen::MatrixBase< Derived > &x)
Definition: EigenArchive.h:43
cnoid::MprSignalStatement
Definition: MprBasicStatements.h:230
cnoid::MprGroupStatement::groupName
const std::string & groupName() const
Definition: MprBasicStatements.h:73
cnoid::MprDummyStatementPtr
ref_ptr< MprDummyStatement > MprDummyStatementPtr
Definition: MprBasicStatements.h:41
cnoid::MprCommentStatement
Definition: MprBasicStatements.h:44
MprStructuredStatement.h
cnoid::ref_ptr
Definition: Referenced.h:103
cnoid::MprCommentStatement::comment
const std::string & comment() const
Definition: MprBasicStatements.h:51
cnoid::MprSignalStatementPtr
ref_ptr< MprSignalStatement > MprSignalStatementPtr
Definition: MprBasicStatements.h:255
cnoid::MprWaitStatement::setSignalStateCondition
void setSignalStateCondition(bool state)
Definition: MprBasicStatements.h:272
cnoid::MprGroupStatementPtr
ref_ptr< MprGroupStatement > MprGroupStatementPtr
Definition: MprBasicStatements.h:87
cnoid::MprCallStatement::setProgramName
void setProgramName(const std::string &name)
Definition: MprBasicStatements.h:168
cnoid::MprGroupStatement::setGroupName
void setGroupName(const std::string &name)
Definition: MprBasicStatements.h:74
cnoid::MprSignalStatement::signalIndex
int signalIndex() const
Definition: MprBasicStatements.h:236
cnoid::MprCommentStatementPtr
ref_ptr< MprCommentStatement > MprCommentStatementPtr
Definition: MprBasicStatements.h:64
cnoid::MprDelayStatement::time
double time() const
Definition: MprBasicStatements.h:297
cnoid::MprWhileStatement
Definition: MprBasicStatements.h:144
cnoid::MprIfStatement
Definition: MprBasicStatements.h:110
cnoid::MprConditionStatement::setCondition
void setCondition(const std::string &condition)
Definition: MprBasicStatements.h:94
cnoid::MprWaitStatement::ConditionType
ConditionType
Definition: MprBasicStatements.h:264
cnoid::MprWaitStatementPtr
ref_ptr< MprWaitStatement > MprWaitStatementPtr
Definition: MprBasicStatements.h:287
cnoid::MprDelayStatementPtr
ref_ptr< MprDelayStatement > MprDelayStatementPtr
Definition: MprBasicStatements.h:311
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::MprAssignStatement
Definition: MprBasicStatements.h:202
cnoid::CloneMap
Definition: CloneMap.h:13
cnoid::MprConditionStatementPtr
ref_ptr< MprConditionStatement > MprConditionStatementPtr
Definition: MprBasicStatements.h:107
cnoid::MprStatement
Definition: MprStatement.h:16
cnoid::MprConditionStatement::condition
const std::string condition() const
Definition: MprBasicStatements.h:93
cnoid::MprIfStatementPtr
ref_ptr< MprIfStatement > MprIfStatementPtr
Definition: MprBasicStatements.h:124
cnoid::MprConditionStatement
Definition: MprBasicStatements.h:90
cnoid::MprAssignStatement::setVariableExpression
void setVariableExpression(const std::string &expression)
Definition: MprBasicStatements.h:210
cnoid::Referenced
Definition: Referenced.h:54
cnoid::MprSignalStatement::setSignalIndex
void setSignalIndex(int index)
Definition: MprBasicStatements.h:237
cnoid::MprAssignStatementPtr
ref_ptr< MprAssignStatement > MprAssignStatementPtr
Definition: MprBasicStatements.h:227
cnoid::MprProgram
Definition: MprProgram.h:21
cnoid::MprDelayStatement::setTime
void setTime(double t)
Definition: MprBasicStatements.h:298
cnoid::MprDummyStatement
Definition: MprBasicStatements.h:29
cnoid::MprWaitStatement::signalStateCondition
bool signalStateCondition() const
Definition: MprBasicStatements.h:271
cnoid::MprEmptyStatement
Definition: MprBasicStatements.h:13
MprStatement.h
cnoid::MprWaitStatement::setSignalIndex
void setSignalIndex(int index)
Definition: MprBasicStatements.h:270
cnoid::MprSignalStatement::on
bool on() const
Definition: MprBasicStatements.h:239
cnoid::MprSignalStatement::on
void on(bool on)
Definition: MprBasicStatements.h:240
cnoid::MprAssignStatement::setValueExpression
void setValueExpression(const std::string &expression)
Definition: MprBasicStatements.h:213
cnoid::MprWaitStatement
Definition: MprBasicStatements.h:258