summaryrefslogtreecommitdiff
path: root/src/examples/eolian_cxx/eolian_cxx_inherit_01.cc
blob: 5cd6b20596a58b3e6f5ebb3777f79debf3d709f6 (plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

#include <iostream>
#include <cassert>

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include "ns_colourable.eo.hh"
#include "ns_colourablesquare.eo.hh"
#include "ns_colourable.eo.impl.hh"
#include "ns_colourablesquare.eo.impl.hh"

#include <eo_inherit.hh>

using namespace efl;

struct ColourableCircle
  : efl::eo::inherit<ColourableCircle, ::ns::Colourable>
{
   ColourableCircle(int rgb)
     : inherit_base(::ns::Colourable::rgb_24bits_constructor(rgb))
   {}

   int colour_get()
   {
      int rgb = 0;
      rgb = ::ns_colourable_colour_get(eo_super(_eo_ptr(), _eo_class()));
      std::cout << "ColourableCircle::colour_get(" << this << ") ==> "
                << std::hex << rgb << std::endl;
      return rgb;
   }
};

/*
struct ColourableFoo
  : efl::eo::inherit<ColourableFoo,
                     ::colourable,
                     ::colourablesquare>
{
   ColourableFoo(int size, int rgb)
     : inherit_base(efl::eo::args<::colourable>(size)
                  , efl::eo::args<::colourablesquare>(rgb))
   {}
};*/

struct ColourableBar
  : efl::eo::inherit<ColourableBar, ::ns::ColourableSquare>
{
   ColourableBar()
     : inherit_base(::ns::Colourable::rgb_24bits_constructor(0))
   {}

   int colour_get()
   {
      int rgb = 0;
      rgb = ::ns_colourable_colour_get(eo_super(_eo_ptr(), _eo_class()));
      std::cout << "ColourableBar::colour_get(" << this << ") ==> "
                << std::hex << rgb << std::endl;
      return rgb;
   }

};

int
main()
{
   efl::eo::eo_init init;
   eina_log_domain_level_set("colourable", EINA_LOG_LEVEL_DBG);

   ColourableCircle obj1(0x0);
   obj1.composite_colour_set(0xc0, 0xff, 0xee);

   ColourableCircle obj2(0xc0ffee);
   int r, g, b;
   obj2.composite_colour_get(&r, &g, &b);


   ColourableBar obj3;
   obj3.composite_colour_get(&r, &g, &b);

   assert(r == 0xc0);
   assert(g == 0xff);
   assert(b == 0xee);

   assert(obj1.colour_get() == obj2.colour_get());

   return 0;
}