Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkStateMachineContainer.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkStateMachineContainer_h
14 #define mitkStateMachineContainer_h
15 
16 #include <itkObject.h>
17 #include <iostream>
18 #include <vtkXMLParser.h>
19 
20 #include <itkObjectFactory.h>
21 #include <mitkCommon.h>
22 
23 #include <mitkStateMachineAction.h>
24 #include <mitkStateMachineState.h>
26 
27 namespace us
28 {
29  class Module;
30 }
31 
32 namespace mitk
33 {
43  class StateMachineContainer : public vtkXMLParser
44  {
45  public:
48 
50  typedef std::vector<StateMachineState::Pointer> StateMachineCollectionType;
51 
56  StateMachineState::Pointer GetStartState() const;
57 
71  bool LoadBehavior(const std::string &fileName, const us::Module *module);
72 
75 
76  protected:
79 
85  void StartElement(const char *elementName, const char **atts) override;
86 
92  void EndElement(const char *elementName) override;
93 
94  private:
102  std::string ReadXMLStringAttribut(std::string name, const char **atts);
103 
111  bool ReadXMLBooleanAttribut(std::string name, const char **atts);
112 
116  void ConnectStates();
117 
118  StateMachineState::Pointer m_StartState;
119  StateMachineState::Pointer m_CurrState;
120  StateMachineTransition::Pointer m_CurrTransition;
121 
123  bool m_StartStateFound;
124  bool
125  m_errors; // use member, because of inheritance from vtkXMLParser we can't return a success value for parsing the
126  // file.
127  std::string m_Filename; // store file name for debug purposes.
128  };
129 
130 } // namespace mitk
131 
132 #endif
Parses XML state machine descriptions and builds the state machine structure.
void StartElement(const char *elementName, const char **atts) override
Handle the start of an XML element during parsing.
std::vector< StateMachineState::Pointer > StateMachineCollectionType
Type that holds all states of one state machine.
void EndElement(const char *elementName) override
Handle the end of an XML element during parsing.
bool LoadBehavior(const std::string &fileName, const us::Module *module)
Load a state machine pattern from an XML resource file.
vtkTypeMacro(StateMachineContainer, vtkXMLParser)
friend class InteractionStateMachine
To enable InteractionStateMachine to access states.
static StateMachineContainer * New()
StateMachineState::Pointer GetStartState() const
Return the start state of the state machine.
Represents a CppMicroServices module.
Definition: usModule.h:70
Find image slices visible on a given plane.