File src/impl/batch.hxx changed (mode: 100644) (index e261b80..edeaf02) |
1 |
1 |
namespace om636 { |
namespace om636 { |
2 |
2 |
namespace control { |
namespace control { |
3 |
3 |
///////////////////////////////////////////////////////////////////////////////////// |
///////////////////////////////////////////////////////////////////////////////////// |
4 |
|
template <typename... T> |
|
5 |
|
auto BatchImpl<T...>::hook(function_type callback) -> agent_type |
|
|
4 |
|
template <template<typename> typename P, typename... T> |
|
5 |
|
auto BatchImpl<P, T...>::hook(function_type callback) -> agent_type |
6 |
6 |
{ |
{ |
7 |
7 |
using namespace std; |
using namespace std; |
8 |
8 |
auto agent(make_shared<function_type>(callback)); |
auto agent(make_shared<function_type>(callback)); |
|
... |
... |
namespace control { |
11 |
11 |
} |
} |
12 |
12 |
|
|
13 |
13 |
///////////////////////////////////////////////////////////////////////////////////// |
///////////////////////////////////////////////////////////////////////////////////// |
14 |
|
template <typename... T> |
|
15 |
|
auto BatchImpl<T...>::hook_once(function_type callback) -> agent_type |
|
|
14 |
|
template <template<typename> typename P, typename... T> |
|
15 |
|
auto BatchImpl<P, T...>::hook_once(function_type callback) -> agent_type |
16 |
16 |
{ |
{ |
17 |
17 |
using namespace std; |
using namespace std; |
18 |
18 |
auto agent(make_shared<function_type>(callback)); |
auto agent(make_shared<function_type>(callback)); |
|
... |
... |
namespace control { |
21 |
21 |
} |
} |
22 |
22 |
|
|
23 |
23 |
///////////////////////////////////////////////////////////////////////////////////// |
///////////////////////////////////////////////////////////////////////////////////// |
24 |
|
template <typename... T> |
|
25 |
|
void BatchImpl<T...>::invoke(T... arg) |
|
|
24 |
|
template <template<typename> typename P, typename... T> |
|
25 |
|
void BatchImpl<P, T...>::invoke(T... arg) |
26 |
26 |
{ |
{ |
27 |
27 |
using namespace std; |
using namespace std; |
28 |
28 |
batch_type traverse; |
batch_type traverse; |
|
... |
... |
namespace control { |
41 |
41 |
} |
} |
42 |
42 |
|
|
43 |
43 |
///////////////////////////////////////////////////////////////////////////////////// |
///////////////////////////////////////////////////////////////////////////////////// |
44 |
|
template <typename... T> |
|
45 |
|
auto BatchImpl<T...>::impl_ref() -> batch_type& |
|
|
44 |
|
template <template<typename> typename P, typename... T> |
|
45 |
|
auto BatchImpl<P, T...>::impl_ref() -> batch_type& |
46 |
46 |
{ |
{ |
47 |
47 |
return m_impl; |
return m_impl; |
48 |
48 |
} |
} |
49 |
49 |
|
|
50 |
50 |
///////////////////////////////////////////////////////////////////////////////////// |
///////////////////////////////////////////////////////////////////////////////////// |
51 |
|
template <typename... T> |
|
52 |
|
auto BatchImpl<T...>::impl_ref() const -> const batch_type& |
|
|
51 |
|
template <template<typename> typename P, typename... T> |
|
52 |
|
auto BatchImpl<P, T...>::impl_ref() const -> const batch_type& |
53 |
53 |
{ |
{ |
54 |
54 |
return m_impl; |
return m_impl; |
55 |
55 |
} |
} |
File test/src/batch.h changed (mode: 100644) (index 0c576c2..f5ac19c) |
... |
... |
using namespace std; |
4 |
4 |
|
|
5 |
5 |
void check_unhook_while_traverse() |
void check_unhook_while_traverse() |
6 |
6 |
{ |
{ |
7 |
|
BatchImpl<> batch; |
|
|
7 |
|
BatchImpl<dummy> batch; |
8 |
8 |
unsigned passed(0); |
unsigned passed(0); |
9 |
9 |
|
|
10 |
|
typename BatchImpl<>::listener_type temp(batch.hook([&]() { |
|
|
10 |
|
typename BatchImpl<dummy>::listener_type temp(batch.hook([&]() { |
11 |
11 |
++passed; |
++passed; |
12 |
12 |
temp.reset(); |
temp.reset(); |
13 |
13 |
})); |
})); |
|
... |
... |
void check_unhook_while_traverse() |
21 |
21 |
|
|
22 |
22 |
void dead_agent_removal() |
void dead_agent_removal() |
23 |
23 |
{ |
{ |
24 |
|
typedef BatchImpl<int> batch_type; |
|
|
24 |
|
typedef BatchImpl<dummy, int> batch_type; |
25 |
25 |
batch_type batch; |
batch_type batch; |
26 |
26 |
batch.hook([](int) {}); |
batch.hook([](int) {}); |
27 |
27 |
batch.invoke(9); |
batch.invoke(9); |
|
... |
... |
void dead_agent_removal() |
31 |
31 |
|
|
32 |
32 |
void check_traverse_with_arg() |
void check_traverse_with_arg() |
33 |
33 |
{ |
{ |
34 |
|
BatchImpl<int> batch; |
|
|
34 |
|
BatchImpl<dummy, int> batch; |
35 |
35 |
int v = 0; |
int v = 0; |
36 |
36 |
auto p(batch.hook([&](int i) { |
auto p(batch.hook([&](int i) { |
37 |
37 |
v = i; |
v = i; |
|
... |
... |
void check_traverse_with_arg() |
44 |
44 |
|
|
45 |
45 |
void check_traverse_with_args() |
void check_traverse_with_args() |
46 |
46 |
{ |
{ |
47 |
|
typedef BatchImpl<int, int> batch_type; |
|
|
47 |
|
typedef BatchImpl<dummy, int, int> batch_type; |
48 |
48 |
|
|
49 |
49 |
unsigned test_passed(0); |
unsigned test_passed(0); |
50 |
50 |
batch_type batch; |
batch_type batch; |
|
... |
... |
void check_traverse_with_args() |
62 |
62 |
|
|
63 |
63 |
void check_traverse_while_traverse() |
void check_traverse_while_traverse() |
64 |
64 |
{ |
{ |
65 |
|
BatchImpl<> batch; |
|
|
65 |
|
BatchImpl<dummy> batch; |
66 |
66 |
unsigned passed(0); |
unsigned passed(0); |
67 |
67 |
|
|
68 |
68 |
auto p(batch.hook([&]() { |
auto p(batch.hook([&]() { |
|
... |
... |
void check_traverse_while_traverse() |
77 |
77 |
|
|
78 |
78 |
void check_traverse() |
void check_traverse() |
79 |
79 |
{ |
{ |
80 |
|
BatchImpl<> batch; |
|
|
80 |
|
BatchImpl<dummy> batch; |
81 |
81 |
unsigned passed(0); |
unsigned passed(0); |
82 |
82 |
|
|
83 |
83 |
auto temp(batch.hook([&]() { |
auto temp(batch.hook([&]() { |