1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* NetworkManager -- Network link manager
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 * Copyright (C) 2015 Red Hat, Inc.
21 #ifndef __NM_MULTI_INDEX__
22 #define __NM_MULTI_INDEX__
24 #include "nm-default.h"
33 typedef struct NMMultiIndex NMMultiIndex;
37 const NMMultiIndex *_index;
49 typedef gboolean (*NMMultiIndexFuncEqual) (const NMMultiIndexId *id_a, const NMMultiIndexId *id_b);
50 typedef guint (*NMMultiIndexFuncHash) (const NMMultiIndexId *id);
51 typedef NMMultiIndexId *(*NMMultiIndexFuncClone) (const NMMultiIndexId *id);
52 typedef void (*NMMultiIndexFuncDestroy) (NMMultiIndexId *id);
54 typedef gboolean (*NMMultiIndexFuncForeach) (const NMMultiIndexId *id, void *const* values, guint len, gpointer user_data);
57 NMMultiIndex *nm_multi_index_new (NMMultiIndexFuncHash hash_fcn,
58 NMMultiIndexFuncEqual equal_fcn,
59 NMMultiIndexFuncClone clone_fcn,
60 NMMultiIndexFuncDestroy destroy_fcn);
62 void nm_multi_index_free (NMMultiIndex *index);
64 gboolean nm_multi_index_add (NMMultiIndex *index,
65 const NMMultiIndexId *id,
68 gboolean nm_multi_index_remove (NMMultiIndex *index,
69 const NMMultiIndexId *id,
72 gboolean nm_multi_index_move (NMMultiIndex *index,
73 const NMMultiIndexId *id_old,
74 const NMMultiIndexId *id_new,
77 guint nm_multi_index_get_num_groups (const NMMultiIndex *index);
79 void *const*nm_multi_index_lookup (const NMMultiIndex *index,
80 const NMMultiIndexId *id,
83 gboolean nm_multi_index_contains (const NMMultiIndex *index,
84 const NMMultiIndexId *id,
87 const NMMultiIndexId *nm_multi_index_lookup_first_by_value (const NMMultiIndex *index,
90 void nm_multi_index_foreach (const NMMultiIndex *index,
92 NMMultiIndexFuncForeach foreach_func,
95 void nm_multi_index_iter_init (NMMultiIndexIter *iter,
96 const NMMultiIndex *index,
98 gboolean nm_multi_index_iter_next (NMMultiIndexIter *iter,
99 const NMMultiIndexId **out_id,
100 void *const**out_values,
103 void nm_multi_index_id_iter_init (NMMultiIndexIdIter *iter,
104 const NMMultiIndex *index,
105 const NMMultiIndexId *id);
106 gboolean nm_multi_index_id_iter_next (NMMultiIndexIdIter *iter,
111 #endif /* __NM_MULTI_INDEX__ */