Eobj: s/__UNUSED__/EINA_UNUSED/ I had no idea that exists.
[profile/ivi/eobj.git] / examples / composite_objects / comp.c
1 #include "Eobj.h"
2 #include "simple.h"
3
4 #include "comp.h"
5 #include "config.h"
6
7 #include "../eunit_tests.h"
8
9 EAPI Eobj_Op COMP_BASE_ID = 0;
10
11 static const Eobj_Class *_my_class = NULL;
12
13 static void
14 _a_get(Eobj *obj, void *class_data EINA_UNUSED, va_list *list)
15 {
16    int *a;
17    a = va_arg(*list, int *);
18    eobj_do_super(obj, SIMPLE_A_GET(a));
19 }
20
21 static void
22 _constructor(Eobj *obj, void *class_data EINA_UNUSED)
23 {
24    eobj_constructor_super(obj);
25
26    Eobj *simple = eobj_add(SIMPLE_CLASS, obj);
27    eobj_composite_object_attach(obj, simple);
28    eobj_event_callback_forwarder_add(simple, SIG_A_CHANGED, obj);
29
30    fail_if(eobj_composite_is(obj));
31    fail_if(!eobj_composite_is(simple));
32
33    eobj_do(obj, EOBJ_BASE_DATA_SET("simple-obj", simple, NULL));
34
35    eobj_unref(simple);
36 }
37
38 static void
39 _class_constructor(Eobj_Class *klass)
40 {
41    const Eobj_Op_Func_Description func_desc[] = {
42         EOBJ_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_GET), _a_get),
43         EOBJ_OP_FUNC_SENTINEL
44    };
45
46    eobj_class_funcs_set(klass, func_desc);
47 }
48
49 const Eobj_Class *
50 comp_class_get(void)
51 {
52    if (_my_class) return _my_class;
53
54    static const Eobj_Class_Description class_desc = {
55         "Comp",
56         EOBJ_CLASS_TYPE_REGULAR,
57         EOBJ_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
58         NULL,
59         0,
60         _constructor,
61         NULL,
62         _class_constructor,
63         NULL
64    };
65
66    return _my_class = eobj_class_new(&class_desc, EOBJ_BASE_CLASS,
67          SIMPLE_CLASS, NULL);
68 }