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

Data Structures

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

Macros

#define EFL_DEFINE_CLASS(class_get_func_name, class_desc, parent_class, ...)
 A convenient 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

EAPI const Efl_Classefl_class_new (const Efl_Class_Description *desc, const Efl_Class *parent,...)
 Create a new class. More...
 
EAPI 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...
 
EAPI Eina_Bool efl_object_override (Eo *obj, const Efl_Object_Ops *ops)
 Override Eo functions of this object. More...
 
EAPI Eina_Bool efl_isa (const Eo *obj, const Efl_Class *klass)
 Check if an object "is a" klass. More...
 
EAPI const char * efl_class_name_get (const Efl_Class *klass)
 Gets the name of the passed class. More...
 
EAPI const char * efl_debug_name_get (const Eo *obj_id)
 Gets a debug name for this object. 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; \
}
EAPI const Efl_Class * efl_class_new(const Efl_Class_Description *desc, const Efl_Class *parent,...)
Create a new class.
Definition: eo.c:1438
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:41
#define EINA_UNLIKELY(exp)
Definition: eina_types.h:380
EAPI unsigned int _efl_object_init_generation
This variable stores the current eo init generation.
Definition: eo.c:42
#define EINA_LIKELY(exp)
Definition: eina_types.h:386
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, for compatibility reasons.
Definition: Eo.h:179

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

This macro is fairly simple and makes for better code.

Parameters
class_get_func_namethe name of the wanted class_get function name.
class_descthe class description.
parent_classThe parent class for the function. See efl_class_new() for more information.
...List of extensions. See 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:558
Definition: Eo.h:799
This structure holds the ops and the size of the ops.
Definition: Eo.h:810

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()

EAPI 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' handle on success or NULL otherwise.
Note
There are two types of extensions, mixins and none-mixins. Mixins are inheriting both the API AND the implementation. Non-mixins only inherit the API, so a class which inherits a non-mixin as an extension must implement the api.

Use EFL_DEFINE_CLASS. This will provide thread safety and other features easily.

See also
EFL_DEFINE_CLASS

◆ efl_class_functions_set()

EAPI 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()

EAPI 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 replace them with ad-hoc implementation. The contents of the array are copied so they can reside on the stack for instance.

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.

See also
EFL_OPS_DEFINE

References EINA_FALSE, EINA_TRUE, and ERR.

Referenced by efl_reuse().

◆ efl_isa()

EAPI Eina_Bool efl_isa ( const Eo obj,
const Efl_Class klass 
)

◆ efl_class_name_get()

EAPI 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' name.
See also
efl_class_get()

Referenced by efl_object_shutdown(), and evas_object_del().

◆ efl_debug_name_get()

EAPI const char* efl_debug_name_get ( const Eo obj_id)

Gets a debug name for this object.

Parameters
obj_idThe object (or class)
Returns
A name to use in logs and for other debugging purposes

Note that subclasses can override Efl.Object "debug_name_override" to provide more meaningful debug strings. The standard format includes the class name, the object ID (this obj_id), the reference count and optionally the object name (as defined by Efl.Object.name).

This might return a temporary string, as created by eina_slstr, which means that a main loop should probably be running.

Since
1.21

References efl_cast(), EFL_CLASS_TYPE_INTERFACE, EFL_CLASS_TYPE_MIXIN, EFL_CLASS_TYPE_REGULAR, EFL_CLASS_TYPE_REGULAR_NO_INSTANT, efl_super(), EINA_FALSE, eina_strbuf_append_printf(), and eina_strbuf_new().