-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
65 lines (53 loc) · 1.65 KB
/
main.cpp
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
#include "MergedCallbacks.hpp"
#include <iostream>
void f()
{
static int counter = 0;
std::cout << "f(), call counter: " << counter << std::endl;
++counter;
}
class A
{
public:
void f(int a)
{
static int counter = 0;
std::cout << "A::f(int), call counter: " << counter << std::endl;
counter++;
a++;
}
virtual void g(int b, int c)
{
b++;
c++;
}
};
class B : public A
{
public:
void g(int b, int c)
{
static int counter = 0;
std::cout << "B::g(int, int), call counter: " << counter << std::endl;
counter++;
}
};
int main()
{
A a;
B b;
MergedCallbacks mc;
mc.registerUniqueCallback(MergedCallbacks::NORMAL, boost::bind(&f));
mc.registerUniqueCallback(MergedCallbacks::NORMAL, boost::bind(&f));
mc.registerUniqueCallback(MergedCallbacks::NORMAL, boost::bind(&A::f, &a, 1));
mc.registerUniqueCallback(MergedCallbacks::NORMAL, boost::bind(&A::f, &a, 1));
mc.registerUniqueCallback(MergedCallbacks::NORMAL, boost::bind(&A::f, &a, 2));
mc.registerUniqueCallback(MergedCallbacks::NORMAL, boost::bind(&B::g, &b, 0, 0));
mc.registerUniqueCallback(MergedCallbacks::NORMAL, boost::bind(&B::g, &b, 0, 0));
mc.registerUniqueCallback(MergedCallbacks::NORMAL, boost::bind(&B::g, &b, 0, 1));
mc.registerUniqueCallback(MergedCallbacks::NORMAL, boost::bind(&B::g, &b, 0, 1));
mc.registerUniqueCallback(MergedCallbacks::NORMAL, boost::bind(&B::g, &b, 1, 0));
mc.registerUniqueCallback(MergedCallbacks::NORMAL, boost::bind(&B::g, &b, 1, 0));
mc.executeCallbackWithPriority(MergedCallbacks::NORMAL);
return 0;
}