-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathCommand.h
116 lines (86 loc) · 2.97 KB
/
Command.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#pragma once
/*
* Command provided by unified shapeworks executable.
*/
#include "OptionParser.h"
#include "SharedCommandData.h"
#include <iostream>
#include <stdexcept>
#define COMMAND_DECLARE(CommandName, CommandType) \
class CommandName : public CommandType \
{ \
public: \
static CommandName &getCommand() { static CommandName instance; return instance; } \
\
private: \
CommandName() { buildParser(); } \
void buildParser() override; \
bool execute(const optparse::Values &options, SharedCommandData &sharedData) override; \
}
namespace shapeworks {
class Command {
public:
virtual const std::string type() { return "General"; }
const std::string name() const { return parser.prog(); }
const std::string usage() const { return parser.get_usage(); }
const std::string desc() const { return parser.description(); }
/// parses the arguments for this command, saving them in the parser and returning the leftovers
std::vector<std::string> parse_args(const std::vector<std::string> &arguments);
/// calls execute for this command using the parsed args, returning system exit value
int run(SharedCommandData &sharedData);
private:
virtual bool execute(const optparse::Values &options, SharedCommandData &sharedData) = 0;
protected:
virtual void buildParser(); // derived classes should specialize and call this as well
optparse::OptionParser parser;
};
class ImageCommand : public Command
{
public:
const std::string type() override { return "Image"; }
private:
};
class MeshCommand : public Command
{
public:
const std::string type() override { return "Mesh"; }
private:
};
class OptimizeCommandGroup : public Command
{
public:
const std::string type() override { return "Optimize"; }
private:
};
class GroomCommandGroup : public Command
{
public:
const std::string type() override { return "Groom"; }
private:
};
class AnalyzeCommandGroup : public Command
{
public:
const std::string type() override { return "Analyze"; }
private:
};
class ProjectCommandGroup : public Command
{
public:
const std::string type() override { return "Project"; }
private:
};
class ParticleSystemCommand : public Command
{
public:
const std::string type() override { return "ParticleSystem"; }
private:
};
class ShapeworksCommand : public Command
{
public:
const std::string type() override { return "Shapeworks"; }
private:
};
}; // shapeworks
std::ostream& operator<<(std::ostream& os, const shapeworks::Command &cmd);