LRDE Tiger Compiler  1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
task::Task Class Reference

A function bound to a command line option. More...

#include <task.hh>

Inheritance diagram for task::Task:
Collaboration diagram for task::Task:

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_typedependencies_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.

Detailed Description

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.

Member Typedef Documentation

typedef std::list<std::string> task::Task::deps_type

Constructor & Destructor Documentation

task::Task::Task ( const char *  name,
const char *  module_name,
const char *  desc,
int  key = 0,
const std::string &  deps = "" 
)

Construct a Task.

Parameters
namename of this task (used for long option)
module_namename of the module to which the task belongs.
descdescription of this task
keythe optional short option that enables the task
depsoptional 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.

task::Task::~Task ( )
virtual

Destroy this Task.

Member Function Documentation

const char * task::Task::arg_get ( ) const
inline
void task::Task::arg_set ( const char *  arg) const
inline

The argument.

References arg_.

Referenced by task::TaskRegister::enable_task().

const char * task::Task::argname_get ( ) const
inline

The argument name.

References argname_.

void task::Task::argname_set ( const char *  argname)
inline
virtual bool task::Task::check ( ) const
pure virtual
const Task::deps_type & task::Task::dependencies_get ( ) const
inline

Access to tasks dependencies.

References dependencies_.

Referenced by task::TaskRegister::print_task_graph(), and task::TaskRegister::resolve_dependencies().

const char * task::Task::desc_get ( ) const
inline

Access to 'desc'.

References desc_.

virtual void task::Task::execute ( ) const
pure virtual
int task::Task::key_get ( ) const
inline

Access to 'key'.

References key_.

Referenced by task::TaskRegister::register_task().

const char * task::Task::module_name_get ( ) const
inline

Access to 'module_name'.

References module_name_.

const char * task::Task::name_get ( ) const
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().

std::string task::Task::normalize ( const std::string &  task_name)
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_.

Task::deps_type task::Task::resolve_dependencies ( tasks_list_type active_tasks) const
virtual

Member Data Documentation

const char* task::Task::arg_
mutableprotected

The actual argument value.

Referenced by arg_get(), and arg_set().

const char* task::Task::argname_
protected

The name of the argument to display in the –help message.

Referenced by argname_get(), and argname_set().

deps_type task::Task::dependencies_
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().

const char* task::Task::desc_
protected

A short description of this task (displayed in program usage).

Referenced by desc_get().

int task::Task::key_
protected

The integer key provided by the this task to the option parser.

From 'argp ()': "If key has a value that is a printable ASCII character (i.e., isascii (key) is true), it also specifies a short option '-char' where char is the ASCII character with the code key"

Referenced by key_get(), and Task().

const char* task::Task::module_name_
protected

Module name to which the task belongs.

Referenced by module_name_get().

std::string task::Task::name_
protected

Task name.

Referenced by name_get(), print_dependencies(), and Task().


The documentation for this class was generated from the following files: