diff options
Diffstat (limited to 'libraries/eina/src/examples/eina_model_04_parrot.c')
-rw-r--r-- | libraries/eina/src/examples/eina_model_04_parrot.c | 95 |
1 files changed, 0 insertions, 95 deletions
diff --git a/libraries/eina/src/examples/eina_model_04_parrot.c b/libraries/eina/src/examples/eina_model_04_parrot.c deleted file mode 100644 index ac619ee..0000000 --- a/libraries/eina/src/examples/eina_model_04_parrot.c +++ /dev/null | |||
@@ -1,95 +0,0 @@ | |||
1 | /* | ||
2 | * parrot.c | ||
3 | */ | ||
4 | |||
5 | #include "eina_model_04_parrot.h" | ||
6 | #include "eina_model_04_whistler.h" | ||
7 | |||
8 | static Eina_Bool initialized = EINA_FALSE; | ||
9 | |||
10 | static void | ||
11 | _parrot_fly(Eina_Model *m) | ||
12 | { | ||
13 | printf("%s\t%s", eina_model_type_name_get(eina_model_type_get(m)), | ||
14 | __func__); | ||
15 | printf("\t\t Fly Parrot\n"); | ||
16 | } | ||
17 | |||
18 | static void | ||
19 | _parrot_eat(Eina_Model *m) | ||
20 | { | ||
21 | printf("%s\t%s", eina_model_type_name_get(eina_model_type_get(m)), | ||
22 | __func__); | ||
23 | printf("\t\t Grain \n"); | ||
24 | } | ||
25 | |||
26 | static void | ||
27 | _parrot_whistle(Eina_Model *m) | ||
28 | { | ||
29 | printf("%s\t%s", eina_model_type_name_get(eina_model_type_get(m)), | ||
30 | __func__); | ||
31 | printf("\t\t Whistle Parrot\n"); | ||
32 | } | ||
33 | |||
34 | /* | ||
35 | * defining Parrot Model Instance | ||
36 | * defining Whistler Interface instance | ||
37 | */ | ||
38 | const char *PARROT_MODEL_TYPE_NAME = NULL; | ||
39 | |||
40 | static Parrot_Type _PARROT_TYPE; | ||
41 | const Eina_Model_Type * const PARROT_TYPE = (Eina_Model_Type *) &_PARROT_TYPE; | ||
42 | |||
43 | static const Whistler_Interface _WHISTLER_INTERFACE; | ||
44 | static const Eina_Model_Interface * const WHISTLER_INTERFACE = | ||
45 | (Eina_Model_Interface *) &_WHISTLER_INTERFACE; | ||
46 | |||
47 | static const Eina_Model_Interface * MODEL_INTERFACES_ARRAY[] = | ||
48 | { &_WHISTLER_INTERFACE.base_interface, NULL }; //this array is for model | ||
49 | |||
50 | void | ||
51 | parrot_init() | ||
52 | { | ||
53 | Eina_Model_Type *type; | ||
54 | if (initialized) return; | ||
55 | initialized = EINA_TRUE; | ||
56 | |||
57 | animal_init(); | ||
58 | /* | ||
59 | *overriding Whistler Interface (creating instance of Whistler Interface) | ||
60 | */ | ||
61 | Eina_Model_Interface *iface = (Eina_Model_Interface *) &_WHISTLER_INTERFACE; | ||
62 | iface->version = EINA_MODEL_INTERFACE_VERSION; | ||
63 | iface->interface_size = sizeof(Whistler_Interface); | ||
64 | iface->name = WHISTLER_INTERFACE_NAME; | ||
65 | WHISTLER_INTERFACE(iface)->whistle = _parrot_whistle; | ||
66 | |||
67 | PARROT_MODEL_TYPE_NAME = "Parrot_Model_Type"; | ||
68 | |||
69 | type = (Eina_Model_Type *)&_PARROT_TYPE; | ||
70 | type->version = EINA_MODEL_TYPE_VERSION; | ||
71 | type->name = PARROT_MODEL_TYPE_NAME; | ||
72 | type->private_size = 0; | ||
73 | |||
74 | eina_model_type_subclass_setup(type, ANIMAL_TYPE); | ||
75 | |||
76 | type->type_size = sizeof(Parrot_Type); | ||
77 | type->interfaces = MODEL_INTERFACES_ARRAY; | ||
78 | |||
79 | ANIMAL_TYPE(type)->eat = _parrot_eat; | ||
80 | PARROT_TYPE(type)->fly = _parrot_fly; | ||
81 | } | ||
82 | |||
83 | |||
84 | void | ||
85 | parrot_fly(Eina_Model *m) | ||
86 | { | ||
87 | EINA_SAFETY_ON_FALSE_RETURN(eina_model_instance_check(m, PARROT_TYPE)); | ||
88 | |||
89 | void (*pf)(Eina_Model *m); | ||
90 | pf = eina_model_method_resolve(m, Parrot_Type, fly); | ||
91 | EINA_SAFETY_ON_NULL_RETURN(pf); | ||
92 | printf("%s() \t", __func__); | ||
93 | pf(m); | ||
94 | } | ||
95 | |||