1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 
3 #ifndef OBJECT_LIST_H
4 #define OBJECT_LIST_H
5 
6 #include <glib.h>
7 
8 typedef struct {
9     GHashTable  *obj_hash;
10     GPtrArray   *obj_ids;
11 } ObjectList;
12 
13 
14 ObjectList *
15 object_list_new ();
16 
17 void
18 object_list_free (ObjectList *ol);
19 
20 void
21 object_list_serialize (ObjectList *ol, uint8_t **buffer, uint32_t *len);
22 
23 /**
24  * Add object to ObjectList.
25  * Return FALSE if it is already in the list, TRUE otherwise.
26  */
27 gboolean
28 object_list_insert (ObjectList *ol, const char *object_id);
29 
30 inline static gboolean
object_list_exists(ObjectList * ol,const char * object_id)31 object_list_exists (ObjectList *ol, const char *object_id)
32 {
33     return (g_hash_table_lookup(ol->obj_hash, object_id) != NULL);
34 }
35 
36 inline static int
object_list_length(ObjectList * ol)37 object_list_length (ObjectList *ol)
38 {
39     return ol->obj_ids->len;
40 }
41 
42 #endif
43