Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef STATEMACHINECONTAINER_H_HEADER_INCLUDED_C19AEDDD
18 #define STATEMACHINECONTAINER_H_HEADER_INCLUDED_C19AEDDD
19 
20 #include "itkObject.h"
21 #include <iostream>
22 #include <vtkXMLParser.h>
23 
24 #include "itkObjectFactory.h"
25 #include "mitkCommon.h"
26 
27 #include "mitkStateMachineAction.h"
28 #include "mitkStateMachineState.h"
30 
31 namespace us
32 {
33  class Module;
34 }
35 
36 namespace mitk
37 {
43  class StateMachineContainer : public vtkXMLParser
44  {
45  public:
46  static StateMachineContainer *New();
47  vtkTypeMacro(StateMachineContainer, vtkXMLParser);
48 
52  typedef std::vector<StateMachineState::Pointer> StateMachineCollectionType;
53 
58 
65  bool LoadBehavior(const std::string &fileName, const us::Module *module);
66 
71 
72  protected:
74  virtual ~StateMachineContainer();
75 
79  void StartElement(const char *elementName, const char **atts) override;
83  void EndElement(const char *elementName) override;
84 
85  private:
89  std::string ReadXMLStringAttribut(std::string name, const char **atts);
93  bool ReadXMLBooleanAttribut(std::string name, const char **atts);
94 
98  void ConnectStates();
99 
100  StateMachineState::Pointer m_StartState;
101  StateMachineState::Pointer m_CurrState;
102  StateMachineTransition::Pointer m_CurrTransition;
103 
104  StateMachineCollectionType m_States;
105  bool m_StartStateFound;
106  bool
107  m_errors; // use member, because of inheritance from vtkXMLParser we can't return a success value for parsing the
108  // file.
109  std::string m_Filename; // store file name for debug purposes.
110  };
111 
112 } // namespace mitk
113 
114 #endif /* STATEMACHINECONTAINER_H_HEADER_INCLUDED_C19AEDDD */
bool LoadBehavior(const std::string &fileName, const us::Module *module)
Loads XML resource.
vtkTypeMacro(StateMachineContainer, vtkXMLParser)
DataCollection - Class to facilitate loading/accessing structured data.
StateMachineState::Pointer GetStartState() const
Returns the StartState of the StateMachine.
void StartElement(const char *elementName, const char **atts) override
Derived from XMLReader.
static StateMachineContainer * New()
std::vector< StateMachineState::Pointer > StateMachineCollectionType
This type holds all states of one statemachine.
void EndElement(const char *elementName) override
Derived from XMLReader.