## MrpResource

MrpResource — represents a resource in the project.

## Functions

MrpResource * | mrp_resource_new ()
const gchar * | mrp_resource_get_name ()
void | mrp_resource_set_name ()
void | mrp_resource_assign ()
GList * | mrp_resource_get_assignments ()
GList * | mrp_resource_get_assigned_tasks ()
gint | mrp_resource_compare ()
MrpCalendar * | mrp_resource_get_calendar ()
void | mrp_resource_set_calendar ()

## Properties

gpointer | calendar | Read / Write
gfloat | cost | Read / Write
gchar * | email | Read / Write
MrpGroup * | group | Read / Write
gchar * | name | Read / Write
gchar * | note | Read / Write
gchar * | short-name | Read / Write
gint | type | Read / Write
gint | units | Read / Write

## Signals

void | assignment-added | Run Last
void | assignment-removed | Run Last

## Types and Values

| MrpResourcePriv
| MrpResource
enum | MrpResourceType

## Object Hierarchy

        GObject
        ╰── MrpObject
            ╰── MrpResource

## Includes

    #include <libplanner/planner.h>

## Description

## Functions

### mrp_resource_new ()

    MrpResource *
    mrp_resource_new (void);

Creates a new empty resource.

#### Returns

the newly created resource.

### mrp_resource_get_name ()

    const gchar *
    mrp_resource_get_name (MrpResource *resource);

Retrives the name of `resource` .

#### Parameters

resource | an MrpResource |

#### Returns

the name

### mrp_resource_set_name ()

    void
    mrp_resource_set_name (MrpResource *resource,
                           const gchar *name);

Sets the name of `resource` .

#### Parameters

resource | an MrpResource |
name | new name of `resource` |

### mrp_resource_assign ()

    void
    mrp_resource_assign (MrpResource *resource,
                         MrpTask *task,
                         gint units);

Assigns `resource` to `task` by the given amount of `units` . A value of 100 units corresponds to fulltime assignment.

#### Parameters

resource | an MrpResource |
task | an MrpTask |
units | the amount of units of assignment |

### mrp_resource_get_assignments ()

    GList *
    mrp_resource_get_assignments (MrpResource *resource);

Retrieves the assignments that this resource has. If caller needs to manipulate the returned list, a copy of it needs to be made.

#### Parameters

resource | an MrpResource. |

#### Returns

The assignments of `resource` . It should not be freed.

### mrp_resource_get_assigned_tasks ()

    GList *
    mrp_resource_get_assigned_tasks (MrpResource *resource);

Retrieves a list of all the tasks that this resource is assigned to. It is basically a convenience wrapper around `mrp_resource_get_assignments()`.

#### Parameters

resource | an MrpResource |

#### Returns

A list of the tasks that this resource is assigned to. Needs to be freed when not used anymore.

### mrp_resource_compare ()

    gint
    mrp_resource_compare (gconstpointer a,
                          gconstpointer b);

Comparison routine for resources. It is suitable for sorting, and only compares the resource name.

#### Parameters

a | an MrpResource |
b | an MrpResource |

#### Returns

-1 if `a` is less than `b` , 1 id `a` is greater than `b` , and 1 if equal.

### mrp_resource_get_calendar ()

    MrpCalendar *
    mrp_resource_get_calendar (MrpResource *resource);

Retrieves the calendar that is used for `resource` . If no calendar is set, `NULL` is returned, which means the project default calendar.

#### Parameters

resource | an MrpResource |

#### Returns

a MrpCalendar, or `NULL` if no specific calendar is set.

### mrp_resource_set_calendar ()

    void
    mrp_resource_set_calendar (MrpResource *resource,
                               MrpCalendar *calendar);

Sets the calendar to use for `resource` . `NULL` means to use the project default calendar.

#### Parameters

resource | an MrpResource |
calendar | the MrpCalendar to set, or `NULL` |

## Types and Values

### MrpResourcePriv

    typedef struct _MrpResourcePriv MrpResourcePriv;

A private struct for internal use only. The definition of this structure is not publically available.

### MrpResource

    typedef struct _MrpResource MrpResource;

Object representing a task in the project.

### enum MrpResourceType

The type of the resource, work or material.

#### Members

MRP_RESOURCE_TYPE_NONE | invalid type (unset) |
MRP_RESOURCE_TYPE_WORK | work resource |
MRP_RESOURCE_TYPE_MATERIAL | material resource |

## Property Details

### The `“calendar”` property

      “calendar”                 gpointer

The calendar this resource uses.

Flags: Read / Write

### The `“cost”` property

      “cost”                     gfloat

The standard cost of the resource.

Flags: Read / Write

Allowed values: >= 0

Default value: 0

### The `“email”` property

      “email”                    gchar *

The email address of the resource.

Flags: Read / Write

Default value: NULL

### The `“group”` property

      “group”                    MrpGroup *

The group that the resource belongs to.

Flags: Read / Write

### The `“name”` property

      “name”                     gchar *

The name of the resource.

Flags: Read / Write

Default value: NULL

### The `“note”` property

      “note”                     gchar *

Resource note.

Flags: Read / Write

Default value: ""

### The `“short-name”` property

      “short-name”               gchar *

The shorter name, initials or nickname of the resource.

Flags: Read / Write

Default value: NULL

### The `“type”` property

      “type”                     gint

The type of resource this is.

Flags: Read / Write

Allowed values: [0,2]

Default value: 1

### The `“units”` property

      “units”                    gint

The amount of units this resource has.

Flags: Read / Write

Allowed values: >= -1

Default value: 0

## Signal Details

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

    void
    user_function (MrpResource   *mrpresource,
                   MrpAssignment *arg1,
                   gpointer       user_data)

#### Parameters

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

Flags: Run Last

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

    void
    user_function (MrpResource   *mrpresource,
                   MrpAssignment *arg1,
                   gpointer       user_data)

#### Parameters

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

Flags: Run Last