Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/CmdAction/VerboseAction.cpp

    r92c52f rbf3817  
    55 *      Author: heber
    66 */
     7
     8// include config.h
     9#ifdef HAVE_CONFIG_H
     10#include <config.h>
     11#endif
    712
    813#include "Helpers/MemDebug.hpp"
     
    2631class CommandLineVerboseState : public ActionState {
    2732public:
    28   CommandLineVerboseState(const int _oldverbosity, const int _newverbosity) :
    29     oldverbosity(_oldverbosity),
    30     newverbosity(_newverbosity)
     33  CommandLineVerboseState(int _verbosity) :
     34    verbosity(_verbosity)
    3135  {}
    32   int oldverbosity;
    33   int newverbosity;
     36  int verbosity;
    3437};
    3538
     
    5861
    5962Action::state_ptr CommandLineVerboseAction::performCall() {
    60   int oldverbosity = getVerbosity();
    61   int newverbosity = 2;
     63  int verbosity = 2;
    6264
    63   ValueStorage::getInstance().queryCurrentValue(NAME, newverbosity);
     65  ValueStorage::getInstance().queryCurrentValue(NAME, verbosity);
    6466
    65   if (oldverbosity != newverbosity) {
    66     CommandLineVerboseState *UndoState = new CommandLineVerboseState(oldverbosity, newverbosity);
    67     setVerbosity(newverbosity);
    68     DoLog(0) && (Log() << Verbose(0) << "Setting verbosity from " << oldverbosity << " to " << newverbosity << "." << endl);
    69     return Action::state_ptr(UndoState);
    70   } else {
    71     DoLog(0) && (Log() << Verbose(0) << "Verbosity remains unchanged at " << oldverbosity << "." << endl);
    72     return Action::failure;
    73   }
     67  setVerbosity(verbosity);
     68  DoLog(0) && (Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl);
     69  return Action::success;
    7470}
    7571
     
    7773  CommandLineVerboseState *state = assert_cast<CommandLineVerboseState*>(_state.get());
    7874
    79   DoLog(0) && (Log() << Verbose(0) << "Setting verbosity from " << state->newverbosity << " to " << state->oldverbosity << "." << endl);
    80   setVerbosity(state->oldverbosity);
     75  int verbosity = 2;
     76  ValueStorage::getInstance().queryCurrentValue(NAME, verbosity);
    8177
    82   return Action::state_ptr(_state);
     78  setVerbosity(state->verbosity);
     79  return Action::state_ptr(new CommandLineVerboseState(verbosity));
    8380}
    8481
    8582Action::state_ptr CommandLineVerboseAction::performRedo(Action::state_ptr _state){
    86   CommandLineVerboseState *state = assert_cast<CommandLineVerboseState*>(_state.get());
    87 
    88   DoLog(0) && (Log() << Verbose(0) << "Setting verbosity from " << state->oldverbosity << " to " << state->newverbosity << "." << endl);
    89   setVerbosity(state->newverbosity);
    90 
    91   return Action::state_ptr(_state);
     83  return performUndo(_state);
    9284}
    9385
Note: See TracChangeset for help on using the changeset viewer.