IODA Bundle
ToolRunnerApplication.cc
Go to the documentation of this file.
1
/*
2
* (C) Copyright 1996-2012 ECMWF.
3
*
4
* This software is licensed under the terms of the Apache Licence Version 2.0
5
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6
* In applying this licence, ECMWF does not waive the privileges and immunities
7
* granted to it by virtue of its status as an intergovernmental organisation nor
8
* does it submit to any jurisdiction.
9
*/
10
11
/// \file ToolRunnerApplication.h
12
///
13
/// @author Piotr Kuchta, ECMWF, Feb 2009
14
15
#include "eckit/filesystem/PathName.h"
16
17
#include "
odc/tools/Tool.h
"
18
#include "
odc/tools/ToolFactory.h
"
19
#include "
odc/tools/ToolRunnerApplication.h
"
20
21
using namespace
eckit
;
22
23
namespace
odc
{
24
namespace
tool {
25
26
ToolRunnerApplication::ToolRunnerApplication (
int
argc,
char
**argv,
bool
createCommandLineTool,
bool
deleteTool)
27
:
ODBApplication
(argc, argv),
28
tool_(!createCommandLineTool ? 0 :
AbstractToolFactory
::createTool(PathName(argv[1]).baseName(), argc - 1, argv + 1)),
29
deleteTool_(deleteTool)
30
{}
31
32
ToolRunnerApplication::ToolRunnerApplication
(
odc::tool::Tool
&tool,
int
argc,
char
**argv)
33
:
ODBApplication
(argc, argv),
34
tool_(&tool),
35
deleteTool_(false)
36
{}
37
38
ToolRunnerApplication::~ToolRunnerApplication
()
39
{
40
if
(
deleteTool_
)
delete
tool_
;
41
}
42
43
void
ToolRunnerApplication::tool
(
odc::tool::Tool
*tool)
44
{
45
tool_
=
tool
;
46
}
47
48
void
ToolRunnerApplication::run
()
49
{
50
if
(
tool_
== 0)
51
{
52
std::cerr <<
name
() <<
": Unknown command '"
<< argv(1) <<
"'"
<< std::endl;
53
return
;
54
}
55
56
tool_
->
run
();
57
58
if
(
deleteTool_
)
59
{
60
delete
tool_
;
61
tool_
= 0;
62
}
63
}
64
65
66
int
ToolRunnerApplication::printHelp
(std::ostream &out)
67
{
68
if
(
tool_
== 0)
69
{
70
std::cerr <<
name
() <<
": Unknown command '"
<< argv(1) <<
"'"
<< std::endl;
71
return
1;
72
}
73
//tool_->help(out);
74
return
0;
75
}
76
77
}
// namespace tool
78
}
// namespace odc
79
Tool.h
ToolFactory.h
ToolRunnerApplication.h
odc::tool::AbstractToolFactory
Definition:
ToolFactory.h:21
odc::tool::ODBApplication
Definition:
ODBApplication.h:24
odc::tool::Tool
Definition:
Tool.h:27
odc::tool::Tool::run
virtual void run()=0
odc::tool::ToolRunnerApplication::ToolRunnerApplication
ToolRunnerApplication(int argc, char **argv, bool createCommandLineTool=true, bool deleteTool=true)
Definition:
ToolRunnerApplication.cc:26
odc::tool::ToolRunnerApplication::tool
void tool(odc::tool::Tool *)
Definition:
ToolRunnerApplication.cc:43
odc::tool::ToolRunnerApplication::printHelp
int printHelp(std::ostream &out)
Definition:
ToolRunnerApplication.cc:66
odc::tool::ToolRunnerApplication::run
void run()
Definition:
ToolRunnerApplication.cc:48
odc::tool::ToolRunnerApplication::tool_
odc::tool::Tool * tool_
Definition:
ToolRunnerApplication.h:36
odc::tool::ToolRunnerApplication::deleteTool_
bool deleteTool_
Definition:
ToolRunnerApplication.h:37
odc::tool::ToolRunnerApplication::~ToolRunnerApplication
~ToolRunnerApplication()
Definition:
ToolRunnerApplication.cc:38
03-VariablesIntro.name
name
Definition:
03-VariablesIntro.py:74
eckit
Definition:
DistributionUtils.h:15
odc
Definition:
ColumnInfo.h:23
odc
src
odc
tools
ToolRunnerApplication.cc
Generated on Fri Aug 20 2021 11:49:12 for IODA Bundle by
1.9.1