summaryrefslogtreecommitdiff
path: root/src/examples/eolian_cxx/eolian_cxx_callbacks_01.cc
blob: 8c41c0eab74c141894c5053f35f35e1f83b392a3 (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
#include <iostream>
#include <thread>
#include <cassert>
#include <sstream>

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

#include <Eo.h>
#include <Ecore.h>
#include <Evas.h>
#include <Ecore_Evas.h>

#include <Eina.hh>
#include <Eo.hh>
#include <Ecore.hh>
#include <Evas.hh>

#include <ecore_poller.eo.hh>

namespace efl { namespace ecore {
using ::ecore::poller;
} }

void
example_callbacks()
{
   int count = 0;
   efl::ecore::poller poller(
     poller.ecore_poller_constructor(ECORE_POLLER_CORE, 1,
       [&count, &poller]
       {
          if (++count == 5)
            {
               std::cout << std::endl;
               ecore_main_loop_quit();
               return false;
            }
          poller.interval_set(2*poller.interval_get());
          std::cout << "." << std::flush;
          return true;
       })
   );
   ::ecore_main_loop_begin();
}

int main()
{
   efl::eina::eina_init eina_;
   efl::eo::eo_init eo_;
   efl::ecore::ecore_init ecore_;

   std::cerr << "[+] Running EFL++ example: Callbacks" << std::endl;
   example_callbacks();

   return 0;
}