1 | /*
|
---|
2 | * Project: MoleCuilder
|
---|
3 | * Description: creates and alters molecular systems
|
---|
4 | * Copyright (C) 2010 University of Bonn. All rights reserved.
|
---|
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 | using namespace std;
|
---|
33 |
|
---|
34 | #include "ParseTremoloPotentialsAction.hpp"
|
---|
35 |
|
---|
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;
|
---|
45 | TremoloParser &tremolo = FormatParserStorage::getInstance().getTremolo();
|
---|
46 | // parsing file if present
|
---|
47 | if (!boost::filesystem::exists(params.filename)) {
|
---|
48 | DoLog(1) && (Log() << Verbose(1) << "Specified potentials file " << params.filename << " not found." << endl);
|
---|
49 | // DONT FAIL: it's just empty we re-create default id-mapping
|
---|
50 | tremolo.createKnownTypesByIdentity();
|
---|
51 |
|
---|
52 | } else {
|
---|
53 | DoLog(1) && (Log() << Verbose(1) << "Specified potentials file found, parsing ... " << std::endl);
|
---|
54 |
|
---|
55 | // parse the file
|
---|
56 | test.open(params.filename);
|
---|
57 | TremoloParser &tremolo = FormatParserStorage::getInstance().getTremolo();
|
---|
58 | tremolo.parseKnownTypes(test);
|
---|
59 | test.close();
|
---|
60 | }
|
---|
61 |
|
---|
62 | return Action::success;
|
---|
63 | }
|
---|
64 |
|
---|
65 | Action::state_ptr ParserParseTremoloPotentialsAction::performUndo(Action::state_ptr _state) {
|
---|
66 | // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
|
---|
67 |
|
---|
68 | return Action::failure;
|
---|
69 | // string newName = state->mol->getName();
|
---|
70 | // state->mol->setName(state->lastName);
|
---|
71 | //
|
---|
72 | // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
|
---|
73 | }
|
---|
74 |
|
---|
75 | Action::state_ptr ParserParseTremoloPotentialsAction::performRedo(Action::state_ptr _state){
|
---|
76 | return Action::failure;
|
---|
77 | }
|
---|
78 |
|
---|
79 | bool ParserParseTremoloPotentialsAction::canUndo() {
|
---|
80 | return false;
|
---|
81 | }
|
---|
82 |
|
---|
83 | bool ParserParseTremoloPotentialsAction::shouldUndo() {
|
---|
84 | return false;
|
---|
85 | }
|
---|
86 | /** =========== end of function ====================== */
|
---|