/* * 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. */ /* * SetDefaultNameAction.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 "World.hpp" #include #include #include "Actions/WorldAction/SetDefaultNameAction.hpp" using namespace MoleCuilder; // and construct the stuff #include "SetDefaultNameAction.def" #include "Action_impl_pre.hpp" /** =========== define the function ====================== */ Action::state_ptr WorldSetDefaultNameAction::performCall() { string Worldsdefaultname; Worldsdefaultname = World::getInstance().getDefaultName(); WorldSetDefaultNameState *UndoState = new WorldSetDefaultNameState(Worldsdefaultname, params); World::getInstance().setDefaultName(params.newname.get()); LOG(0, "Default name of new molecules set to " << World::getInstance().getDefaultName() << "."); return Action::state_ptr(UndoState); } Action::state_ptr WorldSetDefaultNameAction::performUndo(Action::state_ptr _state) { WorldSetDefaultNameState *state = assert_cast(_state.get()); World::getInstance().setDefaultName(state->lastname); LOG(0, "Default name of new molecules set to " << World::getInstance().getDefaultName() << "."); return Action::state_ptr(_state); } Action::state_ptr WorldSetDefaultNameAction::performRedo(Action::state_ptr _state){ WorldSetDefaultNameState *state = assert_cast(_state.get()); World::getInstance().setDefaultName(state->params.newname.get()); LOG(0, "Default name of new molecules set to " << World::getInstance().getDefaultName() << "."); return Action::state_ptr(_state); } bool WorldSetDefaultNameAction::canUndo() { return true; } bool WorldSetDefaultNameAction::shouldUndo() { return true; } /** =========== end of function ====================== */