Xmipp  v3.23.11-Nereus
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
PythonProgram Class Reference

#include <python_program.h>

Inheritance diagram for PythonProgram:
Inheritance graph
[legend]
Collaboration diagram for PythonProgram:
Collaboration graph
[legend]

Public Member Functions

 PythonProgram ()
 Constructor. More...
 
void endDefinition ()
 
virtual void read (int argc, const char **argv, bool reportErrors=true) override
 
virtual void read (int argc, char **argv, bool reportErrors=true) override
 
- Public Member Functions inherited from XmippProgram
const char * getParam (const char *param, int arg=0)
 
const char * getParam (const char *param, const char *subparam, int arg=0)
 
int getIntParam (const char *param, int arg=0)
 
int getIntParam (const char *param, const char *subparam, int arg=0)
 
double getDoubleParam (const char *param, int arg=0)
 
double getDoubleParam (const char *param, const char *subparam, int arg=0)
 
float getFloatParam (const char *param, int arg=0)
 
float getFloatParam (const char *param, const char *subparam, int arg=0)
 
void getListParam (const char *param, StringVector &list)
 
int getCountParam (const char *param)
 
bool checkParam (const char *param)
 
bool existsParam (const char *param)
 
void addParamsLine (const String &line)
 
void addParamsLine (const char *line)
 
ParamDefgetParamDef (const char *param) const
 
virtual void quit (int exit_code=0) const
 
virtual int tryRun ()
 
void initProgress (size_t total, size_t stepBin=60)
 
void setProgress (size_t value=0)
 
void endProgress ()
 
void processDefaultComment (const char *param, const char *left)
 
void setDefaultComment (const char *param, const char *comment)
 
virtual void initComments ()
 
void setProgramName (const char *name)
 
void addUsageLine (const char *line, bool verbatim=false)
 
void clearUsage ()
 
void addExampleLine (const char *example, bool verbatim=true)
 
void addSeeAlsoLine (const char *seeAlso)
 
void addKeywords (const char *keywords)
 
const char * name () const
 
virtual void usage (int verb=0) const
 
virtual void usage (const String &param, int verb=2)
 
int version () const
 
void read (const String &argumentsLine)
 
 XmippProgram ()
 
 XmippProgram (int argc, const char **argv)
 
virtual ~XmippProgram ()
 

Public Attributes

bool definitionComplete
 
- Public Attributes inherited from XmippProgram
bool doRun
 
bool runWithoutArgs
 
int verbose
 Verbosity level. More...
 
int debug
 

Protected Member Functions

virtual void defineParams () override
 
virtual void readParams () override
 
virtual void show () const override
 
virtual void run () override
 
- Protected Member Functions inherited from XmippProgram
void defineCommons ()
 

Additional Inherited Members

- Protected Attributes inherited from XmippProgram
int errorCode
 
ProgramDefprogDef
 Program definition and arguments parser. More...
 
std::map< String, CommentListdefaultComments
 
int argc
 Original command line arguments. More...
 
const char ** argv
 

Detailed Description

This class will serve as an interface for python scripts useful for command line parsing and help message printing

Definition at line 42 of file python_program.h.

Constructor & Destructor Documentation

◆ PythonProgram()

PythonProgram::PythonProgram ( )

Constructor.

Definition at line 35 of file python_program.cpp.

36 {
37  initComments();
38  progDef = new ProgramDef();
39  definitionComplete = false;
40 }
bool definitionComplete
virtual void initComments()
ProgramDef * progDef
Program definition and arguments parser.
Definition: xmipp_program.h:80

Member Function Documentation

◆ defineParams()

void PythonProgram::defineParams ( )
overrideprotectedvirtual

Function in which the param of each Program are defined.

Reimplemented from XmippProgram.

Definition at line 65 of file python_program.cpp.

66 {}

◆ endDefinition()

void PythonProgram::endDefinition ( )

Definition at line 42 of file python_program.cpp.

43 {
44  definitionComplete = true;
45  this->defineCommons();
46  progDef->parse();
47 }
bool definitionComplete
void defineCommons()
virtual bool parse()
Definition: argsparser.cpp:825
ProgramDef * progDef
Program definition and arguments parser.
Definition: xmipp_program.h:80

◆ read() [1/2]

void PythonProgram::read ( int  argc,
const char **  argv,
bool  reportErrors = true 
)
overridevirtual

Read the command line arguments If an error occurs while reading arguments, the error message will be printed and the usage of the program showed. So you don't need to do that in readParams();

If not arguments are provided show the console program help

Reimplemented from XmippProgram.

Definition at line 49 of file python_program.cpp.

50 {
51  if (!definitionComplete)
52  endDefinition();
53  XmippProgram::read(argc, argv, reportErrors);
54 }
virtual void read(int argc, const char **argv, bool reportErrors=true)
bool definitionComplete
int argc
Original command line arguments.
Definition: xmipp_program.h:86
const char ** argv
Definition: xmipp_program.h:87

◆ read() [2/2]

void PythonProgram::read ( int  argc,
char **  argv,
bool  reportErrors = true 
)
overridevirtual

Read the command line arguments A convenience wrapper

Reimplemented from XmippProgram.

Definition at line 56 of file python_program.cpp.

57 {
58  if (!definitionComplete)
59  endDefinition();
60  XmippProgram::read(argc, argv, reportErrors);
61 }
virtual void read(int argc, const char **argv, bool reportErrors=true)
bool definitionComplete
int argc
Original command line arguments.
Definition: xmipp_program.h:86
const char ** argv
Definition: xmipp_program.h:87

◆ readParams()

void PythonProgram::readParams ( )
overrideprotectedvirtual

Function in which each program will read parameters that it need. If some error occurs the usage will be printed out.

Reimplemented from XmippProgram.

Definition at line 63 of file python_program.cpp.

64 {}

◆ run()

void PythonProgram::run ( )
overrideprotectedvirtual

This function will be start running the program. it also should be implemented by derived classes.

Reimplemented from XmippProgram.

Definition at line 69 of file python_program.cpp.

70 {}

◆ show()

void PythonProgram::show ( ) const
overrideprotectedvirtual

Show parameters

Reimplemented from XmippProgram.

Definition at line 67 of file python_program.cpp.

68 {}

Member Data Documentation

◆ definitionComplete

bool PythonProgram::definitionComplete

Definition at line 45 of file python_program.h.


The documentation for this class was generated from the following files: