This is a documentation preview for the next version of Tracker, generated from tracker.git commit 22a1624.

See the Tracker website for more documentation.

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_datetime ()
void tracker_resource_set_relation ()
void tracker_resource_set_take_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_datetime ()
void tracker_resource_add_relation ()
void tracker_resource_add_take_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 ()
GDateTime * tracker_resource_get_first_datetime ()
const char * tracker_resource_get_first_uri ()
const char * tracker_resource_get_identifier ()
GList * tracker_resource_get_values ()
GList * tracker_resource_get_properties ()
gboolean tracker_resource_get_property_overwrite ()
gint tracker_resource_identifier_compare_func ()
char * tracker_resource_print_sparql_update ()
char * tracker_resource_print_turtle ()
char * tracker_resource_print_jsonld ()
GVariant * tracker_resource_serialize ()
TrackerResource * tracker_resource_deserialize ()

Properties

char * identifier Read / Write

Types and Values

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, or NULL.

[nullable]

Returns

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


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

 

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

 

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

 

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]

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

 

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

 

tracker_resource_set_datetime ()

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

Sets a single-valued GDateTime as a TrackerResource

Parameters

self

the TrackerResource

 

property_uri

a string identifying the property to modify

 

value

the property object

 

Since: 3.2


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

 

tracker_resource_set_take_relation ()

void
tracker_resource_set_take_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 . This function takes ownership of resource .

[skip]

Parameters

self

the TrackerResource

 

property_uri

a string identifying the property to modify

 

resource

the property object

 

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

 

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

 

tracker_resource_add_boolean ()

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

Adds a boolean object to a multi-valued property.

Parameters

self

the TrackerResource

 

property_uri

a string identifying the property to modify

 

value

the property object

 

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

 

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

 

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

 

tracker_resource_add_int64 ()

void
tracker_resource_add_int64 (TrackerResource *self,
                            const char *property_uri,
                            gint64 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

 

tracker_resource_add_datetime ()

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

Adds GDateTime object to the multi-valued property.

Parameters

self

the TrackerResource

 

property_uri

a string identifying the property to modify

 

value

the property object

 

Since: 3.2


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

 

tracker_resource_add_take_relation ()

void
tracker_resource_add_take_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 . This function takes ownership of resource .

[skip]

Parameters

self

the TrackerResource

 

property_uri

a string identifying the property to modify

 

resource

the property object

 

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

 

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

 

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


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


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


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


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.

[transfer none]


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


tracker_resource_get_first_datetime ()

GDateTime *
tracker_resource_get_first_datetime (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 GDateTime object

Since: 3.2


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.


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


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. The list should be freed with g_list_free().

[transfer container][element-type GValue]


tracker_resource_get_properties ()

GList *
tracker_resource_get_properties (TrackerResource *resource);

Gets the list of properties defined in resource

Parameters

resource

a TrackerResource

 

Returns

The list of properties. The list should be freed with g_list_free().

[transfer container][element-type utf8]

Since: 3.0


tracker_resource_get_property_overwrite ()

gboolean
tracker_resource_get_property_overwrite
                               (TrackerResource *resource,
                                const gchar *property_uri);

Returns whether the prior values for this property would be deleted in the SPARQL issued by resource .

Parameters

resource

a TrackerResource

 

property_uri

a string identifying the property to query

 

Returns

TRUE if the property would be overwritten

Since: 3.1


tracker_resource_identifier_compare_func ()

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

A helper function that compares a TrackerResource by its identifier string.

Parameters

resource

a TrackerResource

 

identifier

a string identifying the resource

 

Returns

an integer less than, equal to, or greater than zero, if the resource identifier is <, == or > than 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.


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


tracker_resource_print_jsonld ()

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

Serialize all the information in resource as a JSON-LD document.

See http://www.jsonld.org/ for more information on the JSON-LD serialization format.

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 containing JSON-LD data.


tracker_resource_serialize ()

GVariant *
tracker_resource_serialize (TrackerResource *resource);

Serializes a TrackerResource to a GVariant in a lossless way. All child resources are subsequently serialized. It is implied that both ends use a common TrackerNamespaceManager.

Parameters

resource

A TrackerResource

 

Returns

A variant describing the resource, the reference is floating.

[transfer full]


tracker_resource_deserialize ()

TrackerResource *
tracker_resource_deserialize (GVariant *variant);

Deserializes a TrackerResource previously serialized with tracker_resource_serialize(). It is implied that both ends use a common TrackerNamespaceManager.

Parameters

variant

a GVariant

 

Returns

A TrackerResource, or NULL if deserialization fails.

[transfer full]

Types and Values

TrackerResource

typedef struct _TrackerResource TrackerResource;

The TrackerResource object represents information about a given resource.


TRACKER_PREFIX_DC

#define TRACKER_PREFIX_DC       "http://purl.org/dc/elements/1.1/"

The Prefix of the DC (Dublin Core) namespace


TRACKER_PREFIX_MFO

#define TRACKER_PREFIX_MFO      "http://tracker.api.gnome.org/ontology/v3/mfo#"

The Prefix of the MFO namespace


TRACKER_PREFIX_NAO

#define TRACKER_PREFIX_NAO      "http://tracker.api.gnome.org/ontology/v3/nao#"

The Prefix of the NAO namespace


TRACKER_PREFIX_NCO

#define TRACKER_PREFIX_NCO      "http://tracker.api.gnome.org/ontology/v3/nco#"

The Prefix of the NCO namespace


TRACKER_PREFIX_NFO

#define TRACKER_PREFIX_NFO      "http://tracker.api.gnome.org/ontology/v3/nfo#"

The Prefix of the NFO namespace


TRACKER_PREFIX_NIE

#define TRACKER_PREFIX_NIE      "http://tracker.api.gnome.org/ontology/v3/nie#"

The Prefix of the NIE namespace


TRACKER_PREFIX_NMM

#define TRACKER_PREFIX_NMM      "http://tracker.api.gnome.org/ontology/v3/nmm#"

The Prefix of the RDF namespace


TRACKER_PREFIX_NRL

#define TRACKER_PREFIX_NRL      "http://tracker.api.gnome.org/ontology/v3/nrl#"

The Prefix of the NRL namespace


TRACKER_PREFIX_OSINFO

#define TRACKER_PREFIX_OSINFO   "http://tracker.api.gnome.org/ontology/v3/osinfo#"

The Prefix of the Osinfo namespace


TRACKER_PREFIX_RDF

#define TRACKER_PREFIX_RDF      "http://www.w3.org/1999/02/22-rdf-syntax-ns#"

The Prefix of the RDF namespace


TRACKER_PREFIX_RDFS

#define TRACKER_PREFIX_RDFS     "http://www.w3.org/2000/01/rdf-schema#"

The Prefix of the RDFS namespace


TRACKER_PREFIX_SLO

#define TRACKER_PREFIX_SLO      "http://tracker.api.gnome.org/ontology/v3/slo#"

The Prefix of the SLO namespace


TRACKER_PREFIX_TRACKER

#define TRACKER_PREFIX_TRACKER  "http://tracker.api.gnome.org/ontology/v3/tracker#"

The Prefix of the Tracker namespace


TRACKER_PREFIX_XSD

#define TRACKER_PREFIX_XSD      "http://www.w3.org/2001/XMLSchema#"

The Prefix of the XSD namespace

Property Details

The “identifier” property

  “identifier”               char *

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

Owner: TrackerResource

Flags: Read / Write

Default value: NULL