Xmipp  v3.23.11-Nereus
xmipp_program.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Authors: J.M. de la Rosa Trevin (jmdelarosa@cnb.csic.es)
3  *
4  *
5  * Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20  * 02111-1307 USA
21  *
22  * All comments concerning this program package may be sent to the
23  * e-mail address 'xmipp@cnb.csic.es'
24  ***************************************************************************/
25 
26 #ifndef CORE_PROGRAM_H_
27 #define CORE_PROGRAM_H_
28 
29 #include <map>
30 #include "comment_list.h"
31 
32 class ProgramDef;
33 class ParamDef;
34 
53 {
54 private:
56  void init();
57 
59  bool checkBuiltIns();
60 
62  void writeToDB();
64  void writeToAutocomplete();
65 
67  void createWiki();
68 
70  size_t progressTotal;
71  size_t progressStep;
72  size_t progressLast;
73 
74 protected:
76  void defineCommons();
78  int errorCode;
81 
83  std::map<String, CommentList> defaultComments;
84 
86  int argc;
87  const char ** argv;
88 
89 public:
91  bool doRun;
100  void processDefaultComment(const char *param, const char *left);
102  void setDefaultComment(const char *param, const char *comment);
104  virtual void initComments();
106  virtual void defineParams();
110  virtual void readParams();
119  void setProgramName(const char * name);
121  void addUsageLine(const char * line, bool verbatim=false);
123  void clearUsage();
125  void addExampleLine(const char * example, bool verbatim=true);
129  void addSeeAlsoLine(const char * seeAlso);
131  void addKeywords(const char * keywords);
132 
136  const char * getParam(const char * param, int arg = 0);
137  const char * getParam(const char * param, const char * subparam, int arg = 0);
138  int getIntParam(const char * param, int arg = 0);
139  int getIntParam(const char * param, const char * subparam, int arg = 0);
140  double getDoubleParam(const char * param, int arg = 0);
141  double getDoubleParam(const char * param, const char * subparam, int arg = 0);
142  float getFloatParam(const char * param, int arg = 0);
143  float getFloatParam(const char * param, const char * subparam, int arg = 0);
145  void getListParam(const char * param, StringVector &list);
147  int getCountParam(const char * param);
149  bool checkParam(const char * param);
151  bool existsParam(const char * param);
152 
154  void addParamsLine(const String &line);
155  void addParamsLine(const char * line);
156 
158  ParamDef * getParamDef(const char * param) const;
159 
161  int verbose;
163  int debug;
164 
176  const char * name() const;
178  virtual void usage(int verb = 0) const;
180  virtual void usage(const String & param, int verb = 2);
181 
183  int version() const;
184 
186  virtual void show() const;
187 
194  virtual void read(int argc, const char ** argv, bool reportErrors = true);
195 
199  virtual void read(int argc, char ** argv, bool reportErrors = true);
200 
205  void read(const String &argumentsLine);
206 
211  virtual void run();
215  virtual void quit(int exit_code = 0) const;
221  virtual int tryRun();
222 
230  void initProgress(size_t total, size_t stepBin = 60);
231 
233  void setProgress(size_t value = 0);
234 
236  void endProgress();
237 
238 
239 
244  XmippProgram();
246  XmippProgram(int argc, const char ** argv);
248  virtual ~XmippProgram();
251 }
252 ;//end of class XmippProgram
253 
257 #define RUN_XMIPP_PROGRAM(progName) \
258  int main(int argc, char** argv) { \
259  progName program; program.read(argc, argv);\
260  return program.tryRun();}
261 
262 
264 
266 #endif /* PROGRAM_H_ */
virtual void usage(int verb=0) const
virtual void defineParams()
double getDoubleParam(const char *param, int arg=0)
virtual void read(int argc, const char **argv, bool reportErrors=true)
virtual int tryRun()
virtual void show() const
void setDefaultComment(const char *param, const char *comment)
void defineCommons()
void initProgress(size_t total, size_t stepBin=60)
int version() const
void processDefaultComment(const char *param, const char *left)
void getListParam(const char *param, StringVector &list)
virtual void quit(int exit_code=0) const
std::vector< String > StringVector
Definition: xmipp_strings.h:35
void addSeeAlsoLine(const char *seeAlso)
void addKeywords(const char *keywords)
int argc
Original command line arguments.
Definition: xmipp_program.h:86
float getFloatParam(const char *param, int arg=0)
const char * getParam(const char *param, int arg=0)
bool runWithoutArgs
Definition: xmipp_program.h:95
void setProgramName(const char *name)
const char ** argv
Definition: xmipp_program.h:87
void addExampleLine(const char *example, bool verbatim=true)
virtual ~XmippProgram()
int verbose
Verbosity level.
virtual void readParams()
virtual void run()
const char * name() const
struct _parameter * param
int getCountParam(const char *param)
ParamDef * getParamDef(const char *param) const
void setProgress(size_t value=0)
std::string String
Definition: xmipp_strings.h:34
virtual void initComments()
bool checkParam(const char *param)
void addUsageLine(const char *line, bool verbatim=false)
int getIntParam(const char *param, int arg=0)
bool existsParam(const char *param)
ProgramDef * progDef
Program definition and arguments parser.
Definition: xmipp_program.h:80
void addParamsLine(const String &line)
std::map< String, CommentList > defaultComments
Definition: xmipp_program.h:83