Coin  4.0.3
Coin3D core library
Loading...
Searching...
No Matches
ScXMLEvaluator.h
1#ifndef COIN_SCXMLEVALUATOR_H
2#define COIN_SCXMLEVALUATOR_H
3
4/**************************************************************************\
5 * Copyright (c) Kongsberg Oil & Gas Technologies AS
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * Neither the name of the copyright holder nor the names of its
20 * contributors may be used to endorse or promote products derived from
21 * this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34\**************************************************************************/
35
36#include <Inventor/scxml/ScXMLObject.h>
37#include <Inventor/tools/SbLazyPimplPtr.h>
38
39class ScXMLDocument;
41class ScXMLDataObj;
42
43
45 typedef ScXMLObject inherited;
46 SCXML_OBJECT_ABSTRACT_HEADER(ScXMLEvaluator)
47public:
48 static void initClass(void);
49 static void cleanClass(void);
50
51 ScXMLEvaluator(void);
52 virtual ~ScXMLEvaluator(void);
53
54 virtual void setStateMachine(ScXMLStateMachine * sm);
55 ScXMLStateMachine * getStateMachine(void) const { return this->statemachine; }
56
57 virtual ScXMLDataObj * evaluate(const char * expression) const = 0;
58
59 virtual SbBool setAtLocation(const char * location, ScXMLDataObj * obj) = 0;
60 virtual ScXMLDataObj * locate(const char * location) const = 0;
61
62 virtual void clearTemporaryVariables(void);
63
64protected:
65
66private:
67 ScXMLStateMachine * statemachine;
68
69 class PImpl;
71
72}; // ScXMLEvaluator
73
74
75// *************************************************************************
76
78 SCXML_OBJECT_ABSTRACT_HEADER(ScXMLDataObj)
79 typedef ScXMLObject inherited;
80public:
81 static void initClass(void);
82 static void cleanClass(void);
83
84 ScXMLDataObj(void);
85 virtual ~ScXMLDataObj(void);
86
87 void setContainer(ScXMLObject * container);
88 ScXMLObject * getContainer(void) const { return this->container; }
89
90private:
91 ScXMLObject * container;
92
93}; // ScXMLDataObj
94
96 SCXML_OBJECT_ABSTRACT_HEADER(ScXMLConstantDataObj)
97 typedef ScXMLDataObj inherited;
98public:
99 static void initClass(void);
100 static void cleanClass(void);
101
102 virtual ScXMLDataObj * clone(void) const = 0;
103 virtual void convertToString(SbString & str) const = 0;
104
105};
106
107
109 SCXML_OBJECT_HEADER(ScXMLStringDataObj)
111public:
112 static void initClass(void);
113 static void cleanClass(void);
114
115 static ScXMLDataObj * createFor(const char * value);
116
117 ScXMLStringDataObj(void);
118 ScXMLStringDataObj(const char * value);
119 virtual ~ScXMLStringDataObj(void);
120
121 void setString(const char * value);
122 const char * getString(void) const { return this->value; }
123
124 virtual ScXMLDataObj * clone(void) const;
125 virtual void convertToString(SbString & str) const;
126
127private:
128 char * value;
129
130};
131
132
134 SCXML_OBJECT_HEADER(ScXMLRealDataObj)
136public:
137 static void initClass(void);
138 static void cleanClass(void);
139
140 static ScXMLDataObj * createFor(double value);
141
142 ScXMLRealDataObj(void);
143 ScXMLRealDataObj(double value);
144 virtual ~ScXMLRealDataObj(void);
145
146 void setReal(double value);
147 double getReal(void) const { return this->value; }
148
149 virtual ScXMLDataObj * clone(void) const;
150 virtual void convertToString(SbString & str) const;
151
152private:
153 double value;
154
155};
156
157
159 SCXML_OBJECT_HEADER(ScXMLBoolDataObj)
161public:
162 static void initClass(void);
163 static void cleanClass(void);
164
165 static ScXMLDataObj * createFor(SbBool value);
166
167 ScXMLBoolDataObj(void);
168 ScXMLBoolDataObj(SbBool value);
169 virtual ~ScXMLBoolDataObj(void);
170
171 void setBool(SbBool value);
172 SbBool getBool(void) const { return this->value; }
173
174 virtual ScXMLDataObj * clone(void) const;
175 virtual void convertToString(SbString & str) const;
176
177private:
178 SbBool value;
179
180};
181
182
184 SCXML_OBJECT_HEADER(ScXMLSbDataObj)
186public:
187 static void initClass(void);
188 static void cleanClass(void);
189
190 static ScXMLDataObj * createFor(const char * value);
191
192 ScXMLSbDataObj(void);
193 ScXMLSbDataObj(const char * value);
194 virtual ~ScXMLSbDataObj(void);
195
196 void setSbValue(const char * value);
197 const char * getSbValue(void) const { return this->value; }
198
199 virtual ScXMLDataObj * clone(void) const;
200 virtual void convertToString(SbString & str) const;
201
202private:
203 char * value;
204
205};
206
207
209 SCXML_OBJECT_HEADER(ScXMLXMLDataObj)
210 typedef ScXMLDataObj inherited;
211public:
212 static void initClass(void);
213 static void cleanClass(void);
214
215 ScXMLXMLDataObj(void);
216 virtual ~ScXMLXMLDataObj(void);
217
218 virtual ScXMLDataObj * clone(void) const;
219
220};
221
222
224 SCXML_OBJECT_ABSTRACT_HEADER(ScXMLExprDataObj)
225 typedef ScXMLDataObj inherited;
226public:
227 static void initClass(void);
228 static void cleanClass(void);
229
230 ScXMLExprDataObj(void);
231 virtual ~ScXMLExprDataObj(void);
232
233 ScXMLDataObj * evaluate(ScXMLStateMachine * sm);
234
235protected:
236 virtual SbBool evaluateNow(ScXMLStateMachine * sm, ScXMLDataObj *& pointer) const = 0;
237
238private:
239 ScXMLDataObj * result;
240
241};
242
243
245 SCXML_OBJECT_HEADER(ScXMLReferenceDataObj)
247public:
248 static void initClass(void);
249 static void cleanClass(void);
250
251 static ScXMLDataObj * createFor(const char * reference);
252
254 ScXMLReferenceDataObj(const char * reference);
255 virtual ~ScXMLReferenceDataObj(void);
256
257 void setReference(const char * reference);
258 const char * getReference(void) const { return this->reference; }
259
260 virtual SbBool evaluateNow(ScXMLStateMachine * sm, ScXMLDataObj *& pointer) const;
261
262private:
263 char * reference;
264
265};
266
267
268// *************************************************************************
269// logical operators
270
272 SCXML_OBJECT_HEADER(ScXMLAndOpExprDataObj)
274public:
275 static void initClass(void);
276 static void cleanClass(void);
277
278 static ScXMLDataObj * createFor(ScXMLDataObj * lhs, ScXMLDataObj * rhs);
279
282 virtual ~ScXMLAndOpExprDataObj(void);
283
284 void setLHS(ScXMLDataObj * lhs);
285 const ScXMLDataObj * getLHS(void) const { return this->lhs; }
286 void setRHS(ScXMLDataObj * rhs);
287 const ScXMLDataObj * getRHS(void) const { return this->rhs; }
288
289protected:
290 virtual SbBool evaluateNow(ScXMLStateMachine * sm, ScXMLDataObj *& pointer) const;
291
292private:
293 ScXMLDataObj * lhs, * rhs;
294
295};
296
297
299 SCXML_OBJECT_HEADER(ScXMLOrOpExprDataObj)
301public:
302 static void initClass(void);
303 static void cleanClass(void);
304
305 static ScXMLDataObj * createFor(ScXMLDataObj * lhs, ScXMLDataObj * rhs);
306
309 virtual ~ScXMLOrOpExprDataObj(void);
310
311 void setLHS(ScXMLDataObj * lhs);
312 const ScXMLDataObj * getLHS(void) const { return this->lhs; }
313 void setRHS(ScXMLDataObj * rhs);
314 const ScXMLDataObj * getRHS(void) const { return this->rhs; }
315
316protected:
317 virtual SbBool evaluateNow(ScXMLStateMachine * sm, ScXMLDataObj *& pointer) const;
318
319private:
320 ScXMLDataObj * lhs, * rhs;
321
322};
323
324
326 SCXML_OBJECT_HEADER(ScXMLNotOpExprDataObj)
328public:
329 static void initClass(void);
330 static void cleanClass(void);
331
332 static ScXMLDataObj * createFor(ScXMLDataObj * rhs);
333
336 virtual ~ScXMLNotOpExprDataObj(void);
337
338 void setRHS(ScXMLDataObj * rhs);
339 const ScXMLDataObj * getRHS(void) const { return this->rhs; }
340
341protected:
342 virtual SbBool evaluateNow(ScXMLStateMachine * sm, ScXMLDataObj *& pointer) const;
343
344private:
345 ScXMLDataObj * rhs;
346
347};
348
349
351 SCXML_OBJECT_HEADER(ScXMLEqualsOpExprDataObj)
353public:
354 static void initClass(void);
355 static void cleanClass(void);
356
357 static ScXMLDataObj * createFor(ScXMLDataObj * lhs, ScXMLDataObj * rhs);
358
361 virtual ~ScXMLEqualsOpExprDataObj(void);
362
363 void setLHS(ScXMLDataObj * lhs);
364 const ScXMLDataObj * getLHS(void) const { return this->lhs; }
365 void setRHS(ScXMLDataObj * rhs);
366 const ScXMLDataObj * getRHS(void) const { return this->rhs; }
367
368protected:
369 virtual SbBool evaluateNow(ScXMLStateMachine * sm, ScXMLDataObj *& pointer) const;
370
371private:
372 ScXMLDataObj * lhs, * rhs;
373
374};
375
376
377// *************************************************************************
378// arithmetic operators
379
381 SCXML_OBJECT_HEADER(ScXMLAddOpExprDataObj)
383public:
384 static void initClass(void);
385 static void cleanClass(void);
386
387 static ScXMLDataObj * createFor(ScXMLDataObj * lhs, ScXMLDataObj * rhs);
388
391 virtual ~ScXMLAddOpExprDataObj(void);
392
393 void setLHS(ScXMLDataObj * lhs);
394 const ScXMLDataObj * getLHS(void) const { return this->lhs; }
395 void setRHS(ScXMLDataObj * rhs);
396 const ScXMLDataObj * getRHS(void) const { return this->rhs; }
397
398protected:
399 virtual SbBool evaluateNow(ScXMLStateMachine * sm, ScXMLDataObj *& pointer) const;
400
401private:
402 ScXMLDataObj * lhs, * rhs;
403
404};
405
406
408 SCXML_OBJECT_HEADER(ScXMLSubtractOpExprDataObj)
410public:
411 static void initClass(void);
412 static void cleanClass(void);
413
414 static ScXMLDataObj * createFor(ScXMLDataObj * lhs, ScXMLDataObj * rhs);
415
418 virtual ~ScXMLSubtractOpExprDataObj(void);
419
420 void setLHS(ScXMLDataObj * lhs);
421 const ScXMLDataObj * getLHS(void) const { return this->lhs; }
422 void setRHS(ScXMLDataObj * rhs);
423 const ScXMLDataObj * getRHS(void) const { return this->rhs; }
424
425protected:
426 virtual SbBool evaluateNow(ScXMLStateMachine * sm, ScXMLDataObj *& pointer) const;
427
428private:
429 ScXMLDataObj * lhs, * rhs;
430
431};
432
433
435 SCXML_OBJECT_HEADER(ScXMLMultiplyOpExprDataObj)
437public:
438 static void initClass(void);
439 static void cleanClass(void);
440
441 static ScXMLDataObj * createFor(ScXMLDataObj * lhs, ScXMLDataObj * rhs);
442
445 virtual ~ScXMLMultiplyOpExprDataObj(void);
446
447 void setLHS(ScXMLDataObj * lhs);
448 const ScXMLDataObj * getLHS(void) const { return this->lhs; }
449 void setRHS(ScXMLDataObj * rhs);
450 const ScXMLDataObj * getRHS(void) const { return this->rhs; }
451
452protected:
453 virtual SbBool evaluateNow(ScXMLStateMachine * sm, ScXMLDataObj *& pointer) const;
454
455private:
456 ScXMLDataObj * lhs, * rhs;
457
458};
459
460
462 SCXML_OBJECT_HEADER(ScXMLDivideOpExprDataObj)
464public:
465 static void initClass(void);
466 static void cleanClass(void);
467
468 static ScXMLDataObj * createFor(ScXMLDataObj * lhs, ScXMLDataObj * rhs);
469
472 virtual ~ScXMLDivideOpExprDataObj(void);
473
474 void setLHS(ScXMLDataObj * lhs);
475 const ScXMLDataObj * getLHS(void) const { return this->lhs; }
476 void setRHS(ScXMLDataObj * rhs);
477 const ScXMLDataObj * getRHS(void) const { return this->rhs; }
478
479protected:
480 virtual SbBool evaluateNow(ScXMLStateMachine * sm, ScXMLDataObj *& pointer) const;
481
482private:
483 ScXMLDataObj * lhs, * rhs;
484
485};
486
487
489 SCXML_OBJECT_HEADER(ScXMLNegateOpExprDataObj)
491public:
492 static void initClass(void);
493 static void cleanClass(void);
494
495 static ScXMLDataObj * createFor(ScXMLDataObj * rhs);
496
499 virtual ~ScXMLNegateOpExprDataObj(void);
500
501 void setRHS(ScXMLDataObj * rhs);
502 const ScXMLDataObj * getRHS(void) const { return this->rhs; }
503
504protected:
505 virtual SbBool evaluateNow(ScXMLStateMachine * sm, ScXMLDataObj *& pointer) const;
506
507private:
508 ScXMLDataObj * rhs;
509
510};
511
512
513#endif // !COIN_SCXMLEVALUATOR_H
The SbList class is a template container class for lists.
Definition SbList.h:70
The SbString class is a string class with convenience functions for string operations.
Definition SbString.h:52
Definition ScXMLEvaluator.h:380
Implements the logical AND operator.
Definition ScXMLEvaluator.h:271
Definition ScXMLEvaluator.h:158
base class for immediate data values
Definition ScXMLEvaluator.h:95
base class for evaluator data objects in the SCXML data module
Definition ScXMLEvaluator.h:77
Definition ScXMLEvaluator.h:461
Definition ScXMLDocument.h:47
Definition ScXMLEvaluator.h:350
defines an interface for profile-dependent evaluators.
Definition ScXMLEvaluator.h:44
Definition ScXMLEvaluator.h:223
Definition ScXMLEvaluator.h:434
Definition ScXMLEvaluator.h:488
Definition ScXMLEvaluator.h:325
Base class for all SCXML objects.
Definition ScXMLObject.h:41
Definition ScXMLEvaluator.h:298
Definition ScXMLEvaluator.h:133
A data object representing a reference to another object in the data model.
Definition ScXMLEvaluator.h:244
Definition ScXMLEvaluator.h:183
Manager for processing events and setting states in SCXML structures.
Definition ScXMLStateMachine.h:61
Definition ScXMLEvaluator.h:108
Definition ScXMLEvaluator.h:407
Definition ScXMLEvaluator.h:208