summaryrefslogtreecommitdiff
path: root/src/examples/eolian_cxx/eolian_cxx_inherit_01.cc
blob: b3fe196576d0de550df2e6f806e594a775957b02 (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

#include <iostream>
#include <cassert>

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

#include "colourable.eo.hh"
#include "colourablesquare.eo.hh"

#include <eo_inherit.hh>

using namespace efl;

struct ColourableCircle
  : efl::eo::inherit<ColourableCircle, ::colourable>
{
   ColourableCircle(int r, int g, int b)
     : inherit_base(r, g, b)
   {}

   ColourableCircle(int rgb)
     : inherit_base(efl::eo::args<::colourable>(rgb))
   {}

   int colour_get()
   {
      int rgb = 0;
      eo_do_super(_eo_ptr(), _eo_class(), rgb = ::colourable_colour_get());
      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))
   {}
};

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

   ColourableCircle obj1(0xc0, 0xff, 0xee);

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

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

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

   return 0;
}