D-Bus  1.10.12
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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  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   DBusGlobalLock lock;    
00061 };
00062 
00063 #define _DBUS_DATA_SLOT_ALLOCATOR_INIT(x) { NULL, 0, 0, x }
00064 
00069 struct DBusDataSlotList
00070 {
00071   DBusDataSlot *slots;   
00072   int           n_slots; 
00073 };
00074 
00075 dbus_bool_t _dbus_data_slot_allocator_init  (DBusDataSlotAllocator  *allocator,
00076                                              DBusGlobalLock          lock);
00077 dbus_bool_t _dbus_data_slot_allocator_alloc (DBusDataSlotAllocator  *allocator,
00078                                              int                    *slot_id_p);
00079 void        _dbus_data_slot_allocator_free  (DBusDataSlotAllocator  *allocator,
00080                                              int                    *slot_id_p);
00081 void        _dbus_data_slot_list_init       (DBusDataSlotList       *list);
00082 dbus_bool_t _dbus_data_slot_list_set        (DBusDataSlotAllocator  *allocator,
00083                                              DBusDataSlotList       *list,
00084                                              int                     slot,
00085                                              void                   *data,
00086                                              DBusFreeFunction        free_data_func,
00087                                              DBusFreeFunction       *old_free_func,
00088                                              void                  **old_data);
00089 void*       _dbus_data_slot_list_get        (DBusDataSlotAllocator  *allocator,
00090                                              DBusDataSlotList       *list,
00091                                              int                     slot);
00092 void        _dbus_data_slot_list_clear      (DBusDataSlotList       *list);
00093 void        _dbus_data_slot_list_free       (DBusDataSlotList       *list);
00094 
00095 
00096 DBUS_END_DECLS
00097 
00098 #endif /* DBUS_DATASLOT_H */