dbus-dataslot.h

00001 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
00002 /* dbus-dataslot.h  storing data on objects
00003  *
00004  * Copyright (C) 2003 Red Hat, Inc.
00005  *
00006  * Licensed under the Academic Free License version 2.1
00007  * 
00008  * This program is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  * 
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  *
00022  */
00023 #ifndef DBUS_DATASLOT_H
00024 #define DBUS_DATASLOT_H
00025 
00026 #include <dbus/dbus-internals.h>
00027 
00028 DBUS_BEGIN_DECLS
00029 
00030 typedef struct DBusDataSlotAllocator DBusDataSlotAllocator;
00031 typedef struct DBusDataSlotList DBusDataSlotList;
00032 
00034 typedef struct DBusDataSlot DBusDataSlot;
00036 struct DBusDataSlot
00037 {
00038   void *data;                      
00039   DBusFreeFunction free_data_func; 
00040 };
00041 
00042 typedef struct DBusAllocatedSlot DBusAllocatedSlot;
00043 
00046 struct DBusAllocatedSlot
00047 {
00048   dbus_int32_t slot_id;  
00049   int          refcount; 
00050 };
00051 
00055 struct DBusDataSlotAllocator
00056 {
00057   DBusAllocatedSlot *allocated_slots; 
00058   int  n_allocated_slots; 
00059   int  n_used_slots;      
00060   DBusMutex **lock_loc;   
00061 };
00062 
00067 struct DBusDataSlotList
00068 {
00069   DBusDataSlot *slots;   
00070   int           n_slots; 
00071 };
00072 
00073 dbus_bool_t _dbus_data_slot_allocator_init  (DBusDataSlotAllocator  *allocator);
00074 dbus_bool_t _dbus_data_slot_allocator_alloc (DBusDataSlotAllocator  *allocator,
00075                                              DBusMutex              **mutex_loc,
00076                                              int                    *slot_id_p);
00077 void        _dbus_data_slot_allocator_free  (DBusDataSlotAllocator  *allocator,
00078                                              int                    *slot_id_p);
00079 void        _dbus_data_slot_list_init       (DBusDataSlotList       *list);
00080 dbus_bool_t _dbus_data_slot_list_set        (DBusDataSlotAllocator  *allocator,
00081                                              DBusDataSlotList       *list,
00082                                              int                     slot,
00083                                              void                   *data,
00084                                              DBusFreeFunction        free_data_func,
00085                                              DBusFreeFunction       *old_free_func,
00086                                              void                  **old_data);
00087 void*       _dbus_data_slot_list_get        (DBusDataSlotAllocator  *allocator,
00088                                              DBusDataSlotList       *list,
00089                                              int                     slot);
00090 void        _dbus_data_slot_list_clear      (DBusDataSlotList       *list);
00091 void        _dbus_data_slot_list_free       (DBusDataSlotList       *list);
00092 
00093 
00094 DBUS_END_DECLS
00095 
00096 #endif /* DBUS_DATASLOT_H */

Generated on Tue Feb 24 16:40:39 2009 for D-Bus by  doxygen 1.5.1