16 #include "../../include/ecl/sigslots_lite.hpp" 30 void f(
const char* str) {
31 std::cout <<
"Foo::f() " << str << std::endl;
34 std::cout <<
"Foo::h()" << std::endl;
38 void f(
const char* str) {
39 std::cout <<
"f(char*) " << str << std::endl;
42 void g(
const char* str) {
43 std::cout <<
"g(char*) " << str << std::endl;
47 std::cout <<
"h()" << std::endl;
68 int main(
int argc,
char **argv) {
72 std::cout << std::endl;
73 std::cout <<
"***********************************************************" << std::endl;
74 std::cout <<
" Data Sigslots" << std::endl;
75 std::cout <<
"***********************************************************" << std::endl;
76 std::cout << std::endl;
83 dual_slot_signal.
emit(
"one signal, two global slots");
84 std::cout << std::endl;
87 lone_signal1.
emit(
"direct member slot connection");
88 std::cout << std::endl;
91 lone_signal1.
emit(
"multiple signals, one slot connection - I");
92 lone_signal2.
emit(
"multiple signals, one slot connection - II");
93 std::cout << std::endl;
95 std::cout << std::endl;
96 std::cout <<
"***********************************************************" << std::endl;
97 std::cout <<
" Void Sigslots" << std::endl;
98 std::cout <<
"***********************************************************" << std::endl;
99 std::cout << std::endl;
102 connect(member_void_signal,&Foo::h, foo);
105 member_void_signal.
emit();
107 std::cout << std::endl;
108 std::cout <<
"***********************************************************" << std::endl;
109 std::cout <<
" Storage" << std::endl;
110 std::cout <<
"***********************************************************" << std::endl;
111 std::cout << std::endl;
113 std::cout <<
"GlobalSlots<const char*> Stored : " << ecl::lite::global_slots_stored<const char*>() << std::endl;
114 std::cout <<
"GlobalSlots<const char*> Capacity: " << ecl::lite::global_slots_capacity<const char*>() << std::endl;
115 std::cout << std::endl;
116 std::cout <<
"GlobalSlots<void> Stored : " << ecl::lite::global_slots_stored<void>() << std::endl;
117 std::cout <<
"GlobalSlots<void> Capacity: " << ecl::lite::global_slots_capacity<void>() << std::endl;
118 std::cout << std::endl;
120 std::cout <<
"MemberSlots<const char*> Stored(foo) : " << ecl::lite::member_slots_stored<const char*>(foo) << std::endl;
121 std::cout <<
"MemberSlots<const char*> Capacity(Foo): " << ecl::lite::member_slots_capacity<const char*>(foo) << std::endl;
122 std::cout << std::endl;
123 std::cout <<
"MemberSlots<void> Stored(foo) : " << ecl::lite::member_slots_stored<void>(foo) << std::endl;
124 std::cout <<
"MemberSlots<void> Capacity(Foo): " << ecl::lite::member_slots_capacity<void>(foo) << std::endl;
125 std::cout << std::endl;
128 std::cout <<
"Incrementally adding slots to signal<const char*,2>" << std::endl;
129 std::cout <<
" capacity: " << signal_storage_test.
capacity() << std::endl;
130 std::cout <<
" stored : " << signal_storage_test.
stored() << std::endl;
131 connect(signal_storage_test,f);
132 std::cout <<
" stored : " << signal_storage_test.
stored() << std::endl;
133 connect(signal_storage_test,g);
134 std::cout <<
" stored : " << signal_storage_test.
stored() << std::endl;
135 std::cout << std::endl;
137 std::cout << std::endl;
138 std::cout <<
"***********************************************************" << std::endl;
139 std::cout <<
" Error Handling" << std::endl;
140 std::cout <<
"***********************************************************" << std::endl;
141 std::cout << std::endl;
144 std::cout <<
"Adding two slots to a single slot capacity signal." << std::endl;
146 std::cout <<
" Connecting a first slot" << std::endl;
147 error =
connect(one_shot_signal,f);
149 std::cout <<
" " << error.
what() << std::endl;
151 std::cout <<
" Connecting a second slot" << std::endl;
152 error =
connect(one_shot_signal,f);
154 std::cout <<
" " << error.
what() << std::endl;
156 std::cout << std::endl;
158 std::cout <<
"Adding two slots to a single slot capacity MemberSlots interface." << std::endl;
161 std::cout <<
" Connecting a first slot" << std::endl;
162 error =
connect(two_shot_signal, &Foo::f, foo_new);
164 std::cout <<
" " << error.
what() << std::endl;
166 std::cout <<
" Connecting a second slot" << std::endl;
167 error =
connect(two_shot_signal, &Foo::f, foo_new);
169 std::cout <<
" " << error.
what() << std::endl;
172 std::cout << std::endl;
173 std::cout <<
"***********************************************************" << std::endl;
174 std::cout <<
" Passed" << std::endl;
175 std::cout <<
"***********************************************************" << std::endl;
176 std::cout << std::endl;
friend sigslots::Error connect(Signal< Data_, Capacity_ > &signal, void(FunctionClass_::*f)(Data_), FunctionClass_ &o)
This is the global slot interface.
sigslots::Error connect(Signal< Data, Capacity > &signal, void(FunctionClass::*f)(Data), FunctionClass &o)
Convenience method to connect signal with member function.
virtual sigslots::ErrorFlag flag() const
The flag identifying the error identified with this error handler.
void emit(Data data) const
Signal slots with the specified data.
Extends the generic ecl error handler with some time specific error strings.
int main(int argc, char **argv)
This is the member slot interface, inheritable by classes.
unsigned int stored() const
The current number of connections stored.
unsigned int capacity() const
The reserved capacity for this signaller.
virtual const char * what() const
A simple string verbosely representing the error that is handled.