## TrackerResource

TrackerResource — Represents a single Tracker resource

## Stability Level

Stable, unless otherwise indicated

## Functions

TrackerResource * | tracker_resource_new ()
void | tracker_resource_set_boolean ()
void | tracker_resource_set_double ()
void | tracker_resource_set_gvalue ()
void | tracker_resource_set_identifier ()
void | tracker_resource_set_int ()
void | tracker_resource_set_int64 ()
void | tracker_resource_set_relation ()
void | tracker_resource_set_string ()
void | tracker_resource_set_uri ()
void | tracker_resource_add_boolean ()
void | tracker_resource_add_double ()
void | tracker_resource_add_gvalue ()
void | tracker_resource_add_int ()
void | tracker_resource_add_int64 ()
void | tracker_resource_add_relation ()
void | tracker_resource_add_string ()
void | tracker_resource_add_uri ()
gboolean | tracker_resource_get_first_boolean ()
double | tracker_resource_get_first_double ()
int | tracker_resource_get_first_int ()
gint64 | tracker_resource_get_first_int64 ()
TrackerResource * | tracker_resource_get_first_relation ()
const char * | tracker_resource_get_first_string ()
const char * | tracker_resource_get_first_uri ()
const char * | tracker_resource_get_identifier ()
GList * | tracker_resource_get_values ()
gint | tracker_resource_identifier_compare_func ()
char * | tracker_resource_print_sparql_update ()
char * | tracker_resource_print_turtle ()

## Properties

gchar * | identifier | Read / Write

## Types and Values

| TrackerResource

## Object Hierarchy

        GObject
        ╰── TrackerResource

## Includes

    #include <tracker-resource.h>

## Description

TrackerResource keeps track of a set of properties for a given resource. The resulting data can be serialized in several ways.

## Functions

### tracker_resource_new ()

    TrackerResource *
    tracker_resource_new (const char *identifier);

Creates a TrackerResource instance.

#### Parameters

identifier | A string containing a URI |

#### Returns

a newly created TrackerResource. Free with `g_object_unref()` when done

Since: 1.10

### tracker_resource_set_boolean ()

    void
    tracker_resource_set_boolean (TrackerResource *self,
                                  const char *property_uri,
                                  gboolean value);

Sets a single-valued boolean object.

#### Parameters

self | the TrackerResource |
property_uri | a string identifying the property to modify |
value | the property object |

Since: 1.10

### tracker_resource_set_double ()

    void
    tracker_resource_set_double (TrackerResource *self,
                                 const char *property_uri,
                                 double value);

Sets a single-valued double object.

#### Parameters

self | the TrackerResource |
property_uri | a string identifying the property to modify |
value | the property object |

Since: 1.10

### tracker_resource_set_gvalue ()

    void
    tracker_resource_set_gvalue (TrackerResource *self,
                                 const char *property_uri,
                                 const GValue *value);

State that the only value for the given property is 'value'. Any existing values for 'property' will be removed.

When serialising to SPARQL, any properties that were set with this function will get a corresponding DELETE statement to remove any existing values in the database.

You can pass any kind of GValue for `value` , but serialization functions will normally only be able to serialize URIs/relationships and fundamental value types (string, int, etc.).

#### Parameters

self | the TrackerResource |
property_uri | a string identifying the property to set |
value | an initialised GValue |

Since: 1.10

### tracker_resource_set_identifier ()

    void
    tracker_resource_set_identifier (TrackerResource *self,
                                     const char *identifier);

Changes the identifier of a TrackerResource. The identifier should be a URI or compact URI, but this is not necessarily enforced. Invalid identifiers may cause errors when serializing the resource or trying to insert the results in a database.

If the identifier is set to NULL, a SPARQL blank node identifier such as "_:123" is assigned to the resource.

#### Parameters

self | a TrackerResource |
identifier | a string identifying the resource. | [allow-none]

Since: 1.10

### tracker_resource_set_int ()

    void
    tracker_resource_set_int (TrackerResource *self,
                              const char *property_uri,
                              int value);

Sets a single-valued integer object.

#### Parameters

self | the TrackerResource |
property_uri | a string identifying the property to modify |
value | the property object |

Since: 1.10

### tracker_resource_set_int64 ()

    void
    tracker_resource_set_int64 (TrackerResource *self,
                                const char *property_uri,
                                gint64 value);

Sets a single-valued integer object.

#### Parameters

self | the TrackerResource |
property_uri | a string identifying the property to modify |
value | the property object |

Since: 1.10

### tracker_resource_set_relation ()

    void
    tracker_resource_set_relation (TrackerResource *self,
                                   const char *property_uri,
                                   TrackerResource *resource);

Sets a single-valued resource object as a TrackerResource. This function produces similar RDF to `tracker_resource_set_uri()`, although in this function the URI will depend on the identifier set on `resource` .

#### Parameters

self | the TrackerResource |
property_uri | a string identifying the property to modify |
resource | the property object |

Since: 1.10

### tracker_resource_set_string ()

    void
    tracker_resource_set_string (TrackerResource *self,
                                 const char *property_uri,
                                 const char *value);

Sets a single-valued string object.

#### Parameters

self | the TrackerResource |
property_uri | a string identifying the property to modify |
value | the property object |

Since: 1.10

### tracker_resource_set_uri ()

    void
    tracker_resource_set_uri (TrackerResource *self,
                              const char *property_uri,
                              const char *value);

Sets a single-valued resource object as a string URI. This function produces similar RDF to `tracker_resource_set_relation()`, although it requires that the URI is previously known.

#### Parameters

self | the TrackerResource |
property_uri | a string identifying the property to modify |
value | the property object |

Since: 1.10

### tracker_resource_add_boolean ()

    void
    tracker_resource_add_boolean (TrackerResource *self,
                                  const char *property_uri,
                                  gboolean value);

Adds an integer object to a multi-valued property.

#### Parameters

self | the TrackerResource |
property_uri | a string identifying the property to modify |
value | the property object |

Since: 1.10

### tracker_resource_add_double ()

    void
    tracker_resource_add_double (TrackerResource *self,
                                 const char *property_uri,
                                 double value);

Adds a double object to a multi-valued property.

#### Parameters

self | the TrackerResource |
property_uri | a string identifying the property to modify |
value | the property object |

Since: 1.10

### tracker_resource_add_gvalue ()

    void
    tracker_resource_add_gvalue (TrackerResource *self,
                                 const char *property_uri,
                                 const GValue *value);

Add 'value' to the list of values for given property.

You can pass any kind of GValue for `value` , but serialization functions will normally only be able to serialize URIs/relationships and fundamental value types (string, int, etc.).

#### Parameters

self | the TrackerResource |
property_uri | a string identifying the property to set |
value | an initialised GValue |

Since: 1.10

### tracker_resource_add_int ()

    void
    tracker_resource_add_int (TrackerResource *self,
                              const char *property_uri,
                              int value);

Adds an integer object to a multi-valued property.

#### Parameters

self | the TrackerResource |
property_uri | a string identifying the property to modify |
value | the property object |

Since: 1.10

### tracker_resource_add_int64 ()

    void
    tracker_resource_add_int64 (TrackerResource *self,
                                const char *property_uri,
                                gint64 value);

### tracker_resource_add_relation ()

    void
    tracker_resource_add_relation (TrackerResource *self,
                                   const char *property_uri,
                                   TrackerResource *resource);

Adds a resource object to a multi-valued property. This function produces similar RDF to `tracker_resource_add_uri()`, although in this function the URI will depend on the identifier set on `resource` .

#### Parameters

self | the TrackerResource |
property_uri | a string identifying the property to modify |
resource | the property object |

Since: 1.10

### tracker_resource_add_string ()

    void
    tracker_resource_add_string (TrackerResource *self,
                                 const char *property_uri,
                                 const char *value);

Adds a string object to a multi-valued property.

#### Parameters

self | the TrackerResource |
property_uri | a string identifying the property to modify |
value | the property object |

Since: 1.10

### tracker_resource_add_uri ()

    void
    tracker_resource_add_uri (TrackerResource *self,
                              const char *property_uri,
                              const char *value);

Adds a resource object to a multi-valued property. This function produces similar RDF to `tracker_resource_add_relation()`, although it requires that the URI is previously known.

#### Parameters

self | the TrackerResource |
property_uri | a string identifying the property to modify |
value | the property object |

Since: 1.10

### tracker_resource_get_first_boolean ()

    gboolean
    tracker_resource_get_first_boolean (TrackerResource *self,
                                        const char *property_uri);

Returns the first boolean object previously assigned to a property.

#### Parameters

self | A TrackerResource |
property_uri | a string identifying the property to look up |

#### Returns

the first boolean object

Since: 1.10

### tracker_resource_get_first_double ()

    double
    tracker_resource_get_first_double (TrackerResource *self,
                                       const char *property_uri);

Returns the first double object previously assigned to a property.

#### Parameters

self | A TrackerResource |
property_uri | a string identifying the property to look up |

#### Returns

the first double object

Since: 1.10

### tracker_resource_get_first_int ()

    int
    tracker_resource_get_first_int (TrackerResource *self,
                                    const char *property_uri);

Returns the first integer object previously assigned to a property.

#### Parameters

self | A TrackerResource |
property_uri | a string identifying the property to look up |

#### Returns

the first integer object

Since: 1.10

### tracker_resource_get_first_int64 ()

    gint64
    tracker_resource_get_first_int64 (TrackerResource *self,
                                      const char *property_uri);

Returns the first integer object previously assigned to a property.

#### Parameters

self | A TrackerResource |
property_uri | a string identifying the property to look up |

#### Returns

the first integer object

Since: 1.10

### tracker_resource_get_first_relation ()

    TrackerResource *
    tracker_resource_get_first_relation (TrackerResource *self,
                                         const char *property_uri);

Returns the first resource object previously assigned to a property.

#### Parameters

self | A TrackerResource |
property_uri | a string identifying the property to look up |

#### Returns

the first resource object

Since: 1.10

### tracker_resource_get_first_string ()

    const char *
    tracker_resource_get_first_string (TrackerResource *self,
                                       const char *property_uri);

Returns the first string object previously assigned to a property.

#### Parameters

self | A TrackerResource |
property_uri | a string identifying the property to look up |

#### Returns

the first string object

Since: 1.10

### tracker_resource_get_first_uri ()

    const char *
    tracker_resource_get_first_uri (TrackerResource *self,
                                    const char *property_uri);

Returns the first resource object previously assigned to a property.

#### Parameters

self | A TrackerResource |
property_uri | a string identifying the property to look up |

#### Returns

the first resource object as an URI.

Since: 1.10

### tracker_resource_get_identifier ()

    const char *
    tracker_resource_get_identifier (TrackerResource *self);

Returns the identifier of a resource.

If the identifier was set to NULL, the identifier returned will be a unique SPARQL blank node identifier, such as "_:123".

#### Parameters

self | A TrackerResource |

#### Returns

a string owned by the resource

Since: 1.10

### tracker_resource_get_values ()

    GList *
    tracker_resource_get_values (TrackerResource *self,
                                 const char *property_uri);

Returns the list of all known values of the given property.

#### Parameters

self | the TrackerResource |
property_uri | a string identifying the property to look up |

#### Returns

a GList of GValue instances, which must be freed by the caller.

Since: 1.10

### tracker_resource_identifier_compare_func ()

    gint
    tracker_resource_identifier_compare_func
                                   (TrackerResource *resource,
                                    const char *identifier);

### tracker_resource_print_sparql_update ()

    char *
    tracker_resource_print_sparql_update (TrackerResource *self,
                                          TrackerNamespaceManager *namespaces,
                                          const char *graph_id);

Generates a SPARQL command to update a database with the information stored in `resource` .

The `namespaces` object is used to expand any compact URI values. In most cases you should pass `NULL`, which means the set of namespaces returned by `tracker_namespace_manager_get_default()` will be used. This defines the usual prefixes for all of the ontologies that Tracker ships with by default.

#### Parameters

self | a TrackerResource |
namespaces | a set of prefixed URLs, or `NULL` to use the default set. | [allow-none]
graph_id | the URN of the graph the data should be added to, or `NULL`. | [allow-none]

#### Returns

a newly-allocated string containing a SPARQL update command.

Since: 1.10

### tracker_resource_print_turtle ()

    char *
    tracker_resource_print_turtle (TrackerResource *self,
                                   TrackerNamespaceManager *namespaces);

Serialize all the information in `resource` as a Turtle document.

The generated Turtle should correspond to this standard: https://www.w3.org/TR/2014/REC-turtle-20140225/

The `namespaces` object is used to expand any compact URI values. In most cases you should pass `NULL`, which means the set of namespaces returned by `tracker_namespace_manager_get_default()` will be used. This defines the usual prefixes for all of the ontologies that Tracker ships with by default.

#### Parameters

self | a TrackerResource |
namespaces | a set of prefixed URLs, or `NULL` to use the default set. | [allow-none]

#### Returns

a newly-allocated string

Since: 1.10

## Types and Values

### TrackerResource

    typedef struct _TrackerResource TrackerResource;

The TrackerResource object represents information about a given resource.

## Property Details

### The `“identifier”` property

      “identifier”               gchar *

The URI identifier for this class, or `NULL` for a blank node.

Flags: Read / Write

Default value: NULL