Debian Codegraph @

src/common/rcm.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2004 Dizzy
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
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.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 /*
20 * Reference Change Mechanism
21 * an abstract interface to implement safe management of references of objects
22 * which do not share any specific dependencies
23 */
24
25 #ifndef __RCM_H_TYPES__
26 #define __RCM_H_TYPES__
27
28 #include "common/elist.h"
29
30 namespace pvpgn
31 {
32
33 /* reference change mechanism main object
34 * an object which wishes to be referenced using RCM has to include this */
35 typedef struct {
36 unsigned count;
37 t_elist refs; /* list of registered references */
38 } t_rcm;
39
40 /* callback called when the object referenced is moved/deleted */
41 typedef int(*t_chref_cb)(void *data, void *newref);
42
43 /* registered reference object
44 * an object which wants to register it's references to an rcm enabled object
45 * will have to include one of this for every rcm enabled referenced object
46 */
47 typedef struct {
48 t_chref_cb chref;
49 void *data;
50 t_elist refs_link;
51 } t_rcm_regref;
52
53 }
54
55 #endif /* __RCM_H_TYPES__ */
56
57 #ifndef __RCM_H_PROTOS__
58 #define __RCM_H_PROTOS__
59
60 namespace pvpgn
61 {
62
63 extern void rcm_init(t_rcm *rcm);
64 extern void rcm_regref_init(t_rcm_regref *regref, t_chref_cb cb, void *data);
65 extern void rcm_get(t_rcm *rcm, t_rcm_regref *regref);
66 extern void rcm_put(t_rcm *rcm, t_rcm_regref *regref);
67 /* the main function, cycles through the registered references and calls the
68 * registered callback with the new reference */
69 extern void rcm_chref(t_rcm *rcm, void *newref);
70
71 }
72
73 #endif /* __RCM_H_PROTOS__ */