TTK
Loading...
Searching...
No Matches
ProgramBase.h
Go to the documentation of this file.
1
8
9#pragma once
10
11// base code includes
12#include <CommandLineParser.h>
13
14namespace ttk {
15
16 class ProgramBase : public Debug {
17
18 public:
20
21 lastObject_ = true;
23
24 outputPath_ = "output";
25 ttkModule_ = nullptr;
26 }
27
28 ~ProgramBase() override = default;
29
30 virtual int init(int &argc, char **argv) {
31
32 if(!ttkModule_)
33 return -1;
34
35 std::vector<std::string> inputPaths;
36
38 "i", &inputPaths, "Input data-sets (*.vti, *vtu, *vtp)");
40 "o", &outputPath_, "Output file name base (no extension)", true);
41
42 parser_.parse(argc, argv);
45
46 int ret = 0;
47 ret = load(inputPaths);
48
49 if(ret != 0)
50 return ret;
51
52 return 0;
53 }
54
55 virtual int run() {
56
57 if(!ttkModule_)
58 return -1;
59
62
63 return execute();
64 }
65
67 virtual int save() const = 0;
68
70
71 protected:
72 std::string outputPath_;
73
75
77 virtual int execute() = 0;
78
80 virtual int load(const std::vector<std::string> &inputPaths) = 0;
81 };
82
83 template <class ttkModule>
84 class Program : public ProgramBase {
85 ttkModule module_{};
86
87 public:
89 ttkModule_ = &module_;
90 }
91 };
92} // namespace ttk
bool lastObject_
Definition: BaseClass.h:94
int threadNumber_
Definition: BaseClass.h:95
virtual int setThreadNumber(const int threadNumber)
Definition: BaseClass.h:80
Basic command line parsing.
int parse(int argc, char **argv)
int setArgument(const std::string &key, double *value, const std::string &description="", const bool &optional=false)
Minimalist debugging class.
Definition: Debug.h:88
int debugLevel_
Definition: Debug.h:379
virtual int setDebugLevel(const int &debugLevel)
Definition: Debug.cpp:147
Base editor class for standalone programs. This class parses the the command line,...
Definition: ProgramBase.h:16
virtual int run()
Definition: ProgramBase.h:55
~ProgramBase() override=default
virtual int save() const =0
Save the output(s) of the TTK module.
Debug * ttkModule_
Definition: ProgramBase.h:74
CommandLineParser parser_
Definition: ProgramBase.h:69
std::string outputPath_
Definition: ProgramBase.h:72
virtual int execute()=0
Execute your TTK module here.
virtual int init(int &argc, char **argv)
Definition: ProgramBase.h:30
virtual int load(const std::vector< std::string > &inputPaths)=0
Load a sequence of input data-sets.
The Topology ToolKit.
COMMON_EXPORTS int globalThreadNumber_
Definition: BaseClass.cpp:6
COMMON_EXPORTS int globalDebugLevel_
Definition: Debug.cpp:8