Medical Imaging Interaction Toolkit  2021.10.99-9c07a326
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 STATEMACHINECONTAINER_H_HEADER_INCLUDED_C19AEDDD
14 #define STATEMACHINECONTAINER_H_HEADER_INCLUDED_C19AEDDD
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 {
39  class StateMachineContainer : public vtkXMLParser
40  {
41  public:
42  static StateMachineContainer *New();
43  vtkTypeMacro(StateMachineContainer, vtkXMLParser);
44 
48  typedef std::vector<StateMachineState::Pointer> StateMachineCollectionType;
49 
53  StateMachineState::Pointer GetStartState() const;
54 
61  bool LoadBehavior(const std::string &fileName, const us::Module *module);
62 
66  friend class InteractionStateMachine;
67 
68  protected:
70  ~StateMachineContainer() override;
71 
75  void StartElement(const char *elementName, const char **atts) override;
79  void EndElement(const char *elementName) override;
80 
81  private:
85  std::string ReadXMLStringAttribut(std::string name, const char **atts);
89  bool ReadXMLBooleanAttribut(std::string name, const char **atts);
90 
94  void ConnectStates();
95 
96  StateMachineState::Pointer m_StartState;
97  StateMachineState::Pointer m_CurrState;
98  StateMachineTransition::Pointer m_CurrTransition;
99 
100  StateMachineCollectionType m_States;
101  bool m_StartStateFound;
102  bool
103  m_errors; // use member, because of inheritance from vtkXMLParser we can't return a success value for parsing the
104  // file.
105  std::string m_Filename; // store file name for debug purposes.
106  };
107 
108 } // namespace mitk
109 
110 #endif /* STATEMACHINECONTAINER_H_HEADER_INCLUDED_C19AEDDD */
DataCollection - Class to facilitate loading/accessing structured data.
std::vector< StateMachineState::Pointer > StateMachineCollectionType
This type holds all states of one statemachine.