/*
* Project: MoleCuilder
* Description: creates and alters molecular systems
* Copyright (C) 2013 Frederik Heber. All rights reserved.
*
*
* This file is part of MoleCuilder.
*
* MoleCuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* MoleCuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MoleCuilder. If not, see .
*/
/*
* ParseHomologiesAction.cpp
*
* Created on: Jun 24, 2013
* Author: heber
*/
// include config.h
#ifdef HAVE_CONFIG_H
#include
#endif
// include headers that implement a archive in simple text format
// and before MemDebug due to placement new
#include
#include
#include "CodePatterns/MemDebug.hpp"
#include
#include "CodePatterns/Log.hpp"
#include "Fragmentation/Homology/HomologyContainer.hpp"
#include "World.hpp"
#include "Actions/FragmentationAction/ParseHomologiesAction.hpp"
using namespace MoleCuilder;
// and construct the stuff
#include "ParseHomologiesAction.def"
#include "Action_impl_pre.hpp"
/** =========== define the function ====================== */
void parseHomologiesFromFile(
const boost::filesystem::path &homology_file
)
{
HomologyContainer &homology_container = World::getInstance().getHomologies();
if (boost::filesystem::exists(homology_file)) {
std::ifstream returnstream(homology_file.string().c_str());
if (returnstream.good()) {
boost::archive::text_iarchive ia(returnstream);
ia >> homology_container;
} else {
ELOG(2, "Failed to parse from " << homology_file.string() << ".");
}
returnstream.close();
} else {
LOG(2, "Could not open " << homology_file.string()
<< ", creating empty container.");
}
}
Action::state_ptr FragmentationParseHomologiesAction::performCall()
{
// append all keysets to homology file
if (!params.homology_file.get().empty()) {
const boost::filesystem::path &homology_file = params.homology_file.get();
if (homology_file.string() != "") {
LOG(1, "INFO: Parsing HomologyGraphs from file " << homology_file.string() << ".");
parseHomologiesFromFile(homology_file);
return Action::success;
}
}
return Action::failure;
}
Action::state_ptr FragmentationParseHomologiesAction::performUndo(Action::state_ptr _state) {
return Action::success;
}
Action::state_ptr FragmentationParseHomologiesAction::performRedo(Action::state_ptr _state){
return Action::success;
}
bool FragmentationParseHomologiesAction::canUndo() {
return false;
}
bool FragmentationParseHomologiesAction::shouldUndo() {
return false;
}
/** =========== end of function ====================== */