eina: add Eina_Object API.
This API is what could be used by all EFL library for their exposed
type (Evas_Object, Ecore_Timer, Ecore_Animator, Eio_File, ...). The
purpose of Eina_Object is to provide an "obscure" pointer that is
infact an ID with a generation count that will never be dereferenced
directly.
This provide the benefit of always accessing a living object
with 1/256 chance to being the expected generation of it, that will
always be of the right type.
It also provide asynchronous repacking ability (still highly
inefficient, but not really hard to improve), simple inheritance
with constructor/destructor and link between object.
All this implementation is highly open for comment, idea, review,
fix and change. I didn't got the time to write a sample test right
now. Maybe will come tomorrow. Same for docs.
SVN revision: 58562
2011-04-11 11:00:34 -07:00
|
|
|
/* EINA - EFL data type library
|
|
|
|
* Copyright (C) 2011 Cedric Bail
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library;
|
|
|
|
* if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef EINA_OBJECT_H__
|
|
|
|
#define EINA_OBJECT_H__
|
|
|
|
|
|
|
|
#include "eina_config.h"
|
|
|
|
|
|
|
|
#include "eina_types.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup Eina_Object Object
|
2012-12-18 10:38:25 -08:00
|
|
|
* @ingroup Eina
|
eina: add Eina_Object API.
This API is what could be used by all EFL library for their exposed
type (Evas_Object, Ecore_Timer, Ecore_Animator, Eio_File, ...). The
purpose of Eina_Object is to provide an "obscure" pointer that is
infact an ID with a generation count that will never be dereferenced
directly.
This provide the benefit of always accessing a living object
with 1/256 chance to being the expected generation of it, that will
always be of the right type.
It also provide asynchronous repacking ability (still highly
inefficient, but not really hard to improve), simple inheritance
with constructor/destructor and link between object.
All this implementation is highly open for comment, idea, review,
fix and change. I didn't got the time to write a sample test right
now. Maybe will come tomorrow. Same for docs.
SVN revision: 58562
2011-04-11 11:00:34 -07:00
|
|
|
*
|
|
|
|
* @brief These functions manage object providing pointer checking
|
|
|
|
* and memory repacking.
|
|
|
|
*
|
|
|
|
* Each Eina_Object is in fact only an ID and a generation count. This
|
|
|
|
* make it possible to check if the ID is allocated by checking that it
|
2012-06-16 06:33:58 -07:00
|
|
|
* is inside the boundary limit of the allocated range. The generation
|
eina: add Eina_Object API.
This API is what could be used by all EFL library for their exposed
type (Evas_Object, Ecore_Timer, Ecore_Animator, Eio_File, ...). The
purpose of Eina_Object is to provide an "obscure" pointer that is
infact an ID with a generation count that will never be dereferenced
directly.
This provide the benefit of always accessing a living object
with 1/256 chance to being the expected generation of it, that will
always be of the right type.
It also provide asynchronous repacking ability (still highly
inefficient, but not really hard to improve), simple inheritance
with constructor/destructor and link between object.
All this implementation is highly open for comment, idea, review,
fix and change. I didn't got the time to write a sample test right
now. Maybe will come tomorrow. Same for docs.
SVN revision: 58562
2011-04-11 11:00:34 -07:00
|
|
|
* count, give the possibility to check that we use a valid alive pointer
|
|
|
|
* as generation is increased each time an object is allocated/destroyed.
|
|
|
|
* And finally it provide type checking against Eina_Class.
|
|
|
|
*
|
|
|
|
* It is also to define link between object, then when father get deleted
|
|
|
|
* all child will get deleted and their respective destructor will be called.
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct _Eina_Class Eina_Class;
|
|
|
|
typedef struct _Eina_Object Eina_Object;
|
|
|
|
|
2011-04-12 20:08:58 -07:00
|
|
|
typedef void (*Eina_Class_Callback)(Eina_Class *c,
|
2015-04-09 22:13:11 -07:00
|
|
|
void *object,
|
|
|
|
void *data);
|
eina: add Eina_Object API.
This API is what could be used by all EFL library for their exposed
type (Evas_Object, Ecore_Timer, Ecore_Animator, Eio_File, ...). The
purpose of Eina_Object is to provide an "obscure" pointer that is
infact an ID with a generation count that will never be dereferenced
directly.
This provide the benefit of always accessing a living object
with 1/256 chance to being the expected generation of it, that will
always be of the right type.
It also provide asynchronous repacking ability (still highly
inefficient, but not really hard to improve), simple inheritance
with constructor/destructor and link between object.
All this implementation is highly open for comment, idea, review,
fix and change. I didn't got the time to write a sample test right
now. Maybe will come tomorrow. Same for docs.
SVN revision: 58562
2011-04-11 11:00:34 -07:00
|
|
|
|
|
|
|
Eina_Class *eina_class_new(const char *name,
|
2015-04-09 22:13:11 -07:00
|
|
|
unsigned int class_size,
|
|
|
|
unsigned int pool_size,
|
|
|
|
Eina_Class_Callback constructor,
|
|
|
|
Eina_Class_Callback destructor,
|
|
|
|
Eina_Class *parent,
|
|
|
|
void *data);
|
2011-04-12 20:08:58 -07:00
|
|
|
const char *eina_class_name_get(Eina_Class *c);
|
|
|
|
unsigned int eina_class_size_get(Eina_Class *c);
|
|
|
|
unsigned int eina_class_object_size_get(Eina_Class *c);
|
|
|
|
void eina_class_del(Eina_Class *c);
|
|
|
|
void eina_class_repack(Eina_Class *c);
|
eina: add Eina_Object API.
This API is what could be used by all EFL library for their exposed
type (Evas_Object, Ecore_Timer, Ecore_Animator, Eio_File, ...). The
purpose of Eina_Object is to provide an "obscure" pointer that is
infact an ID with a generation count that will never be dereferenced
directly.
This provide the benefit of always accessing a living object
with 1/256 chance to being the expected generation of it, that will
always be of the right type.
It also provide asynchronous repacking ability (still highly
inefficient, but not really hard to improve), simple inheritance
with constructor/destructor and link between object.
All this implementation is highly open for comment, idea, review,
fix and change. I didn't got the time to write a sample test right
now. Maybe will come tomorrow. Same for docs.
SVN revision: 58562
2011-04-11 11:00:34 -07:00
|
|
|
|
2011-04-12 20:08:58 -07:00
|
|
|
Eina_Object *eina_object_add(Eina_Class *c);
|
|
|
|
void *eina_object_pointer_get(Eina_Class *c,
|
2015-04-09 22:13:11 -07:00
|
|
|
Eina_Object *object);
|
|
|
|
void eina_object_del(Eina_Class *c,
|
|
|
|
Eina_Object *object);
|
eina: add Eina_Object API.
This API is what could be used by all EFL library for their exposed
type (Evas_Object, Ecore_Timer, Ecore_Animator, Eio_File, ...). The
purpose of Eina_Object is to provide an "obscure" pointer that is
infact an ID with a generation count that will never be dereferenced
directly.
This provide the benefit of always accessing a living object
with 1/256 chance to being the expected generation of it, that will
always be of the right type.
It also provide asynchronous repacking ability (still highly
inefficient, but not really hard to improve), simple inheritance
with constructor/destructor and link between object.
All this implementation is highly open for comment, idea, review,
fix and change. I didn't got the time to write a sample test right
now. Maybe will come tomorrow. Same for docs.
SVN revision: 58562
2011-04-11 11:00:34 -07:00
|
|
|
|
|
|
|
Eina_Bool eina_object_parent_set(Eina_Class *parent_class, Eina_Object *parent,
|
2015-04-09 22:13:11 -07:00
|
|
|
Eina_Class *object_class, Eina_Object *object);
|
2011-04-12 20:08:58 -07:00
|
|
|
Eina_Object *eina_object_parent_get(Eina_Class *c, Eina_Object *object);
|
eina: add Eina_Object API.
This API is what could be used by all EFL library for their exposed
type (Evas_Object, Ecore_Timer, Ecore_Animator, Eio_File, ...). The
purpose of Eina_Object is to provide an "obscure" pointer that is
infact an ID with a generation count that will never be dereferenced
directly.
This provide the benefit of always accessing a living object
with 1/256 chance to being the expected generation of it, that will
always be of the right type.
It also provide asynchronous repacking ability (still highly
inefficient, but not really hard to improve), simple inheritance
with constructor/destructor and link between object.
All this implementation is highly open for comment, idea, review,
fix and change. I didn't got the time to write a sample test right
now. Maybe will come tomorrow. Same for docs.
SVN revision: 58562
2011-04-11 11:00:34 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2015-04-09 22:13:11 -07:00
|
|
|
#endif
|