inputParam.hh

Go to the documentation of this file.
1 
7 #ifndef inputParam_hh
8 #define inputParam_hh
9 
10 #include <iostream>
11 #include "basics/outputOperator.hh"
12 #include "inputOutput.hh"
13 #include "sequence.hh"
14 
15 namespace concepts {
16 
17  // ******************************************************** InputParameter **
18 
24  class InputParameter : public virtual OutputOperator {
25  public:
34  virtual std::ostream& letters(std::ostream& os) const = 0;
36  virtual std::ostream& arguments(std::ostream& os) const = 0;
38  virtual std::ostream& description(std::ostream& os) const = 0;
43  virtual int input(int opt, const char* optarg) = 0;
45  const InOutParameters parameters() const { return input_; }
47  protected:
48  virtual std::ostream& info(std::ostream& os) const;
51  };
52 
53  // ************************************************************* InputFile **
54 
59  class InputFile : public InputParameter {
60  public:
63 
64  virtual std::ostream& letters(std::ostream& os) const;
65  virtual std::ostream& arguments(std::ostream& os) const;
66  virtual std::ostream& description(std::ostream& os) const;
67  virtual int input(int opt, const char* optarg);
68  protected:
69  virtual std::ostream& info(std::ostream& os) const;
70  };
71 
72  // ****************************************************** ProcessParameter **
73 
81  class ProcessParameter : public virtual OutputOperator {
82  public:
88  void add(InputParameter& input) { inputs_.push_back(&input); }
96  bool apply(int argc, char** argv);
97  protected:
98  virtual std::ostream& info(std::ostream& os) const;
100  std::unique_ptr<InputFile> inputfile_;
103 
104  };
105 
106 } // namespace concepts
107 
108 #endif // inputParam_hh
Helps for reading the input parameter of file name.
Definition: inputParam.hh:59
virtual std::ostream & description(std::ostream &os) const =0
Returns description for help.
virtual std::ostream & arguments(std::ostream &os) const =0
Returns argument list as string.
Sequence< InputParameter * > inputs_
List of input parameter objects.
Definition: inputParam.hh:102
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Holds parameters in hashes.
Definition: inputOutput.hh:75
Abstract class for carrying information, which helps for reading input parameters from command line.
Definition: inputParam.hh:24
virtual int input(int opt, const char *optarg)=0
Process an argument and sets input parameter, if found.
virtual std::ostream & description(std::ostream &os) const
Returns description for help.
std::unique_ptr< InputFile > inputfile_
Reading input files.
Definition: inputParam.hh:100
InputFile(InOutParameters &input)
Constructor.
virtual std::ostream & letters(std::ostream &os) const
Return letters for the arguments.
InputParameter(InOutParameters &input)
Constructor.
void add(InputParameter &input)
Adds another object for input parameter.
Definition: inputParam.hh:88
ProcessParameter(InputParameter &input)
Constructor.
ProcessParameter(InOutParameters &input)
Constructor, just for file loading.
virtual int input(int opt, const char *optarg)
Process an argument and sets input parameter, if found.
bool apply(int argc, char **argv)
Process the command line arguments.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Sequence with operations, output operator, and method of the particular element types.
Definition: sequence.hh:39
InOutParameters & parameters()
Definition: inputParam.hh:46
virtual std::ostream & letters(std::ostream &os) const =0
Return letters for the arguments.
virtual std::ostream & arguments(std::ostream &os) const
Returns argument list as string.
InOutParameters & input_
Input parameter.
Definition: inputParam.hh:50
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Class providing an output operator.
const InOutParameters parameters() const
Returns input parameters.
Definition: inputParam.hh:45
Reads command line.
Definition: inputParam.hh:81
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich