Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
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 
39 class ScXMLDocument;
40 class ScXMLStateMachine;
41 class ScXMLDataObj;
42 
43 
44 class COIN_DLL_API ScXMLEvaluator : public ScXMLObject {
45  typedef ScXMLObject inherited;
46  SCXML_OBJECT_ABSTRACT_HEADER(ScXMLEvaluator)
47 public:
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 
64 protected:
65 
66 private:
67  ScXMLStateMachine * statemachine;
68 
69  class PImpl;
71 
72 }; // ScXMLEvaluator
73 
74 
75 // *************************************************************************
76 
77 class COIN_DLL_API ScXMLDataObj : public ScXMLObject {
78  SCXML_OBJECT_ABSTRACT_HEADER(ScXMLDataObj)
79  typedef ScXMLObject inherited;
80 public:
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 
90 private:
91  ScXMLObject * container;
92 
93 }; // ScXMLDataObj
94 
95 class COIN_DLL_API ScXMLConstantDataObj : public ScXMLDataObj {
96  SCXML_OBJECT_ABSTRACT_HEADER(ScXMLConstantDataObj)
97  typedef ScXMLDataObj inherited;
98 public:
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 
108 class COIN_DLL_API ScXMLStringDataObj : public ScXMLConstantDataObj {
109  SCXML_OBJECT_HEADER(ScXMLStringDataObj)
111 public:
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 
127 private:
128  char * value;
129 
130 };
131 
132 
133 class COIN_DLL_API ScXMLRealDataObj : public ScXMLConstantDataObj {
134  SCXML_OBJECT_HEADER(ScXMLRealDataObj)
136 public:
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 
152 private:
153  double value;
154 
155 };
156 
157 
158 class COIN_DLL_API ScXMLBoolDataObj : public ScXMLConstantDataObj {
159  SCXML_OBJECT_HEADER(ScXMLBoolDataObj)
161 public:
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 
177 private:
178  SbBool value;
179 
180 };
181 
182 
183 class COIN_DLL_API ScXMLSbDataObj : public ScXMLConstantDataObj {
184  SCXML_OBJECT_HEADER(ScXMLSbDataObj)
186 public:
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 
202 private:
203  char * value;
204 
205 };
206 
207 
208 class COIN_DLL_API ScXMLXMLDataObj : public ScXMLDataObj {
209  SCXML_OBJECT_HEADER(ScXMLXMLDataObj)
210  typedef ScXMLDataObj inherited;
211 public:
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 
223 class COIN_DLL_API ScXMLExprDataObj : public ScXMLDataObj {
224  SCXML_OBJECT_ABSTRACT_HEADER(ScXMLExprDataObj)
225  typedef ScXMLDataObj inherited;
226 public:
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 
235 protected:
236  virtual SbBool evaluateNow(ScXMLStateMachine * sm, ScXMLDataObj *& pointer) const = 0;
237 
238 private:
239  ScXMLDataObj * result;
240 
241 };
242 
243 
244 class COIN_DLL_API ScXMLReferenceDataObj : public ScXMLExprDataObj {
245  SCXML_OBJECT_HEADER(ScXMLReferenceDataObj)
246  typedef ScXMLExprDataObj inherited;
247 public:
248  static void initClass(void);
249  static void cleanClass(void);
250 
251  static ScXMLDataObj * createFor(const char * reference);
252 
253  ScXMLReferenceDataObj(void);
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 
262 private:
263  char * reference;
264 
265 };
266 
267 
268 // *************************************************************************
269 // logical operators
270 
271 class COIN_DLL_API ScXMLAndOpExprDataObj : public ScXMLExprDataObj {
272  SCXML_OBJECT_HEADER(ScXMLAndOpExprDataObj)
273  typedef ScXMLExprDataObj inherited;
274 public:
275  static void initClass(void);
276  static void cleanClass(void);
277 
278  static ScXMLDataObj * createFor(ScXMLDataObj * lhs, ScXMLDataObj * rhs);
279 
280  ScXMLAndOpExprDataObj(void);
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 
289 protected:
290  virtual SbBool evaluateNow(ScXMLStateMachine * sm, ScXMLDataObj *& pointer) const;
291 
292 private:
293  ScXMLDataObj * lhs, * rhs;
294 
295 };
296 
297 
298 class COIN_DLL_API ScXMLOrOpExprDataObj : public ScXMLExprDataObj {
299  SCXML_OBJECT_HEADER(ScXMLOrOpExprDataObj)
300  typedef ScXMLExprDataObj inherited;
301 public:
302  static void initClass(void);
303  static void cleanClass(void);
304 
305  static ScXMLDataObj * createFor(ScXMLDataObj * lhs, ScXMLDataObj * rhs);
306 
307  ScXMLOrOpExprDataObj(void);
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 
316 protected:
317  virtual SbBool evaluateNow(ScXMLStateMachine * sm, ScXMLDataObj *& pointer) const;
318 
319 private:
320  ScXMLDataObj * lhs, * rhs;
321 
322 };
323 
324 
325 class COIN_DLL_API ScXMLNotOpExprDataObj : public ScXMLExprDataObj {
326  SCXML_OBJECT_HEADER(ScXMLNotOpExprDataObj)
327  typedef ScXMLExprDataObj inherited;
328 public:
329  static void initClass(void);
330  static void cleanClass(void);
331 
332  static ScXMLDataObj * createFor(ScXMLDataObj * rhs);
333 
334  ScXMLNotOpExprDataObj(void);
336  virtual ~ScXMLNotOpExprDataObj(void);
337 
338  void setRHS(ScXMLDataObj * rhs);
339  const ScXMLDataObj * getRHS(void) const { return this->rhs; }
340 
341 protected:
342  virtual SbBool evaluateNow(ScXMLStateMachine * sm, ScXMLDataObj *& pointer) const;
343 
344 private:
345  ScXMLDataObj * rhs;
346 
347 };
348 
349 
350 class COIN_DLL_API ScXMLEqualsOpExprDataObj : public ScXMLExprDataObj {
351  SCXML_OBJECT_HEADER(ScXMLEqualsOpExprDataObj)
352  typedef ScXMLExprDataObj inherited;
353 public:
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 
368 protected:
369  virtual SbBool evaluateNow(ScXMLStateMachine * sm, ScXMLDataObj *& pointer) const;
370 
371 private:
372  ScXMLDataObj * lhs, * rhs;
373 
374 };
375 
376 
377 // *************************************************************************
378 // arithmetic operators
379 
380 class COIN_DLL_API ScXMLAddOpExprDataObj : public ScXMLExprDataObj {
381  SCXML_OBJECT_HEADER(ScXMLAddOpExprDataObj)
382  typedef ScXMLExprDataObj inherited;
383 public:
384  static void initClass(void);
385  static void cleanClass(void);
386 
387  static ScXMLDataObj * createFor(ScXMLDataObj * lhs, ScXMLDataObj * rhs);
388 
389  ScXMLAddOpExprDataObj(void);
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 
398 protected:
399  virtual SbBool evaluateNow(ScXMLStateMachine * sm, ScXMLDataObj *& pointer) const;
400 
401 private:
402  ScXMLDataObj * lhs, * rhs;
403 
404 };
405 
406 
407 class COIN_DLL_API ScXMLSubtractOpExprDataObj : public ScXMLExprDataObj {
408  SCXML_OBJECT_HEADER(ScXMLSubtractOpExprDataObj)
409  typedef ScXMLExprDataObj inherited;
410 public:
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 
425 protected:
426  virtual SbBool evaluateNow(ScXMLStateMachine * sm, ScXMLDataObj *& pointer) const;
427 
428 private:
429  ScXMLDataObj * lhs, * rhs;
430 
431 };
432 
433 
434 class COIN_DLL_API ScXMLMultiplyOpExprDataObj : public ScXMLExprDataObj {
435  SCXML_OBJECT_HEADER(ScXMLMultiplyOpExprDataObj)
436  typedef ScXMLExprDataObj inherited;
437 public:
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 
452 protected:
453  virtual SbBool evaluateNow(ScXMLStateMachine * sm, ScXMLDataObj *& pointer) const;
454 
455 private:
456  ScXMLDataObj * lhs, * rhs;
457 
458 };
459 
460 
461 class COIN_DLL_API ScXMLDivideOpExprDataObj : public ScXMLExprDataObj {
462  SCXML_OBJECT_HEADER(ScXMLDivideOpExprDataObj)
463  typedef ScXMLExprDataObj inherited;
464 public:
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 
479 protected:
480  virtual SbBool evaluateNow(ScXMLStateMachine * sm, ScXMLDataObj *& pointer) const;
481 
482 private:
483  ScXMLDataObj * lhs, * rhs;
484 
485 };
486 
487 
488 class COIN_DLL_API ScXMLNegateOpExprDataObj : public ScXMLExprDataObj {
489  SCXML_OBJECT_HEADER(ScXMLNegateOpExprDataObj)
490  typedef ScXMLExprDataObj inherited;
491 public:
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 
504 protected:
505  virtual SbBool evaluateNow(ScXMLStateMachine * sm, ScXMLDataObj *& pointer) const;
506 
507 private:
508  ScXMLDataObj * rhs;
509 
510 };
511 
512 
513 #endif // !COIN_SCXMLEVALUATOR_H
base class for immediate data values
Definition: ScXMLEvaluator.h:95
Definition: ScXMLEvaluator.h:208
Definition: ScXMLEvaluator.h:158
Definition: ScXMLEvaluator.h:434
base class for evaluator data objects in the SCXML data module
Definition: ScXMLEvaluator.h:77
Definition: ScXMLEvaluator.h:380
Definition: ScXMLEvaluator.h:108
Definition: ScXMLEvaluator.h:183
defines an interface for profile-dependent evaluators.
Definition: ScXMLEvaluator.h:44
Definition: ScXMLEvaluator.h:350
Definition: ScXMLEvaluator.h:488
Implements the logical AND operator.
Definition: ScXMLEvaluator.h:271
Definition: ScXMLEvaluator.h:461
Definition: ScXMLEvaluator.h:325
Definition: ScXMLEvaluator.h:298
static void initClass(void)
Sets up initialization for data common to all instances of this class, like submitting necessary info...
Definition: ScXMLObject.cpp:102
Definition: ScXMLEvaluator.h:223
Definition: ScXMLEvaluator.h:407
Definition: ScXMLDocument.h:47
static void cleanClass(void)
Does the opposite of initClass, deallocates any class specific resources and resets the class to an u...
Definition: ScXMLObject.cpp:115
A data object representing a reference to another object in the data model.
Definition: ScXMLEvaluator.h:244
Base class for all SCXML objects.
Definition: ScXMLObject.h:41
The SbString class is a string class with convenience functions for string operations.
Definition: SbString.h:52
Definition: ScXMLEvaluator.h:133
Manager for processing events and setting states in SCXML structures.
Definition: ScXMLStateMachine.h:61