- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/CmdAction/VerboseAction.cpp
r952f38 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 … … 5 12 * Author: heber 6 13 */ 14 15 // include config.h 16 #ifdef HAVE_CONFIG_H 17 #include <config.h> 18 #endif 7 19 8 20 #include "Helpers/MemDebug.hpp" … … 26 38 class CommandLineVerboseState : public ActionState { 27 39 public: 28 CommandLineVerboseState(int _verbosity) : 29 verbosity(_verbosity) 40 CommandLineVerboseState(const int _oldverbosity, const int _newverbosity) : 41 oldverbosity(_oldverbosity), 42 newverbosity(_newverbosity) 30 43 {} 31 int verbosity; 44 int oldverbosity; 45 int newverbosity; 32 46 }; 33 47 … … 56 70 57 71 Action::state_ptr CommandLineVerboseAction::performCall() { 58 int verbosity = 2; 72 int oldverbosity = getVerbosity(); 73 int newverbosity = 2; 59 74 60 ValueStorage::getInstance().queryCurrentValue(NAME, verbosity);75 ValueStorage::getInstance().queryCurrentValue(NAME, newverbosity); 61 76 62 setVerbosity(verbosity); 63 DoLog(0) && (Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl); 64 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 } 65 86 } 66 87 … … 68 89 CommandLineVerboseState *state = assert_cast<CommandLineVerboseState*>(_state.get()); 69 90 70 int verbosity = 2;71 ValueStorage::getInstance().queryCurrentValue(NAME,verbosity);91 DoLog(0) && (Log() << Verbose(0) << "Setting verbosity from " << state->newverbosity << " to " << state->oldverbosity << "." << endl); 92 setVerbosity(state->oldverbosity); 72 93 73 setVerbosity(state->verbosity); 74 return Action::state_ptr(new CommandLineVerboseState(verbosity)); 94 return Action::state_ptr(_state); 75 95 } 76 96 77 97 Action::state_ptr CommandLineVerboseAction::performRedo(Action::state_ptr _state){ 78 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); 79 104 } 80 105
Note:
See TracChangeset
for help on using the changeset viewer.