Skip to content

Commit aaea5eb

Browse files
committed
Expanding command objects
1 parent bddf8d5 commit aaea5eb

File tree

10 files changed

+26
-15
lines changed

10 files changed

+26
-15
lines changed

src/Core/Command/CommandFactory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ namespace SCIRun
4343
{
4444
public:
4545
virtual ~GlobalCommandFactory() {}
46-
virtual CommandHandle create(GlobalCommands type) const = 0;
46+
virtual CommandHandle create(GlobalCommands type, int param = 0) const = 0;
4747
};
4848

4949
typedef boost::shared_ptr<GlobalCommandFactory> GlobalCommandFactoryHandle;

src/Core/Command/GlobalCommandBuilderFromCommandLine.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,16 @@ using namespace SCIRun::Core::Commands;
6868
else
6969
std::cout << "HEADLESS MODE" << std::endl; /// @todo obviously
7070

71-
if (params->dataDirectory())
71+
if (!params->dataDirectory())
7272
q->enqueue(cmdFactory_->create(SetupDataDirectory));
7373

7474
if (!params->inputFiles().empty())
75-
q->enqueue(cmdFactory_->create(LoadNetworkFile));
75+
{
76+
for (int i = 0; i < params->inputFiles().size(); ++i)
77+
{
78+
q->enqueue(cmdFactory_->create(LoadNetworkFile, i));
79+
}
80+
}
7681
else if (params->pythonScriptFile())
7782
q->enqueue(cmdFactory_->create(RunPythonScript));
7883

src/Core/ConsoleApplication/ConsoleCommandFactory.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class NothingCommand : public ConsoleCommand
4040
virtual bool execute() { return true; }
4141
};
4242

43-
CommandHandle ConsoleGlobalCommandFactory::create(GlobalCommands type) const
43+
CommandHandle ConsoleGlobalCommandFactory::create(GlobalCommands type, int param) const
4444
{
4545
switch (type)
4646
{
@@ -53,7 +53,7 @@ CommandHandle ConsoleGlobalCommandFactory::create(GlobalCommands type) const
5353
case PrintVersion:
5454
return boost::make_shared<PrintVersionCommand>();
5555
case LoadNetworkFile:
56-
return boost::make_shared<LoadFileCommandConsole>();
56+
return boost::make_shared<LoadFileCommandConsole>(param);
5757
case RunPythonScript:
5858
return boost::make_shared<RunPythonScriptCommandConsole>();
5959
case ExecuteCurrentNetwork:

src/Core/ConsoleApplication/ConsoleCommandFactory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace Console {
3939
class SCISHARE ConsoleGlobalCommandFactory : public Core::Commands::GlobalCommandFactory
4040
{
4141
public:
42-
virtual Core::Commands::CommandHandle create(Core::Commands::GlobalCommands type) const;
42+
virtual Core::Commands::CommandHandle create(Core::Commands::GlobalCommands type, int param) const override;
4343
};
4444

4545
}}}

src/Core/ConsoleApplication/ConsoleCommands.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ bool LoadFileCommandConsole::execute()
4343
auto inputFiles = Application::Instance().parameters()->inputFiles();
4444
if (!inputFiles.empty())
4545
{
46-
auto filename = inputFiles[0];
46+
auto filename = inputFiles[index_];
4747

4848
/// @todo: real logger
4949
std::cout << "Attempting load of " + filename << std::endl;

src/Core/ConsoleApplication/ConsoleCommands.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ namespace Console {
3939
class SCISHARE LoadFileCommandConsole : public Core::Commands::ConsoleCommand
4040
{
4141
public:
42+
explicit LoadFileCommandConsole(int index) : index_(index) {}
4243
virtual bool execute();
44+
private:
45+
int index_;
4346
};
4447

4548
class SCISHARE RunPythonScriptCommandConsole : public Core::Commands::ConsoleCommand
@@ -77,7 +80,7 @@ namespace Console {
7780
public:
7881
virtual bool execute();
7982
};
80-
83+
8184
/// @TODO
8285
// class SCISHARE SetupDataDirectoryCommand : public Core::Commands::ConsoleCommand
8386
// {

src/Interface/Application/GuiCommandFactory.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ using namespace SCIRun::Gui;
3636
using namespace SCIRun::Core::Commands;
3737
using namespace SCIRun::Core::Console;
3838

39-
CommandHandle GuiGlobalCommandFactory::create(GlobalCommands type) const
39+
CommandHandle GuiGlobalCommandFactory::create(GlobalCommands type, int param) const
4040
{
4141
switch (type)
4242
{
@@ -49,7 +49,7 @@ CommandHandle GuiGlobalCommandFactory::create(GlobalCommands type) const
4949
case PrintVersion:
5050
return boost::make_shared<PrintVersionCommand>();
5151
case LoadNetworkFile:
52-
return boost::make_shared<LoadFileCommandGui>();
52+
return boost::make_shared<LoadFileCommandGui>(param);
5353
case RunPythonScript:
5454
return boost::make_shared<RunPythonScriptCommandGui>();
5555
case SetupDataDirectory:
@@ -63,4 +63,4 @@ CommandHandle GuiGlobalCommandFactory::create(GlobalCommands type) const
6363
default:
6464
THROW_INVALID_ARGUMENT("Unknown global command type.");
6565
}
66-
}
66+
}

src/Interface/Application/GuiCommandFactory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace Gui {
3737
class GuiGlobalCommandFactory : public Core::Commands::GlobalCommandFactory
3838
{
3939
public:
40-
virtual Core::Commands::CommandHandle create(Core::Commands::GlobalCommands type) const;
40+
virtual Core::Commands::CommandHandle create(Core::Commands::GlobalCommands type, int param) const override;
4141
};
4242

4343
}

src/Interface/Application/GuiCommands.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ using namespace SCIRun::Dataflow::Networks;
5050
bool LoadFileCommandGui::execute()
5151
{
5252
auto inputFiles = Application::Instance().parameters()->inputFiles();
53-
return SCIRunMainWindow::Instance()->loadNetworkFile(QString::fromStdString(inputFiles[0]));
53+
return SCIRunMainWindow::Instance()->loadNetworkFile(QString::fromStdString(inputFiles[index_]));
5454
}
5555

5656
bool ExecuteCurrentNetworkCommandGui::execute()

src/Interface/Application/GuiCommands.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ namespace Gui {
4343
class LoadFileCommandGui : public Core::Commands::GuiCommand
4444
{
4545
public:
46+
explicit LoadFileCommandGui(int index) : index_(index) {}
4647
virtual bool execute();
48+
private:
49+
int index_;
4750
};
4851

4952
class RunPythonScriptCommandGui : public Core::Commands::GuiCommand
@@ -81,7 +84,7 @@ namespace Gui {
8184
public:
8285
virtual bool execute();
8386
};
84-
87+
8588
class ShowSplashScreenGui : public Core::Commands::GuiCommand
8689
{
8790
public:
@@ -92,7 +95,7 @@ namespace Gui {
9295
static QSplashScreen* splash_;
9396
static QTimer* splashTimer_;
9497
};
95-
98+
9699
class FileOpenCommand : public Core::Commands::GuiCommand
97100
{
98101
public:

0 commit comments

Comments
 (0)