KWWidgets
debian/tmp/usr/include/KWWidgets/vtkKWStateMachineTransition.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: $RCSfile: vtkKWStateMachineTransition.h,v $
4 
5  Copyright (c) Kitware, Inc.
6  All rights reserved.
7  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
14 // .NAME vtkKWStateMachineTransition - a state machine transition.
15 // .SECTION Description
16 // This class is the basis for a state machine transition.
17 // A state machine is defined by a set of states, a set of inputs and a
18 // transition matrix that defines for each pair of (state,input) what is
19 // the next state to assume.
20 // .SECTION Thanks
21 // This work is part of the National Alliance for Medical Image
22 // Computing (NAMIC), funded by the National Institutes of Health
23 // through the NIH Roadmap for Medical Research, Grant U54 EB005149.
24 // Information on the National Centers for Biomedical Computing
25 // can be obtained from http://nihroadmap.nih.gov/bioinformatics.
26 // .SECTION See Also
27 // vtkKWStateMachine vtkKWStateMachineState vtkKWStateMachineTransition
28 
29 #ifndef __vtkKWStateMachineTransition_h
30 #define __vtkKWStateMachineTransition_h
31 
32 #include "vtkKWObject.h"
33 
36 
38 {
39 public:
41  vtkTypeRevisionMacro(vtkKWStateMachineTransition, vtkKWObject);
42  void PrintSelf(ostream& os, vtkIndent indent);
43 
44  // Description:
45  // Get id.
46  vtkGetMacro(Id, vtkIdType);
47 
48  // Description:
49  // Set/Get the state this transition is originating from.
50  vtkGetObjectMacro(OriginState, vtkKWStateMachineState);
51  virtual void SetOriginState(vtkKWStateMachineState*);
52 
53  // Description:
54  // Set/Get the input this transition is triggered by.
55  vtkGetObjectMacro(Input, vtkKWStateMachineInput);
56  virtual void SetInput(vtkKWStateMachineInput*);
57 
58  // Description:
59  // Set/Get the state this transition is leading to.
60  vtkGetObjectMacro(DestinationState, vtkKWStateMachineState);
61  virtual void SetDestinationState(vtkKWStateMachineState*);
62 
63  // Description:
64  // Get if the transition is complete, i.e. it has an originating
65  // state (OriginState), a destination state (DestinationState), and
66  // an input (Input).
67  virtual int IsComplete();
68 
69  // Description:
70  // Start the transition. This method should be invoked when the transition
71  // is "started" by the state machine, as the state machine is about to
72  // leave the OriginState but has not yet entered the DestinationState.
73  // This can prove useful to push bew inputs that rely on the fact that the
74  // state machine is still at the OriginState.
75  // It will take care of calling the corresponding callbacks (StartCommand)
76  // and events (StartEvent). Subclasses that override this method should
77  // make sure they call their superclass's Start() method.
78  virtual void Start();
79 
80  // Description:
81  // End the transition. This command should be invoked when the transition
82  // is "ended" by the state machine, as the state machine has left the
83  // OriginState and already entered the DestinationState.
84  // This can prove useful to push new inputs that rely on the fact that the
85  // state machine is now at the DestinationState.
86  // It will take care of calling the corresponding callbacks (EndCommand)
87  // and events (EndEvent). Subclasses that override this method should
88  // make sure they call their superclass's End() method.
89  virtual void End();
90 
91  // Description:
92  // Specifies a command to associate with this transition. This command
93  // should be invoked when the transition is "started" by the state machine,
94  // as the state machine is about to leave the OriginState but has not yet
95  // entered the DestinationState. State machine (sub)classes should call
96  // the Start() method most of the time, which will take care of triggering
97  // this callback and firing the StartEvent as well.
98  // The 'object' argument is the object that will have the method called on
99  // it. The 'method' argument is the name of the method to be called and any
100  // arguments in string form. If the object is NULL, the method is still
101  // evaluated as a simple command.
102  virtual void SetStartCommand(vtkObject *object, const char *method);
103  virtual void InvokeStartCommand();
104  virtual int HasStartCommand();
105 
106  // Description:
107  // Specifies a command to associate with this transition. This command
108  // should be invoked when the transition is "ended" by the state machine, as
109  // the state machine has left the OriginState and already entered
110  // the DestinationState. State machine (sub)classes should call
111  // the End() method most of the time, which will take care of triggering this
112  // callback and firing the EndEvent as well.
113  // The 'object' argument is the object that will have the method called on
114  // it. The 'method' argument is the name of the method to be called and any
115  // arguments in string form. If the object is NULL, the method is still
116  // evaluated as a simple command.
117  virtual void SetEndCommand(vtkObject *object, const char *method);
118  virtual void InvokeEndCommand();
119  virtual int HasEndCommand();
120 
121  // Description:
122  // Events. The StartEvent should be fired when the transition is "started"
123  // by the state machine, as the state machine is about to leave the
124  // OriginState but has not yet entered the DestinationState. The "EndEvent"
125  // should be fired when the transition is "ended" by the state machine, as
126  // the state machine has left the OriginState and already entered the
127  // DestinationState. In both case, State machine (sub)classes should call
128  // the corresponding Start() end End() methods most of the time, which will
129  // take care of triggering both the callbacks and firing the events.
130  //BTX
131  enum
132  {
133  StartEvent = 10000,
134  EndEvent
135  };
136  //ETX
137 
138 protected:
141 
142  vtkIdType Id;
146 
147  char *EndCommand;
149 
150 private:
151 
152  static vtkIdType IdCounter;
153 
154  vtkKWStateMachineTransition(const vtkKWStateMachineTransition&); // Not implemented
155  void operator=(const vtkKWStateMachineTransition&); // Not implemented
156 };
157 
158 #endif