/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2010 University of Bonn. All rights reserved. * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. */ /* * OutputAction.cpp * * Created on: May 8, 2010 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "CodePatterns/MemDebug.hpp" #include "Parser/FormatParserStorage.hpp" #include "CodePatterns/Log.hpp" #include "CodePatterns/Verbose.hpp" #include "World.hpp" #include #include #include using namespace std; #include "Actions/WorldAction/OutputAction.hpp" // and construct the stuff #include "OutputAction.def" #include "Action_impl_pre.hpp" /** =========== define the function ====================== */ Action::state_ptr WorldOutputAction::performCall() { // obtain information getParametersfromValueStorage(); DoLog(1) && (Log() << Verbose(1) << "Storing world to file " << params.filename << "." << endl); // extract suffix std::string FilenameSuffix; std::string FilenamePrefix; if (params.filename.has_filename()) { // get suffix FilenameSuffix = params.filename.extension().substr(1); // remove the prefixed "." FilenamePrefix = params.filename.stem(); } else { DoeLog(1) && (eLog() << Verbose(1) << "Output file does not have a suffix, cannot recognize format." << endl); return Action::failure; } // store file // parse the file boost::filesystem::ofstream output; output.open(params.filename); if (!output.fail()) { FormatParserStorage::getInstance().saveWorld(output, FilenameSuffix); } else { DoeLog(1) && (eLog() << Verbose(1) << "Could not open file " << params.filename << "." << endl); } output.close(); return Action::success; } Action::state_ptr WorldOutputAction::performUndo(Action::state_ptr _state) { // ParserLoadXyzState *state = assert_cast(_state.get()); return Action::failure; // string newName = state->mol->getName(); // state->mol->setName(state->lastName); // // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); } Action::state_ptr WorldOutputAction::performRedo(Action::state_ptr _state){ return Action::failure; } bool WorldOutputAction::canUndo() { return false; } bool WorldOutputAction::shouldUndo() { return false; } /** =========== end of function ====================== */