| [4d4d33] | 1 | /*
 | 
|---|
 | 2 |  * Project: MoleCuilder
 | 
|---|
 | 3 |  * Description: creates and alters molecular systems
 | 
|---|
| [0aa122] | 4 |  * Copyright (C)  2010-2012 University of Bonn. All rights reserved.
 | 
|---|
| [4d4d33] | 5 |  * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
 | 
|---|
 | 6 |  */
 | 
|---|
 | 7 | 
 | 
|---|
 | 8 | /*
 | 
|---|
 | 9 |  * ParseTremoloPotentialsAction.cpp
 | 
|---|
 | 10 |  *
 | 
|---|
 | 11 |  *  Created on: Feb 9, 2011
 | 
|---|
 | 12 |  *      Author: heber
 | 
|---|
 | 13 |  */
 | 
|---|
 | 14 | 
 | 
|---|
 | 15 | // include config.h
 | 
|---|
 | 16 | #ifdef HAVE_CONFIG_H
 | 
|---|
 | 17 | #include <config.h>
 | 
|---|
 | 18 | #endif
 | 
|---|
 | 19 | 
 | 
|---|
 | 20 | #include "CodePatterns/MemDebug.hpp"
 | 
|---|
 | 21 | 
 | 
|---|
 | 22 | #include "Parser/TremoloParser.hpp"
 | 
|---|
 | 23 | #include "Parser/FormatParserStorage.hpp"
 | 
|---|
 | 24 | #include "CodePatterns/Log.hpp"
 | 
|---|
 | 25 | #include "CodePatterns/Verbose.hpp"
 | 
|---|
 | 26 | 
 | 
|---|
 | 27 | #include <iostream>
 | 
|---|
 | 28 | #include <string>
 | 
|---|
 | 29 | 
 | 
|---|
 | 30 | #include <boost/filesystem/fstream.hpp>
 | 
|---|
 | 31 | 
 | 
|---|
 | 32 | #include "ParseTremoloPotentialsAction.hpp"
 | 
|---|
 | 33 | 
 | 
|---|
| [ce7fdc] | 34 | using namespace MoleCuilder;
 | 
|---|
 | 35 | 
 | 
|---|
| [4d4d33] | 36 | // and construct the stuff
 | 
|---|
 | 37 | #include "ParseTremoloPotentialsAction.def"
 | 
|---|
 | 38 | #include "Action_impl_pre.hpp"
 | 
|---|
 | 39 | /** =========== define the function ====================== */
 | 
|---|
 | 40 | Action::state_ptr ParserParseTremoloPotentialsAction::performCall() {
 | 
|---|
 | 41 |   // obtain information
 | 
|---|
 | 42 |   getParametersfromValueStorage();
 | 
|---|
 | 43 | 
 | 
|---|
 | 44 |   boost::filesystem::ifstream test;
 | 
|---|
| [765f16] | 45 |   FormatParser<tremolo> &parser = FormatParserStorage::getInstance().getParser<tremolo>();
 | 
|---|
| [4d4d33] | 46 |   // parsing file if present
 | 
|---|
 | 47 |   if (!boost::filesystem::exists(params.filename)) {
 | 
|---|
| [47d041] | 48 |     LOG(1, "Specified potentials file " << params.filename << " not found.");
 | 
|---|
| [4d4d33] | 49 |     // DONT FAIL: it's just empty we re-create default id-mapping
 | 
|---|
| [765f16] | 50 |     parser.createKnownTypesByIdentity();
 | 
|---|
| [4d4d33] | 51 | 
 | 
|---|
 | 52 |   } else {
 | 
|---|
| [47d041] | 53 |     LOG(1, "Specified potentials file found, parsing ... ");
 | 
|---|
| [4d4d33] | 54 | 
 | 
|---|
 | 55 |     // parse the file
 | 
|---|
 | 56 |     test.open(params.filename);
 | 
|---|
| [765f16] | 57 |     parser.parseKnownTypes(test);
 | 
|---|
| [4d4d33] | 58 |     test.close();
 | 
|---|
 | 59 |   }
 | 
|---|
 | 60 | 
 | 
|---|
 | 61 |   return Action::success;
 | 
|---|
 | 62 | }
 | 
|---|
 | 63 | 
 | 
|---|
 | 64 | Action::state_ptr ParserParseTremoloPotentialsAction::performUndo(Action::state_ptr _state) {
 | 
|---|
 | 65 | //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
 | 
|---|
 | 66 | 
 | 
|---|
 | 67 |   return Action::failure;
 | 
|---|
 | 68 | //  string newName = state->mol->getName();
 | 
|---|
 | 69 | //  state->mol->setName(state->lastName);
 | 
|---|
 | 70 | //
 | 
|---|
 | 71 | //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
 | 
|---|
 | 72 | }
 | 
|---|
 | 73 | 
 | 
|---|
 | 74 | Action::state_ptr ParserParseTremoloPotentialsAction::performRedo(Action::state_ptr _state){
 | 
|---|
 | 75 |   return Action::failure;
 | 
|---|
 | 76 | }
 | 
|---|
 | 77 | 
 | 
|---|
 | 78 | bool ParserParseTremoloPotentialsAction::canUndo() {
 | 
|---|
 | 79 |   return false;
 | 
|---|
 | 80 | }
 | 
|---|
 | 81 | 
 | 
|---|
 | 82 | bool ParserParseTremoloPotentialsAction::shouldUndo() {
 | 
|---|
 | 83 |   return false;
 | 
|---|
 | 84 | }
 | 
|---|
 | 85 | /** =========== end of function ====================== */
 | 
|---|