summaryrefslogtreecommitdiff
path: root/src/tests/eo/suite/eo_test_class_singleton.c
blob: b6ed50dca05655d2a7d52ddc5fcfe1dc5fbae67b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include "Eo.h"
#include "eo_test_class_singleton.h"
#include "eo_test_class_simple.h"

#define MY_CLASS SINGLETON_CLASS

static Eo *singleton_obj = NULL;

static Eo *
_singleton_efl_constructor(Eo *eo_obj EINA_UNUSED, void *_pd EINA_UNUSED)
{
   if (!singleton_obj)
     {
        singleton_obj = efl_add(SIMPLE_CLASS, NULL);
     }
   else
     {
        efl_ref(singleton_obj);
     }

   return singleton_obj;
}

static Efl_Op_Description op_descs[] = {
     EFL_OBJECT_OP_FUNC_OVERRIDE(efl_constructor, _singleton_efl_constructor),
};

static const Efl_Class_Description class_desc = {
     EO_VERSION,
     "Singleton",
     EFL_CLASS_TYPE_REGULAR,
     EFL_CLASS_DESCRIPTION_OPS(op_descs),
     NULL,
     0,
     NULL,
     NULL
};

EFL_DEFINE_CLASS(singleton_class_get, &class_desc, EO_CLASS, NULL)