1 /* 2 * Database record interface for DMAP containers 3 * 4 * Copyright (C) 2008 W. Michael Petullo <mike@flyn.org> 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21 #ifndef __DMAP_CONTAINER_RECORD_H 22 #define __DMAP_CONTAINER_RECORD_H 23 24 #include <glib-object.h> 25 #include <libdmapsharing/dmap-db.h> 26 27 G_BEGIN_DECLS 28 /** 29 * DMAP_TYPE_CONTAINER_RECORD: 30 * 31 * The type for #DMAPContainerRecord. 32 */ 33 #define DMAP_TYPE_CONTAINER_RECORD (dmap_container_record_get_type ()) 34 /** 35 * DMAP_CONTAINER_RECORD: 36 * @o: Object which is subject to casting. 37 * 38 * Casts a #DMAPContainerRecord or derived pointer into a (DMAPContainerRecord*) 39 * pointer. Depending on the current debugging level, this function may invoke 40 * certain runtime checks to identify invalid casts. 41 */ 42 #define DMAP_CONTAINER_RECORD(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), \ 43 DMAP_TYPE_CONTAINER_RECORD, DMAPContainerRecord)) 44 /** 45 * IS_DMAP_CONTAINER_RECORD: 46 * @o: Instance to check for being a %DMAP_TYPE_CONTAINER_RECORD. 47 * 48 * Checks whether a valid #GTypeInstance pointer is of type 49 * %DMAP_TYPE_CONTAINER_RECORD. 50 */ 51 #define IS_DMAP_CONTAINER_RECORD(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), \ 52 DMAP_TYPE_CONTAINER_RECORD)) 53 /** 54 * DMAP_CONTAINER_RECORD_GET_INTERFACE: 55 * @o: a #DMAPContainerRecord instance. 56 * 57 * Get the class structure associated to a #DMAPContainerRecord instance. 58 * 59 * Returns: pointer to object interface structure. 60 */ 61 #define DMAP_CONTAINER_RECORD_GET_INTERFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), \ 62 DMAP_TYPE_CONTAINER_RECORD, DMAPContainerRecordIface)) 63 typedef struct _DMAPContainerRecord DMAPContainerRecord; 64 typedef struct _DMAPContainerRecordIface DMAPContainerRecordIface; 65 66 struct _DMAPContainerRecordIface 67 { 68 GTypeInterface parent; 69 70 guint (*get_id) (DMAPContainerRecord * record); 71 72 void (*add_entry) (DMAPContainerRecord * container_record, 73 DMAPRecord * record, gint id); 74 75 guint64 (*get_entry_count) (DMAPContainerRecord * record); 76 77 DMAPDb *(*get_entries) (DMAPContainerRecord * record); 78 }; 79 80 GType dmap_container_record_get_type (void); 81 82 /** 83 * dmap_container_record_get_id: 84 * @record: A DMAPContainerRecord. 85 * 86 * Returns: the ID for the given record. 87 */ 88 guint dmap_container_record_get_id (DMAPContainerRecord * record); 89 90 /** 91 * dmap_container_record_add_entry: 92 * @container_record: A DMAPContainerRecord. 93 * @record: A DMAPRecord. 94 * @id: The record's ID. 95 * 96 * Add a record to the database. It is assumed that the record is placed 97 * directly into the database (not copied) and not freed. 98 */ 99 void dmap_container_record_add_entry (DMAPContainerRecord * container_record, 100 DMAPRecord * record, gint id); 101 102 /** 103 * dmap_container_record_get_entry_count: 104 * @record: A DMAPContainerRecord. 105 * 106 * Returns: the number of records in the container record. 107 */ 108 guint64 dmap_container_record_get_entry_count (DMAPContainerRecord * record); 109 110 /** 111 * dmap_container_record_get_entries: 112 * @record: A DMAPContainerRecord. 113 * 114 * Returns: A pointer to a DMAPDb containing the entries contained in record. 115 */ 116 DMAPDb *dmap_container_record_get_entries (DMAPContainerRecord * record); 117 118 #endif /* __DMAP_CONTAINER_RECORD_H */ 119 120 G_END_DECLS 121