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 | * SetGaussianBasisAction.cpp
|
---|
10 | *
|
---|
11 | * Created on: May 8, 2010
|
---|
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 "config.hpp"
|
---|
23 | #include "CodePatterns/Log.hpp"
|
---|
24 | #include "CodePatterns/Verbose.hpp"
|
---|
25 | #include "World.hpp"
|
---|
26 |
|
---|
27 | #include <iostream>
|
---|
28 | #include <string>
|
---|
29 |
|
---|
30 | using namespace std;
|
---|
31 |
|
---|
32 | #include "Actions/WorldAction/SetGaussianBasisAction.hpp"
|
---|
33 |
|
---|
34 | // and construct the stuff
|
---|
35 | #include "SetGaussianBasisAction.def"
|
---|
36 | #include "Action_impl_pre.hpp"
|
---|
37 | /** =========== define the function ====================== */
|
---|
38 | Action::state_ptr WorldSetGaussianBasisAction::performCall() {
|
---|
39 | config *configuration = World::getInstance().getConfig();
|
---|
40 |
|
---|
41 | string lastname = configuration->basis;
|
---|
42 | // obtain information
|
---|
43 | getParametersfromValueStorage();
|
---|
44 | configuration->basis = params.newname;
|
---|
45 |
|
---|
46 | DoLog(1) && (Log() << Verbose(1) << "Setting MPQC basis to " << configuration->basis << "." << endl);
|
---|
47 | return Action::state_ptr(new WorldSetGaussianBasisState(lastname, params));
|
---|
48 | }
|
---|
49 |
|
---|
50 | Action::state_ptr WorldSetGaussianBasisAction::performUndo(Action::state_ptr _state) {
|
---|
51 | WorldSetGaussianBasisState *state = assert_cast<WorldSetGaussianBasisState*>(_state.get());
|
---|
52 |
|
---|
53 | config *configuration = World::getInstance().getConfig();
|
---|
54 | configuration->basis = state->lastname;
|
---|
55 |
|
---|
56 | return Action::state_ptr(_state);
|
---|
57 | }
|
---|
58 |
|
---|
59 | Action::state_ptr WorldSetGaussianBasisAction::performRedo(Action::state_ptr _state){
|
---|
60 | WorldSetGaussianBasisState *state = assert_cast<WorldSetGaussianBasisState*>(_state.get());
|
---|
61 |
|
---|
62 | config *configuration = World::getInstance().getConfig();
|
---|
63 | configuration->basis = state->params.newname;
|
---|
64 |
|
---|
65 | return Action::state_ptr(_state);
|
---|
66 | }
|
---|
67 |
|
---|
68 | bool WorldSetGaussianBasisAction::canUndo() {
|
---|
69 | return true;
|
---|
70 | }
|
---|
71 |
|
---|
72 | bool WorldSetGaussianBasisAction::shouldUndo() {
|
---|
73 | return true;
|
---|
74 | }
|
---|
75 | /** =========== end of function ====================== */
|
---|