## dmap-db dmap-db |

## Synopsis

    #define             TYPE_DMAP_DB
    #define             DMAP_DB                             (o)
    #define             IS_DMAP_DB                          (o)
    #define             DMAP_DB_GET_INTERFACE               (o)
                        DMAPDb;
                        DMAPDbInterface;
    const char *        (*RecordGetValueFunc)               (DMAPRecord *record);
                        FilterDefinition;
    GType               dmap_db_get_type                    (void);
    guint               dmap_db_add                         (DMAPDb *db,
                                                             DMAPRecord *record);
    guint               dmap_db_add_with_id                 (DMAPDb *db,
                                                             DMAPRecord *record,
                                                             guint id);
    guint               dmap_db_add_path                    (DMAPDb *db,
                                                             const gchar *path);
    DMAPRecord *        dmap_db_lookup_by_id                (const DMAPDb *db,
                                                             guint id);
    guint               dmap_db_lookup_id_by_location       (const DMAPDb *db,
                                                             const gchar *location);
    void                dmap_db_foreach                     (const DMAPDb *db,
                                                             GHFunc func,
                                                             gpointer data);
    gulong              dmap_db_count                       (const DMAPDb *db);
    GHashTable *        dmap_db_apply_filter                (DMAPDb *db,
                                                             GSList *filter_def);

## Object Hierarchy

      GInterface
       +----DMAPDb

## Description

## Details

### TYPE_DMAP_DB

    #define TYPE_DMAP_DB		 (dmap_db_get_type ())

The type for DMAPDb.

### DMAP_DB()

    #define             DMAP_DB(o)

Casts a DMAPDb or derived pointer into a (DMAPDb *) pointer. Depending on the current debugging level, this function may invoke certain runtime checks to identify invalid casts.

`o` : | Object which is subject to casting.

### IS_DMAP_DB()

    #define             IS_DMAP_DB(o)

Checks whether a valid GTypeInstance pointer is of type `TYPE_DMAP_DB`.

`o` : | Instance to check for being a `TYPE_DMAP_DB`.

### DMAP_DB_GET_INTERFACE()

    #define             DMAP_DB_GET_INTERFACE(o)

Get the insterface structure associated to a DMAPDb instance.

`o` : | a DMAPDb instance.
Returns : | pointer to object interface structure.

### DMAPDb

    typedef struct _DMAPDb DMAPDb;

### DMAPDbInterface

    typedef struct {
    	GTypeInterface parent;

    	guint (*add)		       (DMAPDb *db, DMAPRecord *record);
    	guint (*add_with_id)	       (DMAPDb *db,
    					DMAPRecord *record,
    					guint id);
    	guint (*add_path)	       (DMAPDb *db, const gchar *path);
    	DMAPRecord *(*lookup_by_id)    (const DMAPDb *db, guint id);
    	guint (*lookup_id_by_location) (const DMAPDb *db,
    					const gchar *location);
    	void (*foreach)		       (const DMAPDb *db,
    					GHFunc func,
    					gpointer data);
    	gint64 (*count) 	       (const DMAPDb *db);
    } DMAPDbInterface;

### RecordGetValueFunc ()

    const char *        (*RecordGetValueFunc)               (DMAPRecord *record);

`record` : |
Returns : |

### FilterDefinition

    typedef struct {
    	gchar *key;
    	gchar *value;
    	gboolean negate;
    } FilterDefinition;

### dmap_db_get_type ()

    GType               dmap_db_get_type                    (void);

Returns : |

### dmap_db_add ()

    guint               dmap_db_add                         (DMAPDb *db,
                                                             DMAPRecord *record);

Add a record to the database and assign it the given ID.

`db` : | A media database.
`record` : | A database record.
Returns : | The ID for the newly added record. See also the notes for dmap_db_add regarding reference counting.

### dmap_db_add_with_id ()

    guint               dmap_db_add_with_id                 (DMAPDb *db,
                                                             DMAPRecord *record,
                                                             guint id);

`db` : |
`record` : |
`id` : |
Returns : |

### dmap_db_add_path ()

    guint               dmap_db_add_path                    (DMAPDb *db,
                                                             const gchar *path);

Create a record and add it to the database.

`db` : | A media database.
`path` : | A path to an appropriate media file.
Returns : | The ID for the newly added record. See also the notes for dmap_db_add regarding reference counting.

### dmap_db_lookup_by_id ()

    DMAPRecord *        dmap_db_lookup_by_id                (const DMAPDb *db,
                                                             guint id);

`db` : | A media database.
`id` : | A record ID.
Returns : | the database record corresponding to `id`. This 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.

### dmap_db_lookup_id_by_location ()

    guint               dmap_db_lookup_id_by_location       (const DMAPDb *db,
                                                             const gchar *location);

`db` : | A media database.
`location` : | A record location.
Returns : | the database id for the record corresponding to `path` or 0 if such a record does not exist.

### dmap_db_foreach ()

    void                dmap_db_foreach                     (const DMAPDb *db,
                                                             GHFunc func,
                                                             gpointer data);

Apply a function to each record in a media database.

`db` : | A media database.
`func` : |
`data` : | User data to pass to the function.

### dmap_db_count ()

    gulong              dmap_db_count                       (const DMAPDb *db);

`db` : | A media database.
Returns : | the number of records in the database.

### dmap_db_apply_filter ()

    GHashTable *        dmap_db_apply_filter                (DMAPDb *db,
                                                             GSList *filter_def);

`db` : |
`filter_def` : |
Returns : |