00001 /*========================================================================= 00002 00003 Module: $RCSfile: vtkKWStateMachineState.h,v $ 00004 00005 Copyright (c) Kitware, Inc. 00006 All rights reserved. 00007 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00008 00009 This software is distributed WITHOUT ANY WARRANTY; without even 00010 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00011 PURPOSE. See the above copyright notice for more information. 00012 00013 =========================================================================*/ 00014 // .NAME vtkKWStateMachineState - a state machine state. 00015 // .SECTION Description 00016 // This class is the basis for a state machine state. 00017 // A state machine is defined by a set of states, a set of inputs and a 00018 // transition matrix that defines for each pair of (state,input) what is 00019 // the next state to assume. 00020 // .SECTION Thanks 00021 // This work is part of the National Alliance for Medical Image 00022 // Computing (NAMIC), funded by the National Institutes of Health 00023 // through the NIH Roadmap for Medical Research, Grant U54 EB005149. 00024 // Information on the National Centers for Biomedical Computing 00025 // can be obtained from http://nihroadmap.nih.gov/bioinformatics. 00026 // .SECTION See Also 00027 // vtkKWStateMachine vtkKWStateMachineInput vtkKWStateMachineTransition 00028 00029 #ifndef __vtkKWStateMachineState_h 00030 #define __vtkKWStateMachineState_h 00031 00032 #include "vtkKWObject.h" 00033 00034 class KWWidgets_EXPORT vtkKWStateMachineState : public vtkKWObject 00035 { 00036 public: 00037 static vtkKWStateMachineState* New(); 00038 vtkTypeRevisionMacro(vtkKWStateMachineState, vtkKWObject); 00039 void PrintSelf(ostream& os, vtkIndent indent); 00040 00041 // Description: 00042 // Get id. 00043 vtkGetMacro(Id, vtkIdType); 00044 00045 // Description: 00046 // Set/Get simple name. 00047 vtkGetStringMacro(Name); 00048 vtkSetStringMacro(Name); 00049 00050 // Description: 00051 // Set/Get longer description. 00052 vtkGetStringMacro(Description); 00053 vtkSetStringMacro(Description); 00054 00055 // Description: 00056 // Enter the state. This method should be invoked by the state machine when 00057 // it enters this state. It will take care of calling the corresponding 00058 // callbacks (EnterCommand) and events (EnterEvent). Subclasses that 00059 // override this method should make sure they call their superclass's 00060 // Enter() method. 00061 virtual void Enter(); 00062 00063 // Description: 00064 // Leave the state. This method should be invoked by the state machine when 00065 // it leaves this state. It will take care of calling the corresponding 00066 // callbacks (LeaveCommand) and events (LeaveEvent). Subclasses that 00067 // override this method should make sure they call their superclass's 00068 // Leave() method. 00069 virtual void Leave(); 00070 00071 // Description: 00072 // Specifies a command to associate with this state. This command 00073 // should be invoked by the state machine when it enters this state. 00074 // State machine (sub)classes should call the Enter() method most of the 00075 // time, which will take care of triggering this callback and firing 00076 // the EnterEvent as well. 00077 // The 'object' argument is the object that will have the method called on 00078 // it. The 'method' argument is the name of the method to be called and any 00079 // arguments in string form. If the object is NULL, the method is still 00080 // evaluated as a simple command. 00081 virtual void SetEnterCommand(vtkObject *object, const char *method); 00082 virtual void InvokeEnterCommand(); 00083 virtual int HasEnterCommand(); 00084 00085 // Description: 00086 // Specifies a command to associate with this state. This command 00087 // should be invoked by the state machine when it leaves this state. 00088 // State machine (sub)classes should call the Leave() method most of the 00089 // time, which will take care of triggering this callback and firing 00090 // the EnterEvent as well. 00091 // The 'object' argument is the object that will have the method called on 00092 // it. The 'method' argument is the name of the method to be called and any 00093 // arguments in string form. If the object is NULL, the method is still 00094 // evaluated as a simple command. 00095 virtual void SetLeaveCommand(vtkObject *object, const char *method); 00096 virtual void InvokeLeaveCommand(); 00097 virtual int HasLeaveCommand(); 00098 00099 // Description: 00100 // Events. The EnterEvent should be fired when the state machine enters 00101 // this state. The LeaveEvent should be fired when the state machine 00102 // leaves this state. In both case, state machine (sub)classes should call 00103 // the corresponding Enter() end Leave() methods most of the time, which will 00104 // take care of triggering both the callbacks and firing the events. 00105 //BTX 00106 enum 00107 { 00108 EnterEvent = 10000, 00109 LeaveEvent 00110 }; 00111 //ETX 00112 00113 // Description: 00114 // Set/Get if the set is an accepting state. This is mainly used for 00115 // display or IO purposes (see vtkKWStateMachineDOTWriter). 00116 vtkBooleanMacro(Accepting, int); 00117 vtkGetMacro(Accepting, int); 00118 vtkSetMacro(Accepting, int); 00119 00120 protected: 00121 vtkKWStateMachineState(); 00122 ~vtkKWStateMachineState(); 00123 00124 vtkIdType Id; 00125 char *Name; 00126 char *Description; 00127 int Accepting; 00128 00129 char *EnterCommand; 00130 char *LeaveCommand; 00131 00132 private: 00133 00134 static vtkIdType IdCounter; 00135 00136 vtkKWStateMachineState(const vtkKWStateMachineState&); // Not implemented 00137 void operator=(const vtkKWStateMachineState&); // Not implemented 00138 }; 00139 00140 #endif