/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2010-2012 University of Bonn. All rights reserved. * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. */ /* * SetWorldTimeAction.cpp * * Created on: May 8, 2010 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "CodePatterns/MemDebug.hpp" #include "CodePatterns/Log.hpp" #include "CodePatterns/Verbose.hpp" #include "WorldTime.hpp" #include #include #include "Actions/WorldAction/SetWorldTimeAction.hpp" using namespace MoleCuilder; // and construct the stuff #include "SetWorldTimeAction.def" #include "Action_impl_pre.hpp" /** =========== define the function ====================== */ Action::state_ptr WorldSetWorldTimeAction::performCall() { // create undo state int oldtime; oldtime = WorldTime::getTime(); WorldSetWorldTimeState *UndoState = new WorldSetWorldTimeState(oldtime, params); WorldTime::getInstance().setTime(params.newtime); LOG(0, "Current time step is now: " << WorldTime::getTime() << "."); return Action::state_ptr(UndoState); } Action::state_ptr WorldSetWorldTimeAction::performUndo(Action::state_ptr _state) { WorldSetWorldTimeState *state = assert_cast(_state.get()); WorldTime::getInstance().setTime(state->oldtime); LOG(0, "Current time step is now again: " << WorldTime::getTime() << "."); return Action::state_ptr(_state); } Action::state_ptr WorldSetWorldTimeAction::performRedo(Action::state_ptr _state){ WorldSetWorldTimeState *state = assert_cast(_state.get()); WorldTime::getInstance().setTime(state->params.newtime); LOG(0, "Current time step is now: " << WorldTime::getTime() << "."); return Action::state_ptr(_state); } bool WorldSetWorldTimeAction::canUndo() { return true; } bool WorldSetWorldTimeAction::shouldUndo() { return true; } /** =========== end of function ====================== */