From: tmoran@acm.org
Subject: Re: Some help for a C++ guy
Date: Fri, 08 Apr 2005 19:19:02 -0500
Date: 2005-04-08T19:19:02-05:00 [thread overview]
Message-ID: <VYydnWm705_rgsrfRVn-2Q@comcast.com> (raw)
In-Reply-To: 1113001402.404239.275940@z14g2000cwz.googlegroups.com
Why not save pointers to the Handler objects instead of the procedures?
You have something like:
1) type BC_Completion_Handler_T is access
procedure (Status : in IO_Status_T);
...
2) -- in the routine that does callbacks you have:
Saved_Completion_Handler_Ptr : BC_Completion_Handler_T;
procedure Register_Message_Callback (msg_id : ... ;
Callback_Ptr : BC_Completion_Handler_T) is
begin
Saved_Completion_Handler_Ptr := Callback_Ptr;
end Register_Message_Callback;
3) -- and then in various places therein you have the actual callbacks
Saved_Completion_Handler_Ptr.all (Status);
change the above to something like:
1) type BC_Completion_Handler_T is access all Handler;
...
2) -- then in the routine that does callbacks you have:
Saved_Completion_Handler_Ptr : BC_Completion_Handler_T;
procedure Register_Message_Callback (msg_id : ... ;
Callback_Ptr : BC_Completion_Handler_T) is
begin
Saved_Completion_Handler_Ptr := Callback_Ptr;
end Register_Message_Callback;
3) -- and then in various places therein you have the actual callbacks
Completion_Handler (Saved_Completion_Handler_Ptr, Status);
that would require a single point change to (1), and a global replace
Saved_Completion_Handler_Ptr.all (Status);
=>
Completion_Handler (Saved_Message_Ptr, Status);
Registration of an array of Handler could then be done in a loop.
Of course you would also do global replacements
BC_Completion_Handler_T => BC_Message_T
Saved_Completion_Handler => Saved_Message
Callback => To_Callback
so as not to confuse readers, leading to:
1) type BC_Message_T is access all Handler;
...
2) -- then in the routine that does callbacks you have:
Saved_Message_Ptr : BC_Message_T;
procedure Register_Message_To_Callback (msg_id : ... ;
To_Callback_Ptr : BC_Message_T) is
begin
Saved_Message_Ptr := To_Callback_Ptr;
end Register_Message_To_Callback;
3) -- and then in various places therein you have the actual callbacks
Completion_Handler (Saved_Message_Ptr, Status);
next prev parent reply other threads:[~2005-04-09 0:19 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-07 22:14 Some help for a C++ guy defaultuserbr
2005-04-07 22:51 ` Ed Falis
2005-04-07 23:18 ` defaultuserbr
2005-04-07 23:32 ` Ed Falis
2005-04-08 15:41 ` defaultuserbr
2005-04-08 5:50 ` Simon Wright
2005-04-08 15:47 ` defaultuserbr
2005-04-08 17:49 ` defaultuserbr
2005-04-08 20:42 ` tmoran
2005-04-08 21:18 ` defaultuserbr
2005-04-08 20:54 ` defaultuserbr
2005-04-08 22:20 ` tmoran
2005-04-08 23:03 ` defaultuserbr
2005-04-09 0:19 ` tmoran [this message]
2005-04-09 15:17 ` defaultuserbr
2005-04-08 4:43 ` tmoran
2005-04-08 15:55 ` defaultuserbr
2005-04-09 22:20 ` Matthew Heaney
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox