On 03/06/11 12:06, Steven Simpson wrote:
A mostly backward-compatible variation: Rename the *CB classes to something else (say *RF, for "Response Function"), then rename the *Response class to *CB. Add an operator->, and you'll be able to write any of these forms: void
XrlFinderclientTargetBase::async_common_0_1_get_target_name(
Common01GetTargetNameCB c_b)
{
// The old way to return a proper result, using the overload
string result = "hello";
c_b->dispatch(XrlCmdError::OKAY(), &result);
// The old way to return an error, using the overload
c_b->dispatch(XrlCmdError::CommandFailed("miserably"), NULL);
// The new way to return a result, using the new method
c_b.respond("hello");
// The new way to return an error, using the other new method
c_b.fail(XrlCmdError::CommandFailed("miserably"));
}
Note the use of '.' for new methods and '->' for the old.I've made a patch from tests on ECODE (where I can test async calls in anger). I'm just trying it against the XORP trunk now, checking for errors and binary sizes. It looks like it actually reduces file sizes a little, as the old *CB class was just a typedef for a template function type, which had to be expanded to appear in method names. Being a proper class, the new *CB type doesn't get expanded that way. Sending the patch tomorrow, hopefully. Cheers! |
_______________________________________________ Xorp-hackers mailing list [email protected] http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/xorp-hackers
