source: molecuilder/src/UIElements/CommandLineWindow.cpp@ 07d2cd

Last change on this file since 07d2cd was 07d2cd, checked in by Frederik Heber <heber@…>, 15 years ago

CommandLineWindow::display() goes through all Actions in ActionRegistry.

  • we check whether title of Action can be found in program_options::vm and if so, execute Action.

Signed-off-by: Frederik Heber <heber@…>

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/*
2 * CommandLineWindow.cpp
3 *
4 * Created on: May 8, 2010
5 * Author: heber
6 */
7
8#include <boost/bind.hpp>
9
10#include "UIElements/CommandLineWindow.hpp"
11#include "UIElements/CommandLineStatusIndicator.hpp"
12
13#include "Actions/ActionRegistry.hpp"
14#include "Actions/CmdAction/HelpAction.hpp"
15#include "Actions/ParserAction/LoadXyzAction.hpp"
16#include "Actions/ParserAction/SaveXyzAction.hpp"
17#include "CommandLineParser.hpp"
18
19#include <iostream>
20
21using namespace std;
22
23// TODO: see what code can be moved to a base class for Graphic and CommandLine Windows
24CommandLineWindow::CommandLineWindow()
25{
26 // create and register all command line callable actions
27 populateParserActions();
28
29 // Add status indicators etc...
30 statusIndicator = new CommandLineStatusIndicator();
31}
32
33CommandLineWindow::~CommandLineWindow()
34{
35 delete statusIndicator;
36}
37
38void CommandLineWindow::display() {
39 // go through all possible actions
40 for(std::map<const std::string,Action*>::iterator ActionRunner = ActionRegistry::getInstance().getBeginIter(); ActionRunner != ActionRegistry::getInstance().getEndIter(); ActionRunner++) {
41 // check whether action is present in command line
42 if (CommandLineParser::getInstance().vm.count(ActionRunner->first)) {
43 ActionRunner->second->call();
44 }
45 }
46}
47
48void CommandLineWindow::populateParserActions()
49{
50 new CommandLineHelpAction();
51 new ParserLoadXyzAction();
52 new ParserSaveXyzAction();
53}
54
Note: See TracBrowser for help on using the repository browser.