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 | * CommandLineDialog.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 "Helpers/MemDebug.hpp"
|
---|
21 |
|
---|
22 | #include <iostream>
|
---|
23 | #include <vector>
|
---|
24 |
|
---|
25 | #include <Descriptors/AtomDescriptor.hpp>
|
---|
26 | #include <Descriptors/AtomIdDescriptor.hpp>
|
---|
27 | #include <Descriptors/MoleculeDescriptor.hpp>
|
---|
28 | #include <Descriptors/MoleculeIdDescriptor.hpp>
|
---|
29 | #include "CommandLineUI/CommandLineDialog.hpp"
|
---|
30 |
|
---|
31 | #include "Actions/Values.hpp"
|
---|
32 |
|
---|
33 | #include "element.hpp"
|
---|
34 | #include "periodentafel.hpp"
|
---|
35 | #include "CommandLineParser.hpp"
|
---|
36 | #include "defs.hpp"
|
---|
37 | #include "Helpers/Log.hpp"
|
---|
38 | #include "LinearAlgebra/Matrix.hpp"
|
---|
39 | #include "periodentafel.hpp"
|
---|
40 | #include "Helpers/Verbose.hpp"
|
---|
41 | #include "World.hpp"
|
---|
42 | #include "Box.hpp"
|
---|
43 |
|
---|
44 | #include "atom.hpp"
|
---|
45 | #include "element.hpp"
|
---|
46 | #include "molecule.hpp"
|
---|
47 | #include "LinearAlgebra/Vector.hpp"
|
---|
48 |
|
---|
49 | using namespace std;
|
---|
50 |
|
---|
51 |
|
---|
52 | CommandLineDialog::CommandLineDialog()
|
---|
53 | {
|
---|
54 | }
|
---|
55 |
|
---|
56 | CommandLineDialog::~CommandLineDialog()
|
---|
57 | {
|
---|
58 | }
|
---|
59 |
|
---|
60 |
|
---|
61 | void CommandLineDialog::queryEmpty(const char* title, string _description){
|
---|
62 | registerQuery(new EmptyCommandLineQuery(title, _description));
|
---|
63 | }
|
---|
64 |
|
---|
65 | void CommandLineDialog::queryInt(const char* title, string _description){
|
---|
66 | registerQuery(new IntCommandLineQuery(title, _description));
|
---|
67 | }
|
---|
68 |
|
---|
69 | void CommandLineDialog::queryInts(const char* title, string _description){
|
---|
70 | registerQuery(new IntsCommandLineQuery(title, _description));
|
---|
71 | }
|
---|
72 |
|
---|
73 | void CommandLineDialog::queryBoolean(const char* title, string _description){
|
---|
74 | registerQuery(new BooleanCommandLineQuery(title, _description));
|
---|
75 | }
|
---|
76 |
|
---|
77 | void CommandLineDialog::queryDouble(const char* title, string _description){
|
---|
78 | registerQuery(new DoubleCommandLineQuery(title, _description));
|
---|
79 | }
|
---|
80 |
|
---|
81 | void CommandLineDialog::queryDoubles(const char* title, string _description){
|
---|
82 | registerQuery(new DoublesCommandLineQuery(title, _description));
|
---|
83 | }
|
---|
84 |
|
---|
85 | void CommandLineDialog::queryString(const char* title, string _description){
|
---|
86 | registerQuery(new StringCommandLineQuery(title, _description));
|
---|
87 | }
|
---|
88 |
|
---|
89 | void CommandLineDialog::queryStrings(const char* title, string _description){
|
---|
90 | registerQuery(new StringsCommandLineQuery(title, _description));
|
---|
91 | }
|
---|
92 |
|
---|
93 | void CommandLineDialog::queryAtom(const char* title, string _description) {
|
---|
94 | registerQuery(new AtomCommandLineQuery(title, _description));
|
---|
95 | }
|
---|
96 |
|
---|
97 | void CommandLineDialog::queryAtoms(const char* title, string _description) {
|
---|
98 | registerQuery(new AtomsCommandLineQuery(title, _description));
|
---|
99 | }
|
---|
100 |
|
---|
101 | void CommandLineDialog::queryMolecule(const char* title, string _description) {
|
---|
102 | registerQuery(new MoleculeCommandLineQuery(title, _description));
|
---|
103 | }
|
---|
104 |
|
---|
105 | void CommandLineDialog::queryMolecules(const char* title, string _description) {
|
---|
106 | registerQuery(new MoleculesCommandLineQuery(title, _description));
|
---|
107 | }
|
---|
108 |
|
---|
109 | void CommandLineDialog::queryVector(const char* title, bool check, string _description) {
|
---|
110 | registerQuery(new VectorCommandLineQuery(title,check, _description));
|
---|
111 | }
|
---|
112 |
|
---|
113 | void CommandLineDialog::queryVectors(const char* title, bool check, string _description) {
|
---|
114 | registerQuery(new VectorsCommandLineQuery(title,check, _description));
|
---|
115 | }
|
---|
116 |
|
---|
117 | void CommandLineDialog::queryBox(const char* title, string _description) {
|
---|
118 | registerQuery(new BoxCommandLineQuery(title,_description));
|
---|
119 | }
|
---|
120 |
|
---|
121 | void CommandLineDialog::queryElement(const char* title, string _description){
|
---|
122 | registerQuery(new ElementCommandLineQuery(title, _description));
|
---|
123 | }
|
---|
124 |
|
---|
125 | void CommandLineDialog::queryElements(const char* title, string _description){
|
---|
126 | registerQuery(new ElementsCommandLineQuery(title, _description));
|
---|
127 | }
|
---|
128 |
|
---|
129 | void CommandLineDialog::queryFile(const char* title, string _description){
|
---|
130 | registerQuery(new FileCommandLineQuery(title, _description));
|
---|
131 | }
|
---|
132 |
|
---|
133 | /************************** Query Infrastructure ************************/
|
---|
134 |
|
---|
135 | CommandLineDialog::EmptyCommandLineQuery::EmptyCommandLineQuery(string title, string _description) :
|
---|
136 | Dialog::EmptyQuery(title, _description)
|
---|
137 | {}
|
---|
138 |
|
---|
139 | CommandLineDialog::EmptyCommandLineQuery::~EmptyCommandLineQuery() {}
|
---|
140 |
|
---|
141 | bool CommandLineDialog::EmptyCommandLineQuery::handle() {
|
---|
142 | cout << "Message of " << getTitle() << ":\n" << getDescription() << "\n";
|
---|
143 | return true;
|
---|
144 | }
|
---|
145 |
|
---|
146 | CommandLineDialog::IntCommandLineQuery::IntCommandLineQuery(string title, string _description) :
|
---|
147 | Dialog::IntQuery(title, _description)
|
---|
148 | {}
|
---|
149 |
|
---|
150 | CommandLineDialog::IntCommandLineQuery::~IntCommandLineQuery() {}
|
---|
151 |
|
---|
152 | bool CommandLineDialog::IntCommandLineQuery::handle() {
|
---|
153 | if (CommandLineParser::getInstance().vm.count(getTitle())) {
|
---|
154 | tmp = CommandLineParser::getInstance().vm[getTitle()].as<int>();
|
---|
155 | return true;
|
---|
156 | } else {
|
---|
157 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing integer for " << getTitle() << "." << endl);
|
---|
158 | return false;
|
---|
159 | }
|
---|
160 | }
|
---|
161 |
|
---|
162 | CommandLineDialog::IntsCommandLineQuery::IntsCommandLineQuery(string title, string _description) :
|
---|
163 | Dialog::IntsQuery(title, _description)
|
---|
164 | {}
|
---|
165 |
|
---|
166 | CommandLineDialog::IntsCommandLineQuery::~IntsCommandLineQuery() {}
|
---|
167 |
|
---|
168 | bool CommandLineDialog::IntsCommandLineQuery::handle() {
|
---|
169 | if (CommandLineParser::getInstance().vm.count(getTitle())) {
|
---|
170 | tmp = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >();
|
---|
171 | return true;
|
---|
172 | } else {
|
---|
173 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing integers for " << getTitle() << "." << endl);
|
---|
174 | return false;
|
---|
175 | }
|
---|
176 | }
|
---|
177 |
|
---|
178 | CommandLineDialog::BooleanCommandLineQuery::BooleanCommandLineQuery(string title, string _description) :
|
---|
179 | Dialog::BooleanQuery(title, _description)
|
---|
180 | {}
|
---|
181 |
|
---|
182 | CommandLineDialog::BooleanCommandLineQuery::~BooleanCommandLineQuery() {}
|
---|
183 |
|
---|
184 | bool CommandLineDialog::BooleanCommandLineQuery::handle() {
|
---|
185 | if (CommandLineParser::getInstance().vm.count(getTitle())) {
|
---|
186 | tmp = CommandLineParser::getInstance().vm[getTitle()].as<bool>();
|
---|
187 | return true;
|
---|
188 | } else {
|
---|
189 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing boolean for " << getTitle() << "." << endl);
|
---|
190 | return false;
|
---|
191 | }
|
---|
192 | }
|
---|
193 |
|
---|
194 | CommandLineDialog::StringCommandLineQuery::StringCommandLineQuery(string title, string _description) :
|
---|
195 | Dialog::StringQuery(title, _description)
|
---|
196 | {}
|
---|
197 |
|
---|
198 | CommandLineDialog::StringCommandLineQuery::~StringCommandLineQuery() {}
|
---|
199 |
|
---|
200 | bool CommandLineDialog::StringCommandLineQuery::handle() {
|
---|
201 | if (CommandLineParser::getInstance().vm.count(getTitle())) {
|
---|
202 | tmp = CommandLineParser::getInstance().vm[getTitle()].as<string>();
|
---|
203 | return true;
|
---|
204 | } else {
|
---|
205 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing string for " << getTitle() << "." << endl);
|
---|
206 | return false;
|
---|
207 | }
|
---|
208 | }
|
---|
209 |
|
---|
210 | CommandLineDialog::StringsCommandLineQuery::StringsCommandLineQuery(string title, string _description) :
|
---|
211 | Dialog::StringsQuery(title, _description)
|
---|
212 | {}
|
---|
213 |
|
---|
214 | CommandLineDialog::StringsCommandLineQuery::~StringsCommandLineQuery() {}
|
---|
215 |
|
---|
216 | bool CommandLineDialog::StringsCommandLineQuery::handle() {
|
---|
217 | if (CommandLineParser::getInstance().vm.count(getTitle())) {
|
---|
218 | tmp = CommandLineParser::getInstance().vm[getTitle()].as< vector<string> >();
|
---|
219 | return true;
|
---|
220 | } else {
|
---|
221 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing strings for " << getTitle() << "." << endl);
|
---|
222 | return false;
|
---|
223 | }
|
---|
224 | }
|
---|
225 |
|
---|
226 | CommandLineDialog::DoubleCommandLineQuery::DoubleCommandLineQuery(string title, string _description) :
|
---|
227 | Dialog::DoubleQuery(title, _description)
|
---|
228 | {}
|
---|
229 |
|
---|
230 | CommandLineDialog::DoubleCommandLineQuery::~DoubleCommandLineQuery() {}
|
---|
231 |
|
---|
232 | bool CommandLineDialog::DoubleCommandLineQuery::handle() {
|
---|
233 | if (CommandLineParser::getInstance().vm.count(getTitle())) {
|
---|
234 | tmp = CommandLineParser::getInstance().vm[getTitle()].as<double>();
|
---|
235 | return true;
|
---|
236 | } else {
|
---|
237 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing double for " << getTitle() << "." << endl);
|
---|
238 | return false;
|
---|
239 | }
|
---|
240 | }
|
---|
241 |
|
---|
242 | CommandLineDialog::DoublesCommandLineQuery::DoublesCommandLineQuery(string title, string _description) :
|
---|
243 | Dialog::DoublesQuery(title, _description)
|
---|
244 | {}
|
---|
245 |
|
---|
246 | CommandLineDialog::DoublesCommandLineQuery::~DoublesCommandLineQuery() {}
|
---|
247 |
|
---|
248 | bool CommandLineDialog::DoublesCommandLineQuery::handle() {
|
---|
249 | if (CommandLineParser::getInstance().vm.count(getTitle())) {
|
---|
250 | tmp = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<double> >();
|
---|
251 | return true;
|
---|
252 | } else {
|
---|
253 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing doubles for " << getTitle() << "." << endl);
|
---|
254 | return false;
|
---|
255 | }
|
---|
256 | }
|
---|
257 |
|
---|
258 | CommandLineDialog::AtomCommandLineQuery::AtomCommandLineQuery(string title, string _description) :
|
---|
259 | Dialog::AtomQuery(title, _description)
|
---|
260 | {}
|
---|
261 |
|
---|
262 | CommandLineDialog::AtomCommandLineQuery::~AtomCommandLineQuery() {}
|
---|
263 |
|
---|
264 | bool CommandLineDialog::AtomCommandLineQuery::handle() {
|
---|
265 | int IdxOfAtom = -1;
|
---|
266 | if (CommandLineParser::getInstance().vm.count(getTitle())) {
|
---|
267 | IdxOfAtom = CommandLineParser::getInstance().vm[getTitle()].as<int>();
|
---|
268 | tmp = World::getInstance().getAtom(AtomById(IdxOfAtom));
|
---|
269 | return true;
|
---|
270 | } else {
|
---|
271 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing atom for " << getTitle() << "." << endl);
|
---|
272 | return false;
|
---|
273 | }
|
---|
274 | }
|
---|
275 |
|
---|
276 | CommandLineDialog::AtomsCommandLineQuery::AtomsCommandLineQuery(string title, string _description) :
|
---|
277 | Dialog::AtomsQuery(title, _description)
|
---|
278 | {}
|
---|
279 |
|
---|
280 | CommandLineDialog::AtomsCommandLineQuery::~AtomsCommandLineQuery() {}
|
---|
281 |
|
---|
282 | bool CommandLineDialog::AtomsCommandLineQuery::handle() {
|
---|
283 | std::vector<int> IdxOfAtom;
|
---|
284 | if (CommandLineParser::getInstance().vm.count(getTitle())) {
|
---|
285 | IdxOfAtom = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >();
|
---|
286 | for (std::vector<int>::iterator iter = IdxOfAtom.begin(); iter != IdxOfAtom.end(); ++iter) {
|
---|
287 | temp = World::getInstance().getAtom(AtomById(*iter));
|
---|
288 | if (temp)
|
---|
289 | tmp.push_back(temp);
|
---|
290 | }
|
---|
291 | return true;
|
---|
292 | } else {
|
---|
293 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing atoms for " << getTitle() << "." << endl);
|
---|
294 | return false;
|
---|
295 | }
|
---|
296 | }
|
---|
297 |
|
---|
298 | CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, string _description) :
|
---|
299 | Dialog::MoleculeQuery(title, _description)
|
---|
300 | {}
|
---|
301 |
|
---|
302 | CommandLineDialog::MoleculeCommandLineQuery::~MoleculeCommandLineQuery() {}
|
---|
303 |
|
---|
304 | bool CommandLineDialog::MoleculeCommandLineQuery::handle() {
|
---|
305 | int IdxOfMol = -1;
|
---|
306 | if (CommandLineParser::getInstance().vm.count(getTitle())) {
|
---|
307 | IdxOfMol = CommandLineParser::getInstance().vm[getTitle()].as<int>();
|
---|
308 | tmp = World::getInstance().getMolecule(MoleculeById(IdxOfMol));
|
---|
309 | return true;
|
---|
310 | } else {
|
---|
311 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing molecule for " << getTitle() << "." << endl);
|
---|
312 | return false;
|
---|
313 | }
|
---|
314 | }
|
---|
315 |
|
---|
316 | CommandLineDialog::MoleculesCommandLineQuery::MoleculesCommandLineQuery(string title, string _description) :
|
---|
317 | Dialog::MoleculesQuery(title, _description)
|
---|
318 | {}
|
---|
319 |
|
---|
320 | CommandLineDialog::MoleculesCommandLineQuery::~MoleculesCommandLineQuery() {}
|
---|
321 |
|
---|
322 | bool CommandLineDialog::MoleculesCommandLineQuery::handle() {
|
---|
323 | std::vector<int> IdxOfMol;
|
---|
324 | if (CommandLineParser::getInstance().vm.count(getTitle())) {
|
---|
325 | IdxOfMol = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<int> >();
|
---|
326 | for (std::vector<int>::iterator iter = IdxOfMol.begin(); iter != IdxOfMol.end(); ++iter) {
|
---|
327 | temp = World::getInstance().getMolecule(MoleculeById(*iter));
|
---|
328 | if (temp)
|
---|
329 | tmp.push_back(temp);
|
---|
330 | }
|
---|
331 | return true;
|
---|
332 | } else {
|
---|
333 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing molecules for " << getTitle() << "." << endl);
|
---|
334 | return false;
|
---|
335 | }
|
---|
336 | }
|
---|
337 |
|
---|
338 | CommandLineDialog::VectorCommandLineQuery::VectorCommandLineQuery(string title, bool _check, string _description) :
|
---|
339 | Dialog::VectorQuery(title,_check, _description)
|
---|
340 | {}
|
---|
341 |
|
---|
342 | CommandLineDialog::VectorCommandLineQuery::~VectorCommandLineQuery()
|
---|
343 | {}
|
---|
344 |
|
---|
345 | bool CommandLineDialog::VectorCommandLineQuery::handle() {
|
---|
346 | VectorValue temp;
|
---|
347 | if (CommandLineParser::getInstance().vm.count(getTitle())) {
|
---|
348 | temp = CommandLineParser::getInstance().vm[getTitle()].as< VectorValue >();
|
---|
349 | tmp[0] = temp.x;
|
---|
350 | tmp[1] = temp.y;
|
---|
351 | tmp[2] = temp.z;
|
---|
352 | if ((check) && (!World::getInstance().getDomain().isInside(tmp))) {
|
---|
353 | DoeLog(1) && (eLog() << Verbose(1) << "Vector " << tmp << " would be outside of box domain." << endl);
|
---|
354 | return false;
|
---|
355 | }
|
---|
356 | return true;
|
---|
357 | } else {
|
---|
358 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing vector for " << getTitle() << "." << endl);
|
---|
359 | return false;
|
---|
360 | }
|
---|
361 | }
|
---|
362 |
|
---|
363 | CommandLineDialog::VectorsCommandLineQuery::VectorsCommandLineQuery(string title, bool _check, string _description) :
|
---|
364 | Dialog::VectorsQuery(title,_check, _description)
|
---|
365 | {}
|
---|
366 |
|
---|
367 | CommandLineDialog::VectorsCommandLineQuery::~VectorsCommandLineQuery()
|
---|
368 | {}
|
---|
369 |
|
---|
370 | bool CommandLineDialog::VectorsCommandLineQuery::handle() {
|
---|
371 | std::vector<VectorValue> temporary;
|
---|
372 | if (CommandLineParser::getInstance().vm.count(getTitle())) {
|
---|
373 | temporary = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<VectorValue> >();
|
---|
374 | for(std::vector<VectorValue>::iterator iter = temporary.begin(); iter != temporary.end(); ++iter) {
|
---|
375 | temp[0] = (*iter).x;
|
---|
376 | temp[1] = (*iter).y;
|
---|
377 | temp[2] = (*iter).z;
|
---|
378 | if ((!check) || (World::getInstance().getDomain().isInside(temp)))
|
---|
379 | tmp.push_back(temp);
|
---|
380 | else
|
---|
381 | DoeLog(1) && (eLog() << Verbose(1) << "Vector " << temp << " would be outside of box domain." << endl);
|
---|
382 | }
|
---|
383 | return true;
|
---|
384 | } else {
|
---|
385 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing vectors for " << getTitle() << "." << endl);
|
---|
386 | return false;
|
---|
387 | }
|
---|
388 | }
|
---|
389 |
|
---|
390 | CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, string _description) :
|
---|
391 | Dialog::BoxQuery(title, _description)
|
---|
392 | {}
|
---|
393 |
|
---|
394 | CommandLineDialog::BoxCommandLineQuery::~BoxCommandLineQuery()
|
---|
395 | {}
|
---|
396 |
|
---|
397 | bool CommandLineDialog::BoxCommandLineQuery::handle() {
|
---|
398 | BoxValue temp;
|
---|
399 | if (CommandLineParser::getInstance().vm.count(getTitle())) {
|
---|
400 | temp = CommandLineParser::getInstance().vm[getTitle()].as< BoxValue >();
|
---|
401 | Matrix M;
|
---|
402 | M.set(0,0, temp.xx);
|
---|
403 | M.set(0,1, temp.yx);
|
---|
404 | M.set(0,2, temp.zx);
|
---|
405 | M.set(1,0, temp.yx);
|
---|
406 | M.set(1,1, temp.yy);
|
---|
407 | M.set(1,2, temp.zy);
|
---|
408 | M.set(2,0, temp.zx);
|
---|
409 | M.set(2,1, temp.zy);
|
---|
410 | M.set(2,2, temp.zz);
|
---|
411 | tmp.setM(M);
|
---|
412 | return true;
|
---|
413 | } else {
|
---|
414 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing symmetric box matrix for " << getTitle() << "." << endl);
|
---|
415 | return false;
|
---|
416 | }
|
---|
417 | }
|
---|
418 |
|
---|
419 | CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, string _description) :
|
---|
420 | Dialog::ElementQuery(title, _description)
|
---|
421 | {}
|
---|
422 |
|
---|
423 | CommandLineDialog::ElementCommandLineQuery::~ElementCommandLineQuery()
|
---|
424 | {}
|
---|
425 |
|
---|
426 | bool CommandLineDialog::ElementCommandLineQuery::handle() {
|
---|
427 | // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector?
|
---|
428 | periodentafel *periode = World::getInstance().getPeriode();
|
---|
429 | if (CommandLineParser::getInstance().vm.count(getTitle())) {
|
---|
430 | int Z = CommandLineParser::getInstance().vm[getTitle()].as< int >();
|
---|
431 | tmp = periode->FindElement(Z);
|
---|
432 | ASSERT(tmp != NULL, "Invalid element specified in ElementCommandLineQuery");
|
---|
433 | return true;
|
---|
434 | } else {
|
---|
435 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing element for " << getTitle() << "." << endl);
|
---|
436 | return false;
|
---|
437 | }
|
---|
438 | }
|
---|
439 |
|
---|
440 | CommandLineDialog::ElementsCommandLineQuery::ElementsCommandLineQuery(string title, string _description) :
|
---|
441 | Dialog::ElementsQuery(title, _description)
|
---|
442 | {}
|
---|
443 |
|
---|
444 | CommandLineDialog::ElementsCommandLineQuery::~ElementsCommandLineQuery()
|
---|
445 | {}
|
---|
446 |
|
---|
447 | bool CommandLineDialog::ElementsCommandLineQuery::handle() {
|
---|
448 | // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector?
|
---|
449 | periodentafel *periode = World::getInstance().getPeriode();
|
---|
450 | if (CommandLineParser::getInstance().vm.count(getTitle())) {
|
---|
451 | vector<int> AllElements = CommandLineParser::getInstance().vm[getTitle()].as< vector<int> >();
|
---|
452 | for (vector<int>::iterator ZRunner = AllElements.begin(); ZRunner != AllElements.end(); ++ZRunner) {
|
---|
453 | temp = periode->FindElement(*ZRunner);
|
---|
454 | ASSERT(temp != NULL, "Invalid element specified in ElementCommandLineQuery");
|
---|
455 | tmp.push_back(temp);
|
---|
456 | }
|
---|
457 | return true;
|
---|
458 | } else {
|
---|
459 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing elements for " << getTitle() << "." << endl);
|
---|
460 | return false;
|
---|
461 | }
|
---|
462 | }
|
---|
463 |
|
---|
464 | CommandLineDialog::FileCommandLineQuery::FileCommandLineQuery(string title, string _description) :
|
---|
465 | Dialog::FileQuery(title, _description)
|
---|
466 | {}
|
---|
467 |
|
---|
468 | CommandLineDialog::FileCommandLineQuery::~FileCommandLineQuery() {}
|
---|
469 |
|
---|
470 | bool CommandLineDialog::FileCommandLineQuery::handle() {
|
---|
471 | if (CommandLineParser::getInstance().vm.count(getTitle())) {
|
---|
472 | tmp = CommandLineParser::getInstance().vm[getTitle()].as<string>();
|
---|
473 | return true;
|
---|
474 | } else {
|
---|
475 | DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing string for " << getTitle() << "." << endl);
|
---|
476 | return false;
|
---|
477 | }
|
---|
478 | }
|
---|
479 |
|
---|