Add possibility to set Required Parameters.
[command.git] / include / parameter.h
1 #ifndef __COMMAND_PARAMETER_H
2 #define __COMMAND_PARAMETER_H
3
4 #include <string>
5
6 #include "descriptive.h"
7 #include "callable.h"
8
9 namespace command {
10     /**
11      * Base class for all the Arguments and Options.
12      *
13      * Example:
14      *  ./myprog ARGUMENT
15      */
16     class Parameter : public Descriptive {
17     protected:
18         /** Variable indicating if current Parameter was already used or not */
19         bool used = false;
20
21     public:
22         typedef class Parameter Type;
23         /**
24          * Default constructor.
25          *
26          * @param description Description of current Argument
27          */
28         Parameter(const std::string & description)
29             : Descriptive(description) {
30         }
31
32         virtual ~Parameter() { }
33
34         /**
35          * Method used for handling method calls linked with Argument or Option
36          */
37         virtual void handle() = 0;
38
39         /**
40          * Method used for checking if the given user value understandable for
41          * parameter.
42          */
43         virtual bool understand(const std::string & ) = 0;
44
45         /**
46          * Indicates if current Parameter is required
47          */
48         virtual bool isRequired() {
49             return false;
50         };
51
52         virtual bool isUsed() {
53             return used;
54         }
55     };
56 }
57
58 #endif /* __COMMAND_PARAMETER_H */