sigslots_manager.cpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10 ** Includes
11 *****************************************************************************/
12 
13 #include <iostream>
14 #include "../../include/ecl/sigslots.hpp"
15 
16 /*****************************************************************************
17 ** Fuctions
18 *****************************************************************************/
23 void g() {
24  std::cout << " This is standalone g()" << std::endl;
25 }
26 void h(int i) {
27  std::cout << " This is standalone g(int): " << i << std::endl;
28 }
29 
30 class A {
31 public:
32  void g() {
33  std::cout << " This is A::g()" << std::endl;
34  }
35  void h(int i) {
36  std::cout << " This is A::g(int): " << i << std::endl;
37  }
38 };
39 
44 /*****************************************************************************
45 ** Main
46 *****************************************************************************/
47 
48 int main(int argc, char **argv) {
49  A a;
50  std::cout << std::endl;
51  std::cout << "***************************************************************" << std::endl;
52  std::cout << "* 1 Signal, 2 Slots" << std::endl;
53  std::cout << "***************************************************************" << std::endl;
54  std::cout << std::endl;
55 
56  ecl::Signal<> sig_void;
57  ecl::Slot<> slot_void0(g);
58  ecl::Slot<> slot_void1(&A::g,a);
59 
60  sig_void.connect("void_test");
61  slot_void0.connect("void_test");
62  slot_void1.connect("void_test");
63  std::cout << "Emitting:" << std::endl;
64  sig_void.emit();
65 
66  std::cout << std::endl;
67  std::cout << "***************************************************************" << std::endl;
68  std::cout << "* Statistics" << std::endl;
69  std::cout << "***************************************************************" << std::endl;
70  std::cout << std::endl;
71 
73 
74  std::cout << std::endl;
75  std::cout << "***************************************************************" << std::endl;
76  std::cout << "* 1 Data Signal, 2 Data Slots" << std::endl;
77  std::cout << "***************************************************************" << std::endl;
78  std::cout << std::endl;
79 
80  ecl::Signal<int> sig_data;
81  ecl::Slot<int> slot_data0(h);
82  ecl::Slot<int> slot_data1(&A::h,a);
83 
84  sig_data.connect("data_test");
85  slot_data0.connect("data_test");
86  slot_data1.connect("data_test");
87  std::cout << "Emitting:" << std::endl;
88  sig_data.emit(3);
89 
90  std::cout << std::endl;
91  std::cout << "***************************************************************" << std::endl;
92  std::cout << "* Statistics" << std::endl;
93  std::cout << "***************************************************************" << std::endl;
94  std::cout << std::endl;
95 
97 
98  return 0;
99 }
100 
void g(const int &i)
static void printStatistics()
Print some statistics on the current status of the manager.
Definition: manager.hpp:59
void connect(const std::string &topic)
Make a connection to the specified topic.
Definition: slot.hpp:152
int main(int argc, char **argv)
Signalling component of a callback system.
Definition: signal.hpp:47
void connect(const std::string &topic)
Make a connection to the specified topic.
Definition: signal.hpp:104
void emit(Data data)
The primary purpose of the signal, to emit!
Definition: signal.hpp:128
Function loading component of a callback system.
Definition: slot.hpp:48


ecl_sigslots
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:08:49