Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
ScXMLStateMachine.h
Go to the documentation of this file.
1 #ifndef COIN_SCXMLSTATEMACHINE_H
2 #define COIN_SCXMLSTATEMACHINE_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/ScXMLEventTarget.h>
37 
38 #include <Inventor/SbName.h>
39 #include <Inventor/lists/SbList.h>
40 
41 class ScXMLEvent;
42 class ScXMLDocument;
43 class ScXMLStateMachine;
44 class ScXMLEvaluator;
45 class ScXMLElt;
46 
47 typedef void ScXMLStateMachineDeleteCB(void * userdata,
48  ScXMLStateMachine * statemachine);
49 typedef void ScXMLStateChangeCB(void * userdata,
50  ScXMLStateMachine * statemachine,
51  const char * stateidentifier,
52  SbBool enterstate,
53  SbBool success);
54 typedef void ScXMLParallelStateChangeCB(void * userdata,
55  ScXMLStateMachine * statemachine,
56  int numstates,
57  const char ** stateidentifiers,
58  SbBool enterstate,
59  SbBool success);
60 
61 class COIN_DLL_API ScXMLStateMachine : public ScXMLEventTarget {
63  SCXML_OBJECT_HEADER(ScXMLStateMachine)
64 
65 public:
66  static void initClass(void);
67  static void cleanClass(void);
68 
69  ScXMLStateMachine(void);
70  virtual ~ScXMLStateMachine(void);
71 
72  virtual void setName(const SbName & name);
73  const SbName & getName(void) const;
74 
75  virtual void setDescription(ScXMLDocument * document);
76  const ScXMLDocument * getDescription(void) const;
77 
78  virtual void setSessionId(const SbName & sessionid);
79  const SbName & getSessionId(void) const;
80 
81  virtual void initialize(void);
82 
83  virtual SbBool isActive(void) const;
84  virtual SbBool isFinished(void) const;
85 
86  virtual int getNumActiveStates(void) const;
87  virtual const ScXMLElt * getActiveState(int idx) const;
88 
89  virtual void addDeleteCallback(ScXMLStateMachineDeleteCB * callback,
90  void * userdata);
91  virtual void removeDeleteCallback(ScXMLStateMachineDeleteCB * callback,
92  void * userdata);
93 
94  virtual void addStateChangeCallback(ScXMLStateChangeCB * callback,
95  void * userdata);
96  virtual void removeStateChangeCallback(ScXMLStateChangeCB * callback,
97  void * userdata);
98 
99  virtual void setVariable(const char * name, const char * value);
100  virtual const char * getVariable(const char * name) const;
101 
102  static ScXMLStateMachine * getStateMachineForSessionId(const SbName & sessionid);
103 
104  virtual void setLogLevel(int loglevel);
105  int getLogLevel(void) const;
106 
107  virtual void setEvaluator(ScXMLEvaluator * evaluator);
108  ScXMLEvaluator * getEvaluator(void) const;
109 
110  SbBool isModuleEnabled(const char * modulename) const;
111  int getNumEnabledModules(void) const;
112  const char * getEnabledModuleName(int idx) const;
113  void setEnabledModulesList(const SbList<const char *> & modulenames);
114 
115 protected:
116  virtual SbBool processOneEvent(const ScXMLEvent * event);
117 
118 private:
119  ScXMLStateMachine(const ScXMLStateMachine & rhs); // N/A
120  ScXMLStateMachine & operator = (const ScXMLStateMachine & rhs); // N/A
121 
122  class PImpl;
123  SbPimplPtr<PImpl> pimpl;
124 
125 }; // ScXMLStateMachine
126 
127 #endif // !COIN_SCXMLSTATEMACHINE_H
virtual SbBool processOneEvent(const ScXMLEvent *event)
Definition: ScXMLEventTarget.cpp:582
void ScXMLStateChangeCB(void *userdata, ScXMLStateMachine *statemachine, const char *stateidentifier, SbBool enterstate, SbBool success)
Definition: ScXMLStateMachine.h:49
void ScXMLParallelStateChangeCB(void *userdata, ScXMLStateMachine *statemachine, int numstates, const char **stateidentifiers, SbBool enterstate, SbBool success)
Definition: ScXMLStateMachine.h:54
The SbList class is a template container class for lists.
Definition: SoType.h:55
defines an interface for profile-dependent evaluators.
Definition: ScXMLEvaluator.h:44
void ScXMLStateMachineDeleteCB(void *userdata, ScXMLStateMachine *statemachine)
Definition: ScXMLStateMachine.h:47
base class for all SCXML elements.
Definition: ScXMLElt.h:44
Base class for events sent to SCXML state machines.
Definition: ScXMLEvent.h:40
Definition: ScXMLDocument.h:47
Base class for all SCXML objects.
Definition: ScXMLObject.h:41
base class for event targets for inter-system event communication
Definition: ScXMLEventTarget.h:43
The SbName class stores strings by reference.
Definition: SbName.h:40
Manager for processing events and setting states in SCXML structures.
Definition: ScXMLStateMachine.h:61