| 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 | * CommandLineWindow.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 <boost/bind.hpp> | 
|---|
| 23 |  | 
|---|
| 24 | #include "CommandLineUI/CommandLineWindow.hpp" | 
|---|
| 25 | #include "CommandLineUI/CommandLineStatusIndicator.hpp" | 
|---|
| 26 |  | 
|---|
| 27 | #include "Helpers/Log.hpp" | 
|---|
| 28 | #include "Helpers/Verbose.hpp" | 
|---|
| 29 |  | 
|---|
| 30 | #include "Actions/Action.hpp" | 
|---|
| 31 | #include "Actions/ActionRegistry.hpp" | 
|---|
| 32 |  | 
|---|
| 33 | #include "UIElements/CommandLineUI/CommandLineParser.hpp" | 
|---|
| 34 |  | 
|---|
| 35 | #include <iostream> | 
|---|
| 36 |  | 
|---|
| 37 | using namespace std; | 
|---|
| 38 |  | 
|---|
| 39 | // TODO: see what code can be moved to a base class for Graphic and CommandLine Windows | 
|---|
| 40 | CommandLineWindow::CommandLineWindow() | 
|---|
| 41 | { | 
|---|
| 42 | // Add status indicators etc... | 
|---|
| 43 | statusIndicator = new CommandLineStatusIndicator(); | 
|---|
| 44 | } | 
|---|
| 45 |  | 
|---|
| 46 | CommandLineWindow::~CommandLineWindow() | 
|---|
| 47 | { | 
|---|
| 48 | delete statusIndicator; | 
|---|
| 49 | } | 
|---|
| 50 |  | 
|---|
| 51 | void CommandLineWindow::display() { | 
|---|
| 52 | //cout << ActionRegistry::getInstance(); | 
|---|
| 53 |  | 
|---|
| 54 | // go through all possible actions | 
|---|
| 55 | DoLog(0) && (Log() << Verbose(0) << "Calling Actions ... " << std::endl); | 
|---|
| 56 | for (std::list<std::string>::iterator CommandRunner = CommandLineParser::getInstance().SequenceOfActions.begin(); CommandRunner != CommandLineParser::getInstance().SequenceOfActions.end(); ++CommandRunner) { | 
|---|
| 57 | if (ActionRegistry::getInstance().isActionPresentByName(*CommandRunner)) { | 
|---|
| 58 | DoLog(1) && (Log() << Verbose(1) | 
|---|
| 59 | << "Checking presence of " << *CommandRunner << ": " | 
|---|
| 60 | << "calling " << *CommandRunner << endl); | 
|---|
| 61 | ActionRegistry::getInstance().getActionByName(*CommandRunner)->call(); | 
|---|
| 62 | } else { | 
|---|
| 63 | DoLog(1) && (Log() << Verbose(1) | 
|---|
| 64 | << "Checking presence of " << *CommandRunner << ": " | 
|---|
| 65 | << "absent." << endl); | 
|---|
| 66 | } | 
|---|
| 67 | } | 
|---|
| 68 | } | 
|---|
| 69 |  | 
|---|