83 void onInitRemoteStateOfferer()
override;
84 void onConnectRemoteStateOfferer()
override;
85 void onExitRemoteStateOfferer()
override;
87 bool loadLib(std::string libPath);
89 StateBasePtr getStatePtr(
const std::string& stateName)
const override;
92 std::map<std::string, DynamicLibraryPtr> libraries;
93 std::string statechartGroupName;
94 std::map<std::string, StatePtr> uuidStateMap;
99 template <
typename ContextType>
105 statechartGroupName = reader->getGroupName();
116 template <
typename ContextType>
118 XMLRemoteStateOfferer<ContextType>::onInitRemoteStateOfferer()
121 statechartGroupName = reader->getGroupName();
122 Ice::StringSeq xmlStateFileList = reader->getStateFilepaths();
124 std::map<std::string, StatechartGroupXmlReader::StateVisibility> visibilities;
126 for (
unsigned int i = 0; i < xmlStateFileList.size(); i++)
128 std::string& filepath = xmlStateFileList.at(i);
133 ARMARX_ERROR <<
"Could not find xml state file: " << filepath;
139 auto uuid = reader->getRoot(
"State").attribute_value(
"uuid");
140 uuidXMLMap->insert(std::make_pair(uuid, reader));
141 visibilities[uuid] = this->reader->getStateVisibility(filepath);
144 for (StringXMLNodeMap::iterator it = uuidXMLMap->begin(); it != uuidXMLMap->end(); it++)
157 ARMARX_ERROR <<
"The loading of the xml state failed due to an invalid xml file '"
158 << it->first <<
"'.\nError hint: " << e.what();
160 catch (std::exception& e)
162 ARMARX_ERROR <<
"The loading of the xml state failed due to an invalid xml file '"
163 << it->first <<
"'.\nError hint: " << e.what();
167 onInitXMLRemoteStateOfferer();
170 template <
typename ContextType>
172 XMLRemoteStateOfferer<ContextType>::onConnectRemoteStateOfferer()
174 onConnectXMLRemoteStateOfferer();
177 template <
typename ContextType>
179 XMLRemoteStateOfferer<ContextType>::onExitRemoteStateOfferer()
181 onExitXMLRemoteStateOfferer();
184 template <
typename ContextType>
186 XMLRemoteStateOfferer<ContextType>::getStatePtr(
const std::string& stateName)
const
188 for (
const auto& substate : StateBase::subStateList)
190 if (StateBasePtr::dynamicCast(substate)->stateName == stateName)
192 return StateBasePtr::dynamicCast(substate);
196 auto it = uuidStateMap.find(stateName);
198 if (it != uuidStateMap.end())
206 ARMARX_ERROR <<
"State with id '" << stateName <<
"' has NULL ptr in map!";
210 ARMARX_ERROR <<
"Could not find state with name '" << stateName <<
"'";
215 template <
typename ContextType>
221 std::string uuid = node.attribute_value(
"uuid");
223 IceInternal::Handle<XMLState> xmlStateInstance =
228 this->reader->getSelectedProfile(),
231 StatePtr state = StatePtr::dynamicCast(xmlStateInstance);
238 this->reader->getSelectedProfile(),
248 state->stateName = stateName;
249 state->stateClassName = stateName;
251 uuidStateMap[uuid] = state;
258 template <
typename ContextType>
260 XMLRemoteStateOfferer<ContextType>::addState(
StatePtr state)
270 "There exists already a substate with name '" + state->getStateName() +
271 "' in this hierarchy level. In one hierarchy level (aka one substatelist) the "
272 "names must be unique.");
275 if (state->getStateName().empty())
280 state->__setParentState(
this);
281 this->StateBase::subStateList.push_back(state);
282 this->initState(*state);
287 template <
typename ContextType>
291 return statechartGroupName;
294 template <
typename ContextType>
298 statechartGroupName = value;