summaryrefslogtreecommitdiff
path: root/digital/ucoolib/ucoolib/arch/host/mex/test/test_mex.cc
diff options
context:
space:
mode:
authorNicolas Schodet2013-02-21 22:40:30 +0100
committerNicolas Schodet2013-03-01 22:58:03 +0100
commit116144085c5fc68009ac90d77efd61507aa7585c (patch)
tree662feaba57e53c8c6d7fd3ef72e7e33f5f97583c /digital/ucoolib/ucoolib/arch/host/mex/test/test_mex.cc
parentda2c8f50ee5caafd73470ef2e33cf2d42be23c6c (diff)
digital/ucoolib/ucoolib/arch/host/mex: simplify handlers thanks to TR1
TR1 (and C++11, but this must compile on debian squeeze) defines function objects which can contain any callable which respects the prototype. This greatly simplify handler code. Also, get rid of get_instance and give Node as handler parameter instead.
Diffstat (limited to 'digital/ucoolib/ucoolib/arch/host/mex/test/test_mex.cc')
-rw-r--r--digital/ucoolib/ucoolib/arch/host/mex/test/test_mex.cc12
1 files changed, 5 insertions, 7 deletions
diff --git a/digital/ucoolib/ucoolib/arch/host/mex/test/test_mex.cc b/digital/ucoolib/ucoolib/arch/host/mex/test/test_mex.cc
index f260203b..9628ca16 100644
--- a/digital/ucoolib/ucoolib/arch/host/mex/test/test_mex.cc
+++ b/digital/ucoolib/ucoolib/arch/host/mex/test/test_mex.cc
@@ -183,7 +183,7 @@ test_node_1 ()
}
void
-test_node_2_handle_hello (Msg &msg)
+test_node_2_handle_hello (Node &, Msg &msg)
{
int pass;
msg.pop ("l") >> pass;
@@ -192,14 +192,14 @@ test_node_2_handle_hello (Msg &msg)
}
void
-test_node_2_handle_world (Msg &msg)
+test_node_2_handle_world (Node &node, Msg &msg)
{
int a, b;
msg.pop ("bh") >> a >> b;
printf ("world\n");
Msg resp (msg.mtype ());
resp.push ("l") << a + b;
- Node::instance ()->response (resp);
+ node.response (resp);
}
void
@@ -209,10 +209,8 @@ test_node_2 ()
mtype_t hello_mtype, world_mtype;
hello_mtype = node.reserve ("hello");
world_mtype = node.reserve ("world");
- HandlerPtrfun hello_handler (test_node_2_handle_hello);
- HandlerPtrfun world_handler (test_node_2_handle_world);
- node.handler_register (hello_mtype, hello_handler);
- node.handler_register (world_mtype, world_handler);
+ node.handler_register (hello_mtype, test_node_2_handle_hello);
+ node.handler_register (world_mtype, test_node_2_handle_world);
node.wait ();
}