[bcf653] | 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 |
|
---|
[97ebf8] | 8 | /*
|
---|
| 9 | * SetGaussianBasisAction.cpp
|
---|
| 10 | *
|
---|
| 11 | * Created on: May 8, 2010
|
---|
| 12 | * Author: heber
|
---|
| 13 | */
|
---|
| 14 |
|
---|
[bf3817] | 15 | // include config.h
|
---|
| 16 | #ifdef HAVE_CONFIG_H
|
---|
| 17 | #include <config.h>
|
---|
| 18 | #endif
|
---|
| 19 |
|
---|
[ad011c] | 20 | #include "CodePatterns/MemDebug.hpp"
|
---|
[112b09] | 21 |
|
---|
[97ebf8] | 22 | #include "config.hpp"
|
---|
[ad011c] | 23 | #include "CodePatterns/Log.hpp"
|
---|
| 24 | #include "CodePatterns/Verbose.hpp"
|
---|
[97ebf8] | 25 | #include "World.hpp"
|
---|
| 26 |
|
---|
| 27 | #include <iostream>
|
---|
| 28 | #include <string>
|
---|
| 29 |
|
---|
| 30 | using namespace std;
|
---|
| 31 |
|
---|
[1fd675] | 32 | #include "Actions/WorldAction/SetGaussianBasisAction.hpp"
|
---|
[aee3b1] | 33 |
|
---|
[1fd675] | 34 | // and construct the stuff
|
---|
| 35 | #include "SetGaussianBasisAction.def"
|
---|
| 36 | #include "Action_impl_pre.hpp"
|
---|
| 37 | /** =========== define the function ====================== */
|
---|
[aee3b1] | 38 | Action::state_ptr WorldSetGaussianBasisAction::performCall() {
|
---|
[bdaacd] | 39 | config *configuration = World::getInstance().getConfig();
|
---|
[aee3b1] | 40 |
|
---|
| 41 | string lastname = configuration->basis;
|
---|
[1fd675] | 42 | // obtain information
|
---|
| 43 | getParametersfromValueStorage();
|
---|
| 44 | configuration->basis = params.newname;
|
---|
[aee3b1] | 45 |
|
---|
| 46 | DoLog(1) && (Log() << Verbose(1) << "Setting MPQC basis to " << configuration->basis << "." << endl);
|
---|
[1fd675] | 47 | return Action::state_ptr(new WorldSetGaussianBasisState(lastname, params));
|
---|
[97ebf8] | 48 | }
|
---|
| 49 |
|
---|
| 50 | Action::state_ptr WorldSetGaussianBasisAction::performUndo(Action::state_ptr _state) {
|
---|
[aee3b1] | 51 | WorldSetGaussianBasisState *state = assert_cast<WorldSetGaussianBasisState*>(_state.get());
|
---|
| 52 |
|
---|
| 53 | config *configuration = World::getInstance().getConfig();
|
---|
[1fd675] | 54 | configuration->basis = state->lastname;
|
---|
[97ebf8] | 55 |
|
---|
[1fd675] | 56 | return Action::state_ptr(_state);
|
---|
[97ebf8] | 57 | }
|
---|
| 58 |
|
---|
| 59 | Action::state_ptr WorldSetGaussianBasisAction::performRedo(Action::state_ptr _state){
|
---|
[1fd675] | 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);
|
---|
[97ebf8] | 66 | }
|
---|
| 67 |
|
---|
| 68 | bool WorldSetGaussianBasisAction::canUndo() {
|
---|
[aee3b1] | 69 | return true;
|
---|
[97ebf8] | 70 | }
|
---|
| 71 |
|
---|
| 72 | bool WorldSetGaussianBasisAction::shouldUndo() {
|
---|
[aee3b1] | 73 | return true;
|
---|
[97ebf8] | 74 | }
|
---|
[1fd675] | 75 | /** =========== end of function ====================== */
|
---|