| 39 | } |
| 40 | |
| 41 | bool mitk::EventStateMachine::LoadStateMachine(const std::string &filename, const us::Module *module) |
| 42 | { |
| 43 | if (m_StateMachineContainer != nullptr) |
| 44 | { |
| 45 | m_StateMachineContainer->Delete(); |
| 46 | } |
| 47 | m_StateMachineContainer = StateMachineContainer::New(); |
| 48 | |
| 49 | if (m_StateMachineContainer->LoadBehavior(filename, module)) |
| 50 | { |
| 51 | m_CurrentState = m_StateMachineContainer->GetStartState(); |
| 52 | |
| 53 | for (auto i = m_ConditionDelegatesMap.begin(); i != m_ConditionDelegatesMap.end(); |
| 54 | ++i) |
| 55 | { |
| 56 | delete i->second; |
| 57 | } |
| 58 | m_ConditionDelegatesMap.clear(); |
| 59 | |
| 60 | // clear actions map ,and connect all actions as declared in sub-class |
| 61 | for (auto i = m_ActionDelegatesMap.begin(); i != m_ActionDelegatesMap.end(); ++i) |
| 62 | { |
| 63 | delete i->second; |
| 64 | } |
| 65 | m_ActionDelegatesMap.clear(); |
| 66 | |
| 67 | ConnectActionsAndFunctions(); |
| 68 | return true; |
| 69 | } |
| 70 | else |
| 71 | { |
| 72 | MITK_WARN << "Unable to load StateMachine from file: " << filename; |
| 73 | return false; |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | mitk::EventStateMachine::~EventStateMachine() |
| 78 | { |