## MrpTask

MrpTask — represents a task in the project.

## Functions

#define | UNIT_IVAL_GET_TIME()
MrpTask * | mrp_task_new ()
const gchar * | mrp_task_get_name ()
void | mrp_task_set_name ()
MrpRelation * | mrp_task_add_predecessor ()
void | mrp_task_remove_predecessor ()
MrpRelation * | mrp_task_get_relation ()
MrpRelation * | mrp_task_get_predecessor_relation ()
MrpRelation * | mrp_task_get_successor_relation ()
GList * | mrp_task_get_predecessor_relations ()
GList * | mrp_task_get_successor_relations ()
gboolean | mrp_task_has_relation_to ()
gboolean | mrp_task_has_relation ()
MrpTask * | mrp_task_get_parent ()
MrpTask * | mrp_task_get_first_child ()
MrpTask * | mrp_task_get_next_sibling ()
MrpTask * | mrp_task_get_prev_sibling ()
guint | mrp_task_get_n_children ()
MrpTask * | mrp_task_get_nth_child ()
gint | mrp_task_get_position ()
mrptime | mrp_task_get_start ()
mrptime | mrp_task_get_work_start ()
mrptime | mrp_task_get_finish ()
mrptime | mrp_task_get_latest_start ()
mrptime | mrp_task_get_latest_finish ()
gint | mrp_task_get_duration ()
gint | mrp_task_get_work ()
gint | mrp_task_get_priority ()
gboolean | mrp_task_is_dominant ()
GList * | mrp_task_get_unit_ivals ()
GList * | mrp_task_set_unit_ivals ()
GList * | mrp_task_get_assignments ()
gint | mrp_task_get_nres ()
gint | mrp_task_get_fullwork ()
MrpAssignment * | mrp_task_get_assignment ()
void | mrp_task_reset_constraint ()
gfloat | mrp_task_get_cost ()
void | mrp_task_invalidate_cost ()
GList * | mrp_task_get_assigned_resources ()
gint | mrp_task_compare ()
MrpTaskType | mrp_task_get_task_type ()
MrpTaskSched | mrp_task_get_sched ()
gshort | mrp_task_get_percent_complete ()
gboolean | mrp_task_get_critical ()

## Properties

int | lag | Read / Write
MrpTask * | predecessor | Read / Write / Construct Only
MrpTask * | successor | Read / Write / Construct Only
MrpRelationType | type | Read / Write
MrpConstraint * | constraint | Read / Write
gboolean | critical | Read / Write
int | duration | Read / Write
gint64 | finish | Read
gint64 | latest-finish | Read
gint64 | latest-start | Read
char * | name | Read / Write
char * | note | Read / Write
int | percent-complete | Read / Write
int | priority | Read / Write
MrpTaskSched | sched | Read / Write
gint64 | start | Read
MrpTaskType | type | Read / Write
int | work | Read / Write

## Signals

void | changed | Run Last
void | assignment-added | Run Last
void | assignment-removed | Run Last
void | child-added | Run Last
void | child-removed | Run Last
void | relation-added | Run Last
void | relation-removed | Run Last
void | task-moved | Run Last

## Types and Values

#define | MRP_TYPE_TASK
#define | MRP_TYPE_RELATION
| MrpUnitsInterval
#define | MRP_DOMINANT_PRIORITY
| MrpRelation
| MrpTask

## Object Hierarchy

        GObject
        ╰── MrpObject
            ├── MrpRelation
            ╰── MrpTask

## Includes

    #include <libplanner/mrp-task.h>

## Description

Tasks have a name.

They form a tree: The work breakdown structure (WBS).

A task is estimated in term of work effort, the mythical man-month.

Some tasks are of the fixed-duration type. They still can consume resources. Some tasks are milestones. They take no time, no resource. They are just markers.

A task have a time constraint. By default, it starts as soon as possible.

Tasks are in logical precedence relationship with each other.

A task lists the assignments it is involved in.

During scheduling, start and finish times are calculated. CPM latest start and latest finish times are also calculated. Tasks belonging to the critical path are marked.

A task have a cost.

A task have a priority.

A task can retain its progress.

Because of non-working periods, work might begin after the task start.

## Functions

### UNIT_IVAL_GET_TIME()

    #define UNIT_IVAL_GET_TIME(R) ((R->is_start?R->start:R->end))

Get start or end time of an interval.

#### Parameters

R | an interval |

### mrp_task_new ()

    MrpTask *
    mrp_task_new (void);

Create a new task.

#### Returns

the newly created MrpTask.

### mrp_task_get_name ()

    const gchar *
    mrp_task_get_name (MrpTask *task);

Retrieves the name of `task` .

#### Parameters

task | an MrpTask |

#### Returns

the name

### mrp_task_set_name ()

    void
    mrp_task_set_name (MrpTask *task,
                       const gchar *name);

Sets the name of `task` .

#### Parameters

task | an MrpTask |
name | new name of `task` |

### mrp_task_add_predecessor ()

    MrpRelation *
    mrp_task_add_predecessor (MrpTask *task,
                              MrpTask *predecessor,
                              MrpRelationType type,
                              glong lag,
                              GError **error);

Adds a predecessor task to a task. Depending on type, the predecessor must be started or finished before task can be started or finished, with an optional lag/lead time.

#### Parameters

task | an MrpTask |
predecessor | the predecessor |
type | type of relation |
lag | lag time, if negative, it means lead time |
error | location to store error, or `NULL` |

#### Returns

the relation that represents the predecessor/successor link.

### mrp_task_remove_predecessor ()

    void
    mrp_task_remove_predecessor (MrpTask *task,
                                 MrpTask *predecessor);

Removes a predecessor previously added to task.

#### Parameters

task | an MrpTask |
predecessor | the predecessor to remove |

### mrp_task_get_relation ()

    MrpRelation *
    mrp_task_get_relation (MrpTask *task_a,
                           MrpTask *task_b);

Fetches a relation between two tasks if it exists.

#### Parameters

task_a | an MrpTask |
task_b | an MrpTask |

#### Returns

a MrpRelation representing the relation between `task_a` and `task_b` or `NULL` if they don't have any relation.

### mrp_task_get_predecessor_relation ()

    MrpRelation *
    mrp_task_get_predecessor_relation (MrpTask *task,
                                       MrpTask *predecessor);

Fetches a predecessor relation between task and it's predecessor.

#### Parameters

task | an MrpTask |
predecessor | an MrpTask |

#### Returns

the MrpRelation if it exists, otherwise `NULL`

### mrp_task_get_successor_relation ()

    MrpRelation *
    mrp_task_get_successor_relation (MrpTask *task,
                                     MrpTask *successor);

Fetches a successor relation between task and it's successor.

#### Parameters

task | an MrpTask |
successor | an MrpTask |

#### Returns

the MrpRelation if it exists, otherwise `NULL`

### mrp_task_get_predecessor_relations ()

    GList *
    mrp_task_get_predecessor_relations (MrpTask *task);

Fetches a list of predecessor relations to `task` .

#### Parameters

task | an MrpTask |

#### Returns

the list of predecessor relations to `task`

### mrp_task_get_successor_relations ()

    GList *
    mrp_task_get_successor_relations (MrpTask *task);

Fetches a list of successor relations to `task` .

#### Parameters

task | an MrpTask |

#### Returns

a list of successor relations to `task`

### mrp_task_has_relation_to ()

    gboolean
    mrp_task_has_relation_to (MrpTask *task_a,
                              MrpTask *task_b);

Checks if `task_a` and `task_b` has a relation, i.e. if `task_a` is a predecessor or successor of `task_b` .

#### Parameters

task_a | an MrpTask |
task_b | an MrpTask |

#### Returns

`TRUE` if `a` and `b` has a relation

### mrp_task_has_relation ()

    gboolean
    mrp_task_has_relation (MrpTask *task);

Checks if a task has any relations, i.e. predecessors or successors.

#### Parameters

task | an MrpTask |

#### Returns

`TRUE` if there are any relations.

### mrp_task_get_parent ()

    MrpTask *
    mrp_task_get_parent (MrpTask *task);

Fetches the parent of `task` .

#### Parameters

task | an MrpTask |

#### Returns

the parent of `task` , or `NULL` if there is no parent..

### mrp_task_get_first_child ()

    MrpTask *
    mrp_task_get_first_child (MrpTask *task);

Fetches the first child of `task` .

#### Parameters

task | an MrpTask |

#### Returns

the first child of `task` , or `NULL` if there are no children.

### mrp_task_get_next_sibling ()

    MrpTask *
    mrp_task_get_next_sibling (MrpTask *task);

Fetches the next sibling of `task` .

#### Parameters

task | an MrpTask |

#### Returns

the next sibling of `task` , or `NULL` if there is no next sibling.

### mrp_task_get_prev_sibling ()

    MrpTask *
    mrp_task_get_prev_sibling (MrpTask *task);

Fetches the previous sibling of `task` .

#### Parameters

task | an MrpTask |

#### Returns

the previous sibling of `task` , or `NULL` if there is none.

### mrp_task_get_n_children ()

    guint
    mrp_task_get_n_children (MrpTask *task);

Fetches the number of children `task` has.

#### Parameters

task | an MrpTask |

#### Returns

the number of children `task` has

### mrp_task_get_nth_child ()

    MrpTask *
    mrp_task_get_nth_child (MrpTask *task,
                            guint n);

Fetches the nth child of `task` .

#### Parameters

task | an MrpTask |
n | the index of the child to get |

#### Returns

the nth child of `task` , or `NULL` if there is no such child.

### mrp_task_get_position ()

    gint
    mrp_task_get_position (MrpTask *task);

Fetches the index or position of `task` among its siblings.

#### Parameters

task | an MrpTask |

#### Returns

the position of `task` among its siblings.

### mrp_task_get_start ()

    mrptime
    mrp_task_get_start (MrpTask *task);

Fetches the start time of `task` .

#### Parameters

task | an MrpTask |

#### Returns

the start time of `task` .

### mrp_task_get_work_start ()

    mrptime
    mrp_task_get_work_start (MrpTask *task);

Retrieves the first time where work is performed of `task` . This might be different from the start time, if the start time is during non-working time. In that case, the work start would be right after the non-working interval.

#### Parameters

task | an MrpTask |

#### Returns

The work start time of `task` .

### mrp_task_get_finish ()

    mrptime
    mrp_task_get_finish (MrpTask *task);

Fetches the finish time of `task` .

#### Parameters

task | an MrpTask |

#### Returns

the finish time of `task` .

### mrp_task_get_latest_start ()

    mrptime
    mrp_task_get_latest_start (MrpTask *task);

Retrieves the latest start time of `task` , i.e. the latest time the task can start without delaying the project.

#### Parameters

task | an MrpTask |

#### Returns

The latest start time of `task` .

### mrp_task_get_latest_finish ()

    mrptime
    mrp_task_get_latest_finish (MrpTask *task);

Retrieves the latest finish time of `task` , i.e. the latest time the task can finish without delaying the project.

#### Parameters

task | an MrpTask |

#### Returns

The latest finish time of `task` .

### mrp_task_get_duration ()

    gint
    mrp_task_get_duration (MrpTask *task);

Fetches the duration of `task` . This differs from the calendar duration that is retrieved by (finish - start).

#### Parameters

task | an MrpTask |

#### Returns

The duration of `task` .

### mrp_task_get_work ()

    gint
    mrp_task_get_work (MrpTask *task);

Retrieves the amount of work of `task` .

#### Parameters

task | an MrpTask |

#### Returns

The work of `task` .

### mrp_task_get_priority ()

    gint
    mrp_task_get_priority (MrpTask *task);

Retrieves the priority of `task` .

#### Parameters

task | an MrpTask |

#### Returns

The priority of `task` .

### mrp_task_is_dominant ()

    gboolean
    mrp_task_is_dominant (MrpTask *task);

Retrieves if `task` is a dominant task.

#### Parameters

task | an MrpTask |

#### Returns

if `task` is a dominant task.

### mrp_task_get_unit_ivals ()

    GList *
    mrp_task_get_unit_ivals (MrpTask *task);

Retrieves the list of intervals of `task` .

#### Parameters

task | an MrpTask |

#### Returns

Intervals of `task` .

### mrp_task_set_unit_ivals ()

    GList *
    mrp_task_set_unit_ivals (MrpTask *task,
                             GList *ivals);

Set the list of intervals of `task` .

#### Parameters

task | an MrpTask |
ivals | a list of intervals. |

#### Returns

Intervals of `task` .

### mrp_task_get_assignments ()

    GList *
    mrp_task_get_assignments (MrpTask *task);

Fetches a list of MrpAssignment.

#### Parameters

task | an MrpTask |

#### Returns

the list of assignments.

### mrp_task_get_nres ()

    gint
    mrp_task_get_nres (MrpTask *task);

Calculate the number of resources assigned to task.

#### Parameters

task | an MrpTask |

#### Returns

the number of resources.

### mrp_task_get_fullwork ()

    gint
    mrp_task_get_fullwork (MrpTask *task);

Unimplemented.

#### Parameters

task | a MrpTask |

#### Returns

an integer

### mrp_task_get_assignment ()

    MrpAssignment *
    mrp_task_get_assignment (MrpTask *task,
                             MrpResource *resource);

retrieves the MrpAssignment associated with `task` and `resource` if the resource is assigned to `task` , or `NULL` if there is no such assignment.

#### Parameters

task | an MrpTask |
resource | an MrpResource |

#### Returns

The assignment if it exists, otherwise `NULL`.

### mrp_task_reset_constraint ()

    void
    mrp_task_reset_constraint (MrpTask *task);

Sets the constraint type to MRP_CONSTRAINT_ASAP and notifies listeners.

#### Parameters

task | an MrpTask |

### mrp_task_get_cost ()

    gfloat
    mrp_task_get_cost (MrpTask *task);

Calculates the cost to complete `task` .

#### Parameters

task | an MrpTask |

#### Returns

The cost to complete `task` .

### mrp_task_invalidate_cost ()

    void
    mrp_task_invalidate_cost (MrpTask *task);

invalidates `task` cost.

#### Parameters

task | a task. |

### mrp_task_get_assigned_resources ()

    GList *
    mrp_task_get_assigned_resources (MrpTask *task);

Fetches a list of resources assigned to `task` . The list needs to be freed with `g_list_free()` by caller.

#### Parameters

task | an MrpTask |

#### Returns

A newly created list of MrpResource.

### mrp_task_compare ()

    gint
    mrp_task_compare (gconstpointer a,
                      gconstpointer b);

Compares the name of the tasks, by calling `strcmp()` on the names.

#### Parameters

a | an MrpTask |
b | an MrpTask |

#### Returns

the return value of strcmp (a->name, b->name).

### mrp_task_get_task_type ()

    MrpTaskType
    mrp_task_get_task_type (MrpTask *task);

get `task` type.

#### Parameters

task | a task. |

#### Returns

a MrpTaskType.

### mrp_task_get_sched ()

    MrpTaskSched
    mrp_task_get_sched (MrpTask *task);

get `task` scheduling type.

#### Parameters

task | a task. |

#### Returns

a MrpTaskSched.

### mrp_task_get_percent_complete ()

    gshort
    mrp_task_get_percent_complete (MrpTask *task);

get `task` percent complete.

#### Parameters

task | a task. |

#### Returns

a integer.

### mrp_task_get_critical ()

    gboolean
    mrp_task_get_critical (MrpTask *task);

is `task` critical?

#### Parameters

task | a task. |

#### Returns

a boolean.

## Types and Values

### MRP_TYPE_TASK

    #define MRP_TYPE_TASK                   (mrp_task_get_type ())

### MRP_TYPE_RELATION

    #define             MRP_TYPE_RELATION

### MrpUnitsInterval

    typedef struct {
    	gboolean is_start;
    	mrptime  start;
    	mrptime  end;
    	gint     units;
    	gint     units_full;
    	gint     res_n;
    } MrpUnitsInterval;

[2006-04-11T12:42:44Z] NOTE: moved from libplanner/mrp-task-manager.c to use the structure in the src/planner-gantt-row.c new fields are: units, units_full, res_n.

#### Members

gboolean `is_start`; | is start. |
mrptime `start`; | start time. |
mrptime `end`; | end time. |
gint `units`; | worked units in the interval. |
gint `units_full`; | expected worked units in the interval all resources that are working in the interval in the right percentage. |
gint `res_n`; | number of expected resources working at the task in the interval. |

### MRP_DOMINANT_PRIORITY

    #define MRP_DOMINANT_PRIORITY           9999

Value of the magic priority of a dominant task.

### MrpRelation

    typedef struct _MrpRelation MrpRelation;

Object representing a predecessor relation between two tasks.

### MrpTask

    typedef struct _MrpTask MrpTask;

Object representing a task in the project.

## Property Details

### The `“lag”` property

      “lag”                      int

Lag between the predecessor and successor.

Owner: MrpRelation

Flags: Read / Write

Allowed values: >= -2147483647

Default value: 0

### The `“predecessor”` property

      “predecessor”              MrpTask *

The predecessor in the relation.

Owner: MrpRelation

Flags: Read / Write / Construct Only

### The `“successor”` property

      “successor”                MrpTask *

The successor in the relation.

Owner: MrpRelation

Flags: Read / Write / Construct Only

### The `“type”` property

      “type”                     MrpRelationType

The type of relation.

Owner: MrpRelation

Flags: Read / Write

Default value: MRP_RELATION_FS

### The `“constraint”` property

      “constraint”               MrpConstraint *

Task scheduling constraint.

Owner: MrpTask

Flags: Read / Write

### The `“critical”` property

      “critical”                 gboolean

In critical path.

Owner: MrpTask

Flags: Read / Write

Default value: FALSE

### The `“duration”` property

      “duration”                 int

Duration of the task.

Owner: MrpTask

Flags: Read / Write

Allowed values: >= -1

Default value: 0

### The `“finish”` property

      “finish”                   gint64

Task finish time.

Owner: MrpTask

Flags: Read

Allowed values: [0,253402300799]

Default value: 0

### The `“latest-finish”` property

      “latest-finish”            gint64

Latest task finish time.

Owner: MrpTask

Flags: Read

Allowed values: [0,253402300799]

Default value: 0

### The `“latest-start”` property

      “latest-start”             gint64

Latest task start time.

Owner: MrpTask

Flags: Read

Allowed values: [0,253402300799]

Default value: 0

### The `“name”` property

      “name”                     char *

Name of the task.

Owner: MrpTask

Flags: Read / Write

Default value: ""

### The `“note”` property

      “note”                     char *

Note attached to the task.

Owner: MrpTask

Flags: Read / Write

Default value: ""

### The `“percent-complete”` property

      “percent-complete”         int

Percent completed of task.

Owner: MrpTask

Flags: Read / Write

Allowed values: [0,100]

Default value: 0

### The `“priority”` property

      “priority”                 int

Priority of the task.

Owner: MrpTask

Flags: Read / Write

Allowed values: [0,9999]

Default value: 0

### The `“sched”` property

      “sched”                    MrpTaskSched

Task scheduling type.

Owner: MrpTask

Flags: Read / Write

Default value: MRP_TASK_SCHED_FIXED_WORK

### The `“start”` property

      “start”                    gint64

Task Start time.

Owner: MrpTask

Flags: Read

Allowed values: [0,253402300799]

Default value: 0

### The `“type”` property

      “type”                     MrpTaskType

Task type.

Owner: MrpTask

Flags: Read / Write

Default value: MRP_TASK_TYPE_NORMAL

### The `“work”` property

      “work”                     int

Task work.

Owner: MrpTask

Flags: Read / Write

Allowed values: >= -1

Default value: 0

## Signal Details

### The `“changed”` signal

    void
    user_function (MrpRelation *relation,
                   gpointer     user_data)

emitted when `relation` changes.

#### Parameters

relation | an MrpRelation. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“assignment-added”` signal

    void
    user_function (MrpTask       *task,
                   MrpAssignment *assignment,
                   gpointer       user_data)

emitted when `assignment` is added.

#### Parameters

task | the object which received the signal. |
assignment | the added MrpAssignment. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“assignment-removed”` signal

    void
    user_function (MrpTask       *task,
                   MrpAssignment *assignment,
                   gpointer       user_data)

emitted when `assignment` is removed.

#### Parameters

task | the object which received the signal. |
assignment | the removed MrpAssignment. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“child-added”` signal

    void
    user_function (MrpTask *task,
                   gpointer user_data)

emitted when a child is added.

#### Parameters

task | the object which received the signal. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“child-removed”` signal

    void
    user_function (MrpTask *task,
                   gpointer user_data)

emitted when a child is removed.

#### Parameters

task | the object which received the signal. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“relation-added”` signal

    void
    user_function (MrpTask *task,
                   gpointer relation,
                   gpointer user_data)

emitted when `relation` is added.

#### Parameters

task | the object which received the signal. |
relation | the added MrpRelation. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“relation-removed”` signal

    void
    user_function (MrpTask *task,
                   gpointer relation,
                   gpointer user_data)

emitted when `relation` is removed.

#### Parameters

task | the object which received the signal. |
relation | the removed MrpRelation |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“task-moved”` signal

    void
    user_function (MrpTask *task,
                   MrpTask *other_task,
                   int      arg2,
                   gpointer user_data)

emitted when `other_task` is moved.

#### Parameters

task | the object which received the signal. |
other_task | another MrpTask. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last