Data Structures | Macros | Typedefs | Enumerations | Functions
Efl Class

Data Structures

struct  _Efl_Op_Description
 
struct  _Efl_Object_Ops
 This struct holds the ops and the size of the ops. More...
 
struct  _Efl_Class_Description
 This struct holds the description of a class. More...
 

Macros

#define EFL_CLASS_CLASS   efl_class_class_get()
 Abstract Efl class.
 
#define EFL_DEFINE_CLASS(class_get_func_name, class_desc, parent_class, ...)
 A convenience macro to be used for creating the class_get function. More...
 
#define EO_VERSION   2
 The current version of EO.
 
#define EFL_OPS_DEFINE(ops, ...)
 Define an array of override functions for efl_object_override. More...
 

Typedefs

typedef enum _Efl_Class_Type Efl_Class_Type
 A convenience typedef for _Efl_Class_Type.
 
typedef struct _Efl_Op_Description Efl_Op_Description
 
typedef struct _Efl_Object_Ops Efl_Object_Ops
 
typedef struct _Efl_Class_Description Efl_Class_Description
 A convenience typedef for _Efl_Class_Description.
 

Enumerations

enum  _Efl_Class_Type {
  EFL_CLASS_TYPE_REGULAR = 0,
  EFL_CLASS_TYPE_REGULAR_NO_INSTANT,
  EFL_CLASS_TYPE_INTERFACE,
  EFL_CLASS_TYPE_MIXIN
}
 An enum representing the possible types of an Eo class. More...
 

Functions

const Efl_Classefl_class_new (const Efl_Class_Description *desc, const Efl_Class *parent,...)
 Create a new class. More...
 
Eina_Bool efl_class_functions_set (const Efl_Class *klass_id, const Efl_Object_Ops *object_ops, const Efl_Object_Ops *class_ops)
 Set the functions of a class. More...
 
Eina_Bool efl_object_override (Eo *obj, const Efl_Object_Ops *ops)
 Override Eo functions of this object. More...
 
Eina_Bool efl_isa (const Eo *obj, const Efl_Class *klass)
 Check if an object "is a" klass. More...
 
const char * efl_class_name_get (const Efl_Class *klass)
 Gets the name of the passed class. More...
 

Detailed Description

Macro Definition Documentation

◆ EFL_DEFINE_CLASS

#define EFL_DEFINE_CLASS (   class_get_func_name,
  class_desc,
  parent_class,
  ... 
)
Value:
const Efl_Class * \
class_get_func_name(void) \
{ \
const Efl_Class *_tmp_parent_class; \
static const Efl_Class * volatile _my_class = NULL; \
static unsigned int _my_init_generation = 1; \
if (EINA_UNLIKELY(_efl_object_init_generation != _my_init_generation)) \
{ \
_my_class = NULL; /* It's freed in efl_object_shutdown(). */ \
} \
if (EINA_LIKELY(!!_my_class)) return _my_class; \
if (!!_my_class) \
{ \
eina_lock_release(&_efl_class_creation_lock); \
return _my_class; \
} \
_tmp_parent_class = parent_class; \
_my_class = efl_class_new(class_desc, _tmp_parent_class, __VA_ARGS__); \
_my_init_generation = _efl_object_init_generation; \
eina_lock_release(&_efl_class_creation_lock); \
\
return _my_class; \
}
const Efl_Class * efl_class_new(const Efl_Class_Description *desc, const Efl_Class *parent,...)
Create a new class.
Definition: eo.c:1351
EAPI Eina_Lock _efl_class_creation_lock
This variable is used for locking purposes in the class_get function defined in EFL_DEFINE_CLASS.
Definition: eo.c:39
#define EINA_UNLIKELY(exp)
Definition: eina_types.h:363
EAPI unsigned int _efl_object_init_generation
This variable stores the current eo init generation.
Definition: eo.c:40
#define EINA_LIKELY(exp)
Definition: eina_types.h:368
static Eina_Lock_Result eina_lock_take(Eina_Lock *mutex)
Attempts to take a lock.
Eo Efl_Class
The basic class type - should be removed, just for compat.
Definition: efl_class.eo.h:7

A convenience macro to be used for creating the class_get function.

This macro is fairly simple but should still be used as it'll let us improve things easily.

Parameters
class_get_func_namethe name of the wanted class_get function name.
class_descthe class description.
parent_classThe parent class for the function. Look at efl_class_new() for more information.
...List of extensions. Look at efl_class_new() for more information.

You must use this macro if you want thread safety in class creation.

◆ EFL_OPS_DEFINE

#define EFL_OPS_DEFINE (   ops,
  ... 
)
Value:
const Efl_Op_Description _##ops##_descs[] = { __VA_ARGS__ }; \
const Efl_Object_Ops ops = { _##ops##_descs, EINA_C_ARRAY_LENGTH(_##ops##_descs) }
#define EINA_C_ARRAY_LENGTH(arr)
Macro to return the array length of a standard c array.
Definition: eina_types.h:522
Definition: Eo.h:562
This struct holds the ops and the size of the ops.
Definition: Eo.h:573

Define an array of override functions for efl_object_override.

Parameters
opsA name for the Efl_Object_Ops local variable to define
...A comma separated list of Efl_Object_Op overrides, using #EFL_OBJECT_OP_FUNC or #EFL_OBJECT_OP_CLASS_FUNC

This can be used as follows:

EFL_OPS_DEFINE(ops, EFL_OBJECT_OP_FUNC(public_func, _my_func));
See also
efl_object_override

Enumeration Type Documentation

◆ _Efl_Class_Type

An enum representing the possible types of an Eo class.

Enumerator
EFL_CLASS_TYPE_REGULAR 

Regular class.

EFL_CLASS_TYPE_REGULAR_NO_INSTANT 

Regular non instant-able class.

EFL_CLASS_TYPE_INTERFACE 

Interface.

EFL_CLASS_TYPE_MIXIN 

Mixin.

Function Documentation

◆ efl_class_new()

const Efl_Class* efl_class_new ( const Efl_Class_Description desc,
const Efl_Class parent,
  ... 
)

Create a new class.

Parameters
descthe class description to create the class with.
parentthe class to inherit from.
...A NULL terminated list of extensions (interfaces, mixins and the classes of any composite objects).
Returns
The new class's handle on success, or NULL otherwise.
Note
There are two types of extensions, mixins and none-mixins. Mixins are inheriting api AND the implementation. Non-mixins only inherit the api, so a class which inherits a non-mixin as extension must implement the api.

You should use EFL_DEFINE_CLASS. It'll provide thread safety and other features easily.

See also
EFL_DEFINE_CLASS

◆ efl_class_functions_set()

Eina_Bool efl_class_functions_set ( const Efl_Class klass_id,
const Efl_Object_Ops object_ops,
const Efl_Object_Ops class_ops 
)

Set the functions of a class.

Parameters
klass_idthe class whose functions we are setting.
object_opsThe function structure we are setting for object functions
class_opsThe function structure we are setting for class functions
Returns
True on success, False otherwise.

This should only be called from within the initializer function.

See also
EFL_DEFINE_CLASS

References _Efl_Object_Ops::count, EINA_FALSE, EINA_TRUE, and ERR.

◆ efl_object_override()

Eina_Bool efl_object_override ( Eo obj,
const Efl_Object_Ops ops 
)

Override Eo functions of this object.

Parameters
opsThe op description to override with.
Returns
true on success, false otherwise.

This lets you override all of the Eo functions of this object (this one included) and repalce them with ad-hoc implementation. The contents of the array are copied so they can for example reside on the stack.

You are only allowed to override functions that are defined in the class or any of its interfaces (that is, efl_isa returning true).

If ops is #NULL, this will revert the obj to its original class without any function overrides.

It is not possible to override a function table of an object when it's already been overridden. Call efl_object_override(obj, NULL) first if you really need to do that.

References EINA_FALSE, eina_freeq_ptr_main_add(), EINA_TRUE, EINA_UNLIKELY, and ERR.

Referenced by efl_reuse().

◆ efl_isa()

Eina_Bool efl_isa ( const Eo obj,
const Efl_Class klass 
)

◆ efl_class_name_get()

const char* efl_class_name_get ( const Efl_Class klass)

Gets the name of the passed class.

Parameters
klassthe class to work on.
Returns
The class's name.
See also
efl_class_get()