Documentation improvements.
[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 this Parameter
36          */
37         virtual void handle() = 0;
38
39         /**
40          * Method used for checking if the given user value understandable for
41          * parameter.
42          *
43          * @return true if passed value is understandable by current Parameter.
44          *      False otherwise.
45          */
46         virtual bool understand(const std::string & ) = 0;
47
48         /**
49          * Indicates if current Parameter is required
50          *
51          * @return false, as all Parameters are non-required by default. If you
52          *      want to make Parameter as required, wrap it using Required class
53          */
54         virtual bool isRequired() {
55             return false;
56         };
57
58         /**
59          * Indicates if current Parameter has been already used
60          *
61          * @return true if current Parameter has been already used. False otherwise.
62          */
63         virtual bool isUsed() {
64             return used;
65         }
66     };
67 }
68
69 #endif /* __COMMAND_PARAMETER_H */