Dmap.Db

g Dmap.Db Dmap.Db GObject.GInterface GObject.GInterface GObject.GInterface->Dmap.Db

Implementations:

None

Methods

add (record)

add_path (path)

add_with_id (record, id)

apply_filter (filter_def)

count ()

foreach (func, *data)

lookup_by_id (id)

lookup_id_by_location (location)

Virtual Methods

do_add (record)

do_add_path (path)

do_add_with_id (record, id)

do_count ()

do_foreach (func, data)

do_lookup_by_id (id)

do_lookup_id_by_location (location)

Properties

None

Signals

None

Fields

None

Class Details

class Dmap.Db
Bases:

GObject.GInterface

Structure:

Dmap.DbInterface

add(record)
Parameters:

record (Dmap.Record) – A database record.

Raises:

GLib.Error

Returns:

The ID for the newly added record or Dmap.DbId.BAD on failure. A reference to the record will be retained by the database (if required; an adapter-type implementation might not want to retain a reference as the record data may be placed elsewhere). In all cases, a returned record should be unrefed by the calling code.

Return type:

int

Add a record to the database.

add_path(path)
Parameters:

path (str) – A path to an appropriate media file.

Raises:

GLib.Error

Returns:

The ID for the newly added record or Dmap.DbId.BAD on failure.

See also the notes for Dmap.Db.add regarding reference counting.

Return type:

int

Create a record and add it to the database.

add_with_id(record, id)
Parameters:
  • record (Dmap.Record) – A database record.

  • id (int) – A database record ID.

Raises:

GLib.Error

Returns:

The ID for the newly added record or Dmap.DbId.BAD on failure.

See also the notes for Dmap.Db.add regarding reference counting.

Return type:

int

Add a record to the database and assign it the given ID. id cannot be Dmap.DbId.BAD.

apply_filter(filter_def)
Parameters:

filter_def ([Dmap.DbFilterDefinition]) – A series of filter definitions.

Returns:

the records which satisfy a record in filter_def.

Return type:

{int: Dmap.Record}

count()
Returns:

the number of records in the database.

Return type:

int

foreach(func, *data)
Parameters:
  • func (Dmap.IdRecordFunc) – The function to apply to each record in the database.

  • data (object or None) – User data to pass to the function.

Apply a function to each record in a media database.

lookup_by_id(id)
Parameters:

id (int) – A record ID.

Returns:

the database record corresponding to id. id cannot be Dmap.DbId.BAD. The returned record should be unrefed by the calling code when no longer required.

If you are implementing a full database using this API, then you probably want to increment the reference count before returning a record pointer.

On the other hand, if you are implementing an adapter class and the records are stored elsewhere, then you will probably return a transient record. That is, once the user is done using it, the returned record should be free’d because it is a adapter copy of the real record. In this case, the reference count should not be incremented before returning a record pointer.

Return type:

Dmap.Record

lookup_id_by_location(location)
Parameters:

location (str) – A record location.

Returns:

the database id for the record corresponding to path or Dmap.DbId.BAD if such a record does not exist.

Return type:

int

do_add(record) virtual
Parameters:

record (Dmap.Record) – A database record.

Returns:

The ID for the newly added record or Dmap.DbId.BAD on failure. A reference to the record will be retained by the database (if required; an adapter-type implementation might not want to retain a reference as the record data may be placed elsewhere). In all cases, a returned record should be unrefed by the calling code.

Return type:

int

Add a record to the database.

do_add_path(path) virtual
Parameters:

path (str) – A path to an appropriate media file.

Returns:

The ID for the newly added record or Dmap.DbId.BAD on failure.

See also the notes for Dmap.Db.add regarding reference counting.

Return type:

int

Create a record and add it to the database.

do_add_with_id(record, id) virtual
Parameters:
  • record (Dmap.Record) – A database record.

  • id (int) – A database record ID.

Returns:

The ID for the newly added record or Dmap.DbId.BAD on failure.

See also the notes for Dmap.Db.add regarding reference counting.

Return type:

int

Add a record to the database and assign it the given ID. id cannot be Dmap.DbId.BAD.

do_count() virtual
Return type:

int

do_foreach(func, data) virtual
Parameters:
  • func (Dmap.IdRecordFunc) – The function to apply to each record in the database.

  • data (object or None) – User data to pass to the function.

Apply a function to each record in a media database.

do_lookup_by_id(id) virtual
Parameters:

id (int) – A record ID.

Returns:

the database record corresponding to id. id cannot be Dmap.DbId.BAD. The returned record should be unrefed by the calling code when no longer required.

If you are implementing a full database using this API, then you probably want to increment the reference count before returning a record pointer.

On the other hand, if you are implementing an adapter class and the records are stored elsewhere, then you will probably return a transient record. That is, once the user is done using it, the returned record should be free’d because it is a adapter copy of the real record. In this case, the reference count should not be incremented before returning a record pointer.

Return type:

Dmap.Record

do_lookup_id_by_location(location) virtual
Parameters:

location (str) – A record location.

Returns:

the database id for the record corresponding to path or Dmap.DbId.BAD if such a record does not exist.

Return type:

int