LRDE Tiger Compiler
1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
|
A function bound to a command line option. More...
#include <task.hh>
Public Types | |
typedef TaskRegister::tasks_list_type | tasks_list_type |
typedef std::list< std::string > | deps_type |
Public Member Functions | |
virtual deps_type | resolve_dependencies (tasks_list_type &active_tasks) const |
void | print_dependencies () const |
Display dependencies of this task . | |
Ctor & dtor. | |
Task (const char *name, const char *module_name, const char *desc, int key=0, const std::string &deps="") | |
Construct a Task. | |
virtual | ~Task () |
Destroy this Task. | |
Abstract methods. | |
virtual bool | check () const =0 |
Check that the preconditions are verified. | |
virtual void | execute () const =0 |
Execute this task. | |
Accessors. | |
const char * | name_get () const |
const char * | module_name_get () const |
Access to 'module_name'. | |
int | key_get () const |
Access to 'key'. | |
const char * | desc_get () const |
Access to 'desc'. | |
const char * | argname_get () const |
The argument name. | |
void | argname_set (const char *) |
void | arg_set (const char *arg) const |
The argument. | |
const char * | arg_get () const |
const deps_type & | dependencies_get () const |
Access to tasks dependencies. |
Static Public Member Functions | |
static std::string | normalize (const std::string &task_name) |
Normalize the name of a task. |
Protected Attributes | |
std::string | name_ |
Task name. | |
const char * | module_name_ |
Module name to which the task belongs. | |
int | key_ |
The integer key provided by the this task to the option parser. | |
const char * | desc_ |
A short description of this task (displayed in program usage). | |
const char * | argname_ |
The name of the argument to display in the –help message. | |
const char * | arg_ |
The actual argument value. | |
deps_type | dependencies_ |
Contains the name of the tasks on which this one depends. |
A function bound to a command line option.
The purpose of the Task class is to abstract the execution of a module and the tasks on which its execution depends. This is an implementation of the Command Design Pattern.
typedef std::list<std::string> task::Task::deps_type |
task::Task::Task | ( | const char * | name, |
const char * | module_name, | ||
const char * | desc, | ||
int | key = 0 , |
||
const std::string & | deps = "" |
||
) |
Construct a Task.
name | name of this task (used for long option) |
module_name | name of the module to which the task belongs. |
desc | description of this task |
key | the optional short option that enables the task |
deps | optional space separated list of task names |
References dependencies_, misc::error::failure, task::TaskRegister::instance(), key_, name_, normalize(), program_name, task::TaskRegister::register_task(), and task_error.
|
virtual |
Destroy this Task.
|
inline |
References arg_.
Referenced by task::IntTask::check(), task::StringTask::check(), and task::MultipleStringTask::check().
|
inline |
|
inline |
The argument name.
References argname_.
|
inline |
References argname_.
Referenced by task::IntTask::IntTask(), task::MultipleStringTask::MultipleStringTask(), and task::StringTask::StringTask().
|
pure virtual |
Check that the preconditions are verified.
Implemented in task::MultipleStringTask, task::BooleanTask, task::DisjunctiveTask, task::FunctionTask, task::IntTask, and task::StringTask.
Referenced by task::TaskRegister::enable_task().
|
inline |
Access to tasks dependencies.
References dependencies_.
Referenced by task::TaskRegister::print_task_graph(), and task::TaskRegister::resolve_dependencies().
|
inline |
Access to 'desc'.
References desc_.
|
pure virtual |
Execute this task.
Implemented in task::MultipleStringTask, task::BooleanTask, task::DisjunctiveTask, task::FunctionTask, task::IntTask, and task::StringTask.
|
inline |
|
inline |
Access to 'module_name'.
References module_name_.
|
inline |
Access to 'name'.
'const char*' is preferred to 'std::string' because TaskRegister calls C functions, that expect 'const char*'. The use of 'std::string::c_str()' is so forbidden and a call to 'strdup(std::string::c_str())' would implies dummy memory leaks.
References name_.
Referenced by task::TaskRegister::print_task_graph(), task::TaskRegister::register_task(), and task::TaskRegister::resolve_dependencies().
|
static |
Normalize the name of a task.
Referenced by Task().
void task::Task::print_dependencies | ( | ) | const |
Display dependencies of this task .
Display dependencies of this task.
References dependencies_, and name_.
|
virtual |
Reimplemented in task::DisjunctiveTask.
References dependencies_.
Referenced by task::TaskRegister::resolve_dependencies().
|
mutableprotected |
|
protected |
The name of the argument to display in the –help message.
Referenced by argname_get(), and argname_set().
|
protected |
Contains the name of the tasks on which this one depends.
Referenced by dependencies_get(), print_dependencies(), task::DisjunctiveTask::resolve_dependencies(), resolve_dependencies(), and Task().
|
protected |
A short description of this task (displayed in program usage).
Referenced by desc_get().
|
protected |
|
protected |
Module name to which the task belongs.
Referenced by module_name_get().
|
protected |
Task name.
Referenced by name_get(), print_dependencies(), and Task().