- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/CmdAction/VerboseAction.cpp
rbf3817 rbcf653 1 /* 2 * Project: MoleCuilder 3 * Description: creates and alters molecular systems 4 * Copyright (C) 2010 University of Bonn. All rights reserved. 5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. 6 */ 7 1 8 /* 2 9 * VerboseAction.cpp … … 31 38 class CommandLineVerboseState : public ActionState { 32 39 public: 33 CommandLineVerboseState(int _verbosity) : 34 verbosity(_verbosity) 40 CommandLineVerboseState(const int _oldverbosity, const int _newverbosity) : 41 oldverbosity(_oldverbosity), 42 newverbosity(_newverbosity) 35 43 {} 36 int verbosity; 44 int oldverbosity; 45 int newverbosity; 37 46 }; 38 47 … … 61 70 62 71 Action::state_ptr CommandLineVerboseAction::performCall() { 63 int verbosity = 2; 72 int oldverbosity = getVerbosity(); 73 int newverbosity = 2; 64 74 65 ValueStorage::getInstance().queryCurrentValue(NAME, verbosity);75 ValueStorage::getInstance().queryCurrentValue(NAME, newverbosity); 66 76 67 setVerbosity(verbosity); 68 DoLog(0) && (Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl); 69 return Action::success; 77 if (oldverbosity != newverbosity) { 78 CommandLineVerboseState *UndoState = new CommandLineVerboseState(oldverbosity, newverbosity); 79 setVerbosity(newverbosity); 80 DoLog(0) && (Log() << Verbose(0) << "Setting verbosity from " << oldverbosity << " to " << newverbosity << "." << endl); 81 return Action::state_ptr(UndoState); 82 } else { 83 DoLog(0) && (Log() << Verbose(0) << "Verbosity remains unchanged at " << oldverbosity << "." << endl); 84 return Action::failure; 85 } 70 86 } 71 87 … … 73 89 CommandLineVerboseState *state = assert_cast<CommandLineVerboseState*>(_state.get()); 74 90 75 int verbosity = 2;76 ValueStorage::getInstance().queryCurrentValue(NAME,verbosity);91 DoLog(0) && (Log() << Verbose(0) << "Setting verbosity from " << state->newverbosity << " to " << state->oldverbosity << "." << endl); 92 setVerbosity(state->oldverbosity); 77 93 78 setVerbosity(state->verbosity); 79 return Action::state_ptr(new CommandLineVerboseState(verbosity)); 94 return Action::state_ptr(_state); 80 95 } 81 96 82 97 Action::state_ptr CommandLineVerboseAction::performRedo(Action::state_ptr _state){ 83 return performUndo(_state); 98 CommandLineVerboseState *state = assert_cast<CommandLineVerboseState*>(_state.get()); 99 100 DoLog(0) && (Log() << Verbose(0) << "Setting verbosity from " << state->oldverbosity << " to " << state->newverbosity << "." << endl); 101 setVerbosity(state->newverbosity); 102 103 return Action::state_ptr(_state); 84 104 } 85 105
Note:
See TracChangeset
for help on using the changeset viewer.