Changes in src/Actions/ActionQueue.cpp [29b52b:11d433]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/ActionQueue.cpp
r29b52b r11d433 55 55 using namespace MoleCuilder; 56 56 57 const Action* ActionQueue::_lastchangedaction = NULL;58 59 57 ActionQueue::ActionQueue() : 60 Observable("ActionQueue"),61 58 AR(new ActionRegistry()), 62 59 history(new ActionHistory), … … 69 66 run_thread_isIdle(true) 70 67 #endif 71 { 72 // channels of observable 73 Channels *OurChannel = new Channels; 74 NotificationChannels.insert( std::make_pair(static_cast<Observable *>(this), OurChannel) ); 75 // add instance for each notification type 76 for (size_t type = 0; type < NotificationType_MAX; ++type) 77 OurChannel->addChannel(type); 78 } 68 {} 79 69 80 70 ActionQueue::~ActionQueue() … … 84 74 #endif 85 75 86 // free all actions contained in actionqueue 87 for (ActionQueue_t::iterator iter = actionqueue.begin(); !actionqueue.empty(); iter = actionqueue.begin()) { 88 delete *iter; 89 actionqueue.erase(iter); 90 } 76 clearQueue(); 91 77 92 78 delete history; … … 96 82 void ActionQueue::queueAction(const std::string &name, enum Action::QueryOptions state) 97 83 { 98 queueAction(AR->getActionByName(name), state); 99 } 100 101 void ActionQueue::queueAction(Action *_action, enum Action::QueryOptions state) 102 { 103 OBSERVE; 104 NOTIFY(ActionQueued); 84 const Action * const registryaction = AR->getActionByName(name); 85 queueAction(registryaction, state); 86 } 87 88 void ActionQueue::queueAction(const Action * const _action, enum Action::QueryOptions state) 89 { 105 90 Action *newaction = _action->clone(state); 106 91 newaction->prepare(state); … … 116 101 std::cerr << "Action " << *boost::get_error_info<ActionNameString>(e) << " has failed." << std::endl; 117 102 World::getInstance().setExitFlag(5); 118 actionqueue.clear(); 119 tempqueue.clear(); 103 clearQueue(); 104 lastActionOk = false; 105 std::cerr << "ActionQueue cleared." << std::endl; 106 } catch (std::exception &e) { 107 pushStatus("FAIL: General exception caught, aborting."); 108 World::getInstance().setExitFlag(134); 109 clearQueue(); 120 110 lastActionOk = false; 121 111 std::cerr << "ActionQueue cleared." << std::endl; … … 128 118 mtx_queue.unlock(); 129 119 #endif 130 _lastchangedaction = newaction;131 120 } 132 121 … … 180 169 pushStatus("FAIL: Action "+*boost::get_error_info<ActionNameString>(e)+" has failed."); 181 170 World::getInstance().setExitFlag(5); 182 actionqueue.clear(); 183 tempqueue.clear(); 171 clearQueue(); 184 172 lastActionOk = false; 173 std::cerr << "ActionQueue cleared." << std::endl; 174 CurrentAction = (size_t)-1; 175 } catch (std::exception &e) { 176 pushStatus("FAIL: General exception caught, aborting."); 177 World::getInstance().setExitFlag(134); 178 clearQueue(); 185 179 std::cerr << "ActionQueue cleared." << std::endl; 186 180 CurrentAction = (size_t)-1; … … 302 296 } 303 297 298 void ActionQueue::clearQueue() 299 { 300 // free all actions contained in actionqueue 301 for (ActionQueue_t::iterator iter = actionqueue.begin(); 302 !actionqueue.empty(); iter = actionqueue.begin()) { 303 delete *iter; 304 actionqueue.erase(iter); 305 } 306 // free all actions contained in tempqueue 307 for (ActionQueue_t::iterator iter = tempqueue.begin(); 308 !tempqueue.empty(); iter = tempqueue.begin()) { 309 delete *iter; 310 tempqueue.erase(iter); 311 } 312 } 304 313 305 314 const ActionQueue::ActionTokens_t ActionQueue::getListOfActions() const
Note:
See TracChangeset
for help on using the changeset viewer.