Changes in src/Actions/Action.cpp [bcf653:e4afb4]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/Action.cpp
rbcf653 re4afb4 20 20 #include "Helpers/MemDebug.hpp" 21 21 22 #include <iostream> 22 23 #include <string> 23 24 … … 25 26 #include "Actions/ActionRegistry.hpp" 26 27 #include "Actions/ActionHistory.hpp" 28 #include "Actions/OptionRegistry.hpp" 29 #include "Actions/OptionTrait.hpp" 27 30 #include "Exceptions/MissingValueException.hpp" 28 31 #include "UIElements/Dialog.hpp" 32 #include "Helpers/Assert.hpp" 29 33 #include "Helpers/MemDebug.hpp" 30 34 #include "UIElements/UIFactory.hpp" … … 43 47 Action::state_ptr Action::failure = getEmptyState(); 44 48 45 Action::Action( std::string _name,bool _doRegister) :46 name(_name)49 Action::Action(const ActionTraits &_Traits, bool _doRegister) : 50 Traits(_Traits) 47 51 { 52 // register with ActionRegistry 48 53 if(_doRegister){ 49 54 ActionRegistry::getInstance().registerInstance(this); 55 } 56 57 // register with OptionRegistry 58 for (ActionTraits::options_const_iterator optioniter = Traits.getBeginIter(); 59 optioniter != Traits.getEndIter(); 60 ++optioniter) { 61 // options may have been re-used by other Actions, so check beforehand whether adding is needed 62 if (!OptionRegistry::getInstance().isOptionPresentByName((optioniter->first))) { 63 OptionRegistry::getInstance().registerInstance(optioniter->second); 64 } else { // if present, ASSERT that types coincide 65 OptionTrait const * const PresentOption = OptionRegistry::getInstance().getOptionByName(optioniter->first); 66 ASSERT(PresentOption->getType() == optioniter->second->getType(), 67 ("Action::Action() - option to add "+ 68 std::string(optioniter->first)+ 69 " of Action "+ 70 std::string(getName())+ 71 " is already present with different type!" 72 ) 73 ); 74 } 50 75 } 51 76 } … … 55 80 56 81 const string Action::getName(){ 57 return name;82 return Traits.getName(); 58 83 } 59 84 … … 104 129 return true; 105 130 } 131
Note:
See TracChangeset
for help on using the changeset viewer.