summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/task/argument-task.hh
blob: 775b084cf055a620a3293e7c7324bde32e27e065 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
 ** \file task/argument-task.hh
 ** \brief Declare the task::ArgumentTask class.
 */

#pragma once

#include <string>

#include <task/task.hh>

namespace task
{
  /** \brief A `Task' expecting arguments prior to be executed.

  This class embodies tasks which need an additional parameter for their
  `execute()' method. Therefore a call to `arg_set()' must be made prior to
  the `execute()' method, to set the value of this expected argument.
  This class also automates the registering of its derived classes, as does its
  sibling class `SimpleTask' for tasks without additional argument.
  */
  class ArgumentTask : public Task
  {
    /** \name Ctor & dtor.
     ** \{ */
  public:
    /// Construct and register an ArgumentTask.
    ArgumentTask(const char* name,
                 const char* module_name,
                 const char* desc,
                 const char* argname,
                 std::string deps = "");

    /** \} */

    /** \name Accessors.
     ** \{ */
  public:
    /// Access to 'arg'.
    const std::string& arg_get() const;

    /// Access to `arg'.
    virtual void arg_set(const std::string& arg) const;

    /// Access to `argname'.
    const char* argname_get() const;

    /** \} */

  protected:
    /// ArgumentTask argument value.
    mutable std::string arg_;

    /// Argument name to be displayed when printing.
    const char* argname_;
  };

} // namespace task