vtkCommandOptions.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
17 #ifndef vtkCommandOptions_h
18 #define vtkCommandOptions_h
19 
20 #include "vtkObject.h"
21 #include "vtkPVVTKExtensionsCoreModule.h" // needed for export macro
22 #include "vtkParaViewDeprecation.h" // for PARAVIEW_DEPRECATED_IN_5_12_0
23 
24 class vtkCommandOptionsInternal;
26 
28 {
29 public:
30  PARAVIEW_DEPRECATED_IN_5_12_0("Use `vtkCLIOptions` instead")
31  static vtkCommandOptions* New();
32  vtkTypeMacro(vtkCommandOptions, vtkObject);
33  void PrintSelf(ostream& os, vtkIndent indent) override;
34 
35  int Parse(int argc, const char* const argv[]);
36  void GetRemainingArguments(int* argc, char** argv[]);
37 
38  enum
39  {
40  EVERYBODY = 0,
41  XMLONLY = 0x1
42  };
43 
44  const char* GetHelp();
45 
47 
50  vtkGetMacro(HelpSelected, int);
51  vtkSetMacro(HelpSelected, int);
53 
58  int GetProcessType() { return this->ProcessType; }
59  void SetProcessType(int p) { this->ProcessType = p; }
60 
62 
65  vtkGetStringMacro(UnknownArgument);
67 
69 
72  vtkGetStringMacro(ErrorMessage);
74 
78  const char* GetArgv0();
79 
81 
84  vtkGetStringMacro(ApplicationPath);
86 
90  int GetLastArgument();
91 
96  virtual int ParseExtraXMLTag(const char*, const char**) { return 1; }
97 
98 protected:
103 
107  ~vtkCommandOptions() override;
108 
112  typedef int (*CallbackType)(const char* argument, const char* value, void* call_data);
113 
115 
125  void AddBooleanArgument(
126  const char* longarg, const char* shortarg, int* var, const char* help, int type = EVERYBODY);
127  void AddDeprecatedArgument(
128  const char* longarg, const char* shortarg, const char* help, int type = EVERYBODY);
129  void AddArgument(
130  const char* longarg, const char* shortarg, int* var, const char* help, int type = EVERYBODY);
131  void AddArgument(
132  const char* longarg, const char* shortarg, char** var, const char* help, int type = EVERYBODY);
134 
135  void AddCallback(const char* longarg, const char* shortarg, CallbackType callback,
136  void* call_data, const char* help, int type = EVERYBODY);
137 
141  virtual void Initialize();
142 
146  virtual int PostProcess(int argc, const char* const* argv);
147 
152  virtual int WrongArgument(const char* argument);
153 
158  virtual int DeprecatedArgument(const char* argument);
159 
165  int LoadXMLConfigFile(const char*);
166 
167  vtkSetStringMacro(UnknownArgument);
168  vtkSetStringMacro(ErrorMessage);
169 
170  // Options:
171  vtkSetStringMacro(XMLConfigFile);
172 
173  void CleanArgcArgv();
174 
175  vtkSetStringMacro(ApplicationPath);
176  void ComputeApplicationPath();
177 
179 
180 private:
181  int Argc;
182  char** Argv;
183  int HelpSelected;
184  char* UnknownArgument;
185  char* ErrorMessage;
186  char* XMLConfigFile;
187  char* ApplicationPath;
188  int ProcessType; // data-server, render-server, combined-server, client
189 
190  vtkCommandOptions(const vtkCommandOptions&) = delete;
191  void operator=(const vtkCommandOptions&) = delete;
192 
193  vtkCommandOptionsInternal* Internals;
194 
195  static int UnknownArgumentHandler(const char* argument, void* call_data);
196  static int DeprecatedArgumentHandler(const char* argument, const char* value, void* call_data);
197 };
198 
199 #endif
#define PARAVIEW_DEPRECATED_IN_5_12_0(reason)
int
void SetProcessType(int p)
#define VTKPVVTKEXTENSIONSCORE_EXPORT
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
vtkCommandOptionsXMLParser * XMLParser
virtual int ParseExtraXMLTag(const char *, const char **)
Pass in the name and the attributes for all tags that are not Options.
ParaView options storage.
int GetProcessType()
Set/Get the type of the process for this set of options.
value
static vtkObject * New()
void operator=(const vtkObjectBase &)
ParaView options storage.