| 1 | /*
|
|---|
| 2 | * Project: MoleCuilder
|
|---|
| 3 | * Description: creates and alters molecular systems
|
|---|
| 4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
|---|
| 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | /*
|
|---|
| 9 | * ElementsCommandLineQuery.cpp
|
|---|
| 10 | *
|
|---|
| 11 | * Created on: Oct 25, 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 "CommandLineUI/Query/CommandLineQuery.hpp"
|
|---|
| 23 | #include "CommandLineUI/CommandLineParser.hpp"
|
|---|
| 24 | #include "CodePatterns/Log.hpp"
|
|---|
| 25 | #include "CodePatterns/Verbose.hpp"
|
|---|
| 26 | #include "Element/element.hpp"
|
|---|
| 27 | #include "Element/periodentafel.hpp"
|
|---|
| 28 | #include "World.hpp"
|
|---|
| 29 |
|
|---|
| 30 | CommandLineDialog::ElementsCommandLineQuery::ElementsCommandLineQuery(Parameter<std::vector<const element*> > &_param, std::string title, std::string _description) :
|
|---|
| 31 | Dialog::TQuery<std::vector<const element *> >(_param, title, _description)
|
|---|
| 32 | {}
|
|---|
| 33 |
|
|---|
| 34 | CommandLineDialog::ElementsCommandLineQuery::~ElementsCommandLineQuery()
|
|---|
| 35 | {}
|
|---|
| 36 |
|
|---|
| 37 | bool CommandLineDialog::ElementsCommandLineQuery::handle() {
|
|---|
| 38 | // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector?
|
|---|
| 39 | periodentafel *periode = World::getInstance().getPeriode();
|
|---|
| 40 | if (CommandLineParser::getInstance().vm.count(getTitle())) {
|
|---|
| 41 | vector<int> AllElements = CommandLineParser::getInstance().vm[getTitle()].as< vector<int> >();
|
|---|
| 42 | const element *temp_element;
|
|---|
| 43 | for (vector<int>::iterator ZRunner = AllElements.begin(); ZRunner != AllElements.end(); ++ZRunner) {
|
|---|
| 44 | temp_element = periode->FindElement(*ZRunner);
|
|---|
| 45 | ASSERT(temp_element != NULL, "Invalid element specified in ElementCommandLineQuery");
|
|---|
| 46 | temp.push_back(temp_element);
|
|---|
| 47 | }
|
|---|
| 48 | return true;
|
|---|
| 49 | } else {
|
|---|
| 50 | ELOG(1, "CommandLineUI parsing error: Missing elements for " << getTitle() << ".");
|
|---|
| 51 | return false;
|
|---|
| 52 | }
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|