EFL 1.7 svn doobies
[profile/ivi/eina.git] / src / include / eina_object.h
1 /* EINA - EFL data type library
2  * Copyright (C) 2011 Cedric Bail
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library 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 GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library;
16  * if not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #ifndef EINA_OBJECT_H__
20 #define EINA_OBJECT_H__
21
22 #include "eina_config.h"
23
24 #include "eina_types.h"
25
26 /**
27  * @addtogroup Eina_Object Object
28  *
29  * @brief These functions manage object providing pointer checking
30  * and memory repacking.
31  *
32  * Each Eina_Object is in fact only an ID and a generation count. This
33  * make it possible to check if the ID is allocated by checking that it
34  * is inside the boundary limit of the allocated range. The generation
35  * count, give the possibility to check that we use a valid alive pointer
36  * as generation is increased each time an object is allocated/destroyed.
37  * And finally it provide type checking against Eina_Class.
38  *
39  * It is also to define link between object, then when father get deleted
40  * all child will get deleted and their respective destructor will be called.
41  *
42  * @{
43  */
44
45 typedef struct _Eina_Class Eina_Class;
46 typedef struct _Eina_Object Eina_Object;
47
48 typedef void (*Eina_Class_Callback)(Eina_Class *c,
49                                     void *object,
50                                     void *data);
51
52 Eina_Class *eina_class_new(const char *name,
53                            unsigned int class_size,
54                            unsigned int pool_size,
55                            Eina_Class_Callback constructor,
56                            Eina_Class_Callback destructor,
57                            Eina_Class *parent,
58                            void *data);
59 const char *eina_class_name_get(Eina_Class *c);
60 unsigned int eina_class_size_get(Eina_Class *c);
61 unsigned int eina_class_object_size_get(Eina_Class *c);
62 void eina_class_del(Eina_Class *c);
63 void eina_class_repack(Eina_Class *c);
64
65 Eina_Object *eina_object_add(Eina_Class *c);
66 void *eina_object_pointer_get(Eina_Class *c,
67                               Eina_Object *object);
68 void eina_object_del(Eina_Class *c, 
69                      Eina_Object *object);
70
71 Eina_Bool eina_object_parent_set(Eina_Class *parent_class, Eina_Object *parent,
72                                  Eina_Class *object_class, Eina_Object *object);
73 Eina_Object *eina_object_parent_get(Eina_Class *c, Eina_Object *object);
74
75 /**
76  * @}
77  */
78
79 #endif