MCPcopy Create free account
hub / github.com/MITK/MITK / StartElement

Method StartElement

Modules/Core/src/Interactions/mitkStateMachineContainer.cpp:93–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91}
92
93void mitk::StateMachineContainer::StartElement(const char *elementName, const char **atts)
94{
95 std::string name(elementName);
96
97 if (name == CONFIG)
98 {
99 //
100 }
101 else if (name == STATE)
102 {
103 std::string stateName = ReadXMLStringAttribut(NAME, atts);
104 std::transform(stateName.begin(), stateName.end(), stateName.begin(), ::toupper);
105 std::string stateMode = ReadXMLStringAttribut(STATEMODE, atts);
106 std::transform(stateMode.begin(), stateMode.end(), stateMode.begin(), ::toupper);
107 bool isStartState = ReadXMLBooleanAttribut(STARTSTATE, atts);
108
109 if (isStartState)
110 {
111 m_StartStateFound = true;
112 }
113
114 // sanitize state modes
115 if (stateMode == "" || stateMode == "REGULAR")
116 {
117 stateMode = "REGULAR";
118 }
119 else if (stateMode != "GRAB_INPUT" && stateMode != "PREFER_INPUT")
120 {
121 MITK_WARN << "Invalid State Modus " << stateMode << ". Mode assumed to be REGULAR";
122 stateMode = "REGULAR";
123 }
124 m_CurrState = mitk::StateMachineState::New(stateName, stateMode);
125
126 if (isStartState)
127 m_StartState = m_CurrState;
128 }
129 else if (name == TRANSITION)
130 {
131 std::string eventClass = ReadXMLStringAttribut(EVENTCLASS, atts);
132 std::string eventVariant = ReadXMLStringAttribut(EVENTVARIANT, atts);
133 std::string target = ReadXMLStringAttribut(TARGET, atts);
134 std::transform(target.begin(), target.end(), target.begin(), ::toupper);
135
136 mitk::StateMachineTransition::Pointer transition =
137 mitk::StateMachineTransition::New(target, eventClass, eventVariant);
138 if (m_CurrState)
139 {
140 m_CurrState->AddTransition(transition);
141 }
142 else
143 {
144 MITK_WARN << "Malformed Statemachine Pattern. Transition has no origin. \n Will be ignored.";
145 MITK_WARN << "Malformed Transition details: target=" << target << ", event class:" << eventClass
146 << ", event variant:" << eventVariant;
147 }
148 m_CurrTransition = transition;
149 }
150

Callers

nothing calls this directly

Calls 7

AddTransitionMethod · 0.80
AddConditionMethod · 0.80
NewFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
AddActionMethod · 0.45

Tested by

no test coverage detected