[b9c847] | 1 | /*
|
---|
| 2 | * SetOutputFormatsAction.cpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: May 8, 2010
|
---|
| 5 | * Author: heber
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #include "Helpers/MemDebug.hpp"
|
---|
| 9 |
|
---|
| 10 | #include "Actions/WorldAction/SetOutputFormatsAction.hpp"
|
---|
| 11 | #include "Parser/ChangeTracker.hpp"
|
---|
| 12 | #include "Parser/FormatParserStorage.hpp"
|
---|
| 13 | #include "log.hpp"
|
---|
| 14 | #include "verbose.hpp"
|
---|
| 15 | #include "World.hpp"
|
---|
| 16 |
|
---|
| 17 | #include <iostream>
|
---|
| 18 | #include <string>
|
---|
| 19 |
|
---|
| 20 | using namespace std;
|
---|
| 21 |
|
---|
| 22 | #include "UIElements/UIFactory.hpp"
|
---|
| 23 | #include "UIElements/Dialog.hpp"
|
---|
[ff22c5] | 24 | #include "UIElements/ValueStorage.hpp"
|
---|
[b9c847] | 25 |
|
---|
| 26 | const char WorldSetOutputFormatsAction::NAME[] = "set-output";
|
---|
| 27 |
|
---|
| 28 | WorldSetOutputFormatsAction::WorldSetOutputFormatsAction() :
|
---|
| 29 | Action(NAME)
|
---|
| 30 | {}
|
---|
| 31 |
|
---|
| 32 | WorldSetOutputFormatsAction::~WorldSetOutputFormatsAction()
|
---|
| 33 | {}
|
---|
| 34 |
|
---|
[ff22c5] | 35 | Dialog* WorldSetOutputFormatsAction::createDialog() {
|
---|
[b9c847] | 36 | Dialog *dialog = UIFactory::getInstance().makeDialog();
|
---|
[ff22c5] | 37 |
|
---|
| 38 | dialog->queryStrings(NAME, ValueStorage::getInstance().getDescription(NAME));
|
---|
| 39 |
|
---|
| 40 | return dialog;
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | Action::state_ptr WorldSetOutputFormatsAction::performCall() {
|
---|
[b9c847] | 44 | vector<std::string> FormatList;
|
---|
| 45 |
|
---|
[ff22c5] | 46 | ValueStorage::getInstance().queryCurrentValue(NAME, FormatList);
|
---|
| 47 |
|
---|
| 48 | for (vector<std::string>::iterator iter = FormatList.begin(); iter != FormatList.end(); ++iter) {
|
---|
| 49 | if (*iter == "mpqc") {
|
---|
| 50 | FormatParserStorage::getInstance().addMpqc();
|
---|
| 51 | DoLog(0) && (Log() << Verbose(0) << "Adding mpqc type to output." << endl);
|
---|
| 52 | } else if (*iter == "pcp") {
|
---|
| 53 | FormatParserStorage::getInstance().addPcp();
|
---|
| 54 | DoLog(0) && (Log() << Verbose(0) << "Adding pcp type to output." << endl);
|
---|
| 55 | } else if (*iter == "tremolo") {
|
---|
| 56 | FormatParserStorage::getInstance().addTremolo();
|
---|
| 57 | DoLog(0) && (Log() << Verbose(0) << "Adding tremolo type to output." << endl);
|
---|
| 58 | } else if (*iter == "xyz") {
|
---|
| 59 | FormatParserStorage::getInstance().addXyz();
|
---|
| 60 | DoLog(0) && (Log() << Verbose(0) << "Adding xyz type to output." << endl);
|
---|
| 61 | } else {
|
---|
[dde125] | 62 | DoeLog(1) && (eLog() << Verbose(1) << "Unknown format:" << *iter << endl);
|
---|
[b9c847] | 63 | }
|
---|
| 64 | }
|
---|
[ff22c5] | 65 | ChangeTracker::getInstance().saveStatus();
|
---|
| 66 | return Action::success;
|
---|
[b9c847] | 67 | }
|
---|
| 68 |
|
---|
| 69 | Action::state_ptr WorldSetOutputFormatsAction::performUndo(Action::state_ptr _state) {
|
---|
| 70 | // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
|
---|
| 71 |
|
---|
| 72 | return Action::failure;
|
---|
| 73 | // string newName = state->mol->getName();
|
---|
| 74 | // state->mol->setName(state->lastName);
|
---|
| 75 | //
|
---|
| 76 | // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 | Action::state_ptr WorldSetOutputFormatsAction::performRedo(Action::state_ptr _state){
|
---|
| 80 | return Action::failure;
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | bool WorldSetOutputFormatsAction::canUndo() {
|
---|
| 84 | return false;
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | bool WorldSetOutputFormatsAction::shouldUndo() {
|
---|
| 88 | return false;
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 | const string WorldSetOutputFormatsAction::getName() {
|
---|
| 92 | return NAME;
|
---|
| 93 | }
|
---|