| [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 |  * ElementDbAction.cpp
 | 
|---|
 | 10 |  *
 | 
|---|
 | 11 |  *  Created on: May 9, 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"
 | 
|---|
| [97ebf8] | 24 | #include "periodentafel.hpp"
 | 
|---|
| [ad011c] | 25 | #include "CodePatterns/Verbose.hpp"
 | 
|---|
| [97ebf8] | 26 | #include "World.hpp"
 | 
|---|
 | 27 | 
 | 
|---|
 | 28 | #include <iostream>
 | 
|---|
 | 29 | #include <string>
 | 
|---|
 | 30 | 
 | 
|---|
 | 31 | using namespace std;
 | 
|---|
 | 32 | 
 | 
|---|
| [1fd675] | 33 | #include "Actions/CommandAction/ElementDbAction.hpp"
 | 
|---|
| [a12e8e] | 34 | 
 | 
|---|
| [1fd675] | 35 | // and construct the stuff
 | 
|---|
 | 36 | #include "ElementDbAction.def"
 | 
|---|
 | 37 | #include "Action_impl_pre.hpp"
 | 
|---|
 | 38 | /** =========== define the function ====================== */
 | 
|---|
| [53d01c] | 39 | Action::state_ptr CommandElementDbAction::performCall() {
 | 
|---|
| [97ebf8] | 40 |   ostringstream usage;
 | 
|---|
| [1fd675] | 41 | 
 | 
|---|
 | 42 |   // obtain information
 | 
|---|
 | 43 |   getParametersfromValueStorage();
 | 
|---|
| [97ebf8] | 44 | 
 | 
|---|
 | 45 |   // get the path
 | 
|---|
 | 46 |   // TODO: Make databasepath a std::string
 | 
|---|
 | 47 |   config *configuration = World::getInstance().getConfig();
 | 
|---|
| [e4afb4] | 48 |   strcpy(configuration->databasepath, params.databasepath.branch_path().string().c_str());
 | 
|---|
| [97ebf8] | 49 | 
 | 
|---|
 | 50 |   // load table
 | 
|---|
 | 51 |   periodentafel *periode = World::getInstance().getPeriode();
 | 
|---|
 | 52 |   if (periode->LoadPeriodentafel(configuration->databasepath)) {
 | 
|---|
 | 53 |     DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl);
 | 
|---|
 | 54 |     //periode->Output();
 | 
|---|
 | 55 |     return Action::success;
 | 
|---|
 | 56 |   } else {
 | 
|---|
 | 57 |     DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl);
 | 
|---|
 | 58 |     return Action::failure;
 | 
|---|
 | 59 |   }
 | 
|---|
 | 60 | 
 | 
|---|
 | 61 | }
 | 
|---|
 | 62 | 
 | 
|---|
| [53d01c] | 63 | Action::state_ptr CommandElementDbAction::performUndo(Action::state_ptr _state) {
 | 
|---|
| [97ebf8] | 64 | //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
 | 
|---|
 | 65 | 
 | 
|---|
 | 66 |   return Action::failure;
 | 
|---|
 | 67 | //  string newName = state->mol->getName();
 | 
|---|
 | 68 | //  state->mol->setName(state->lastName);
 | 
|---|
 | 69 | //
 | 
|---|
 | 70 | //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
 | 
|---|
 | 71 | }
 | 
|---|
 | 72 | 
 | 
|---|
| [53d01c] | 73 | Action::state_ptr CommandElementDbAction::performRedo(Action::state_ptr _state){
 | 
|---|
| [97ebf8] | 74 |   return Action::failure;
 | 
|---|
 | 75 | }
 | 
|---|
 | 76 | 
 | 
|---|
| [53d01c] | 77 | bool CommandElementDbAction::canUndo() {
 | 
|---|
| [97ebf8] | 78 |   return false;
 | 
|---|
 | 79 | }
 | 
|---|
 | 80 | 
 | 
|---|
| [53d01c] | 81 | bool CommandElementDbAction::shouldUndo() {
 | 
|---|
| [97ebf8] | 82 |   return false;
 | 
|---|
 | 83 | }
 | 
|---|
| [1fd675] | 84 | /** =========== end of function ====================== */
 | 
|---|