Re: object methods as friends [message #39165 is a reply to message #38969] |
Sun, 18 April 2004 15:42  |
Mark Hadfield
Messages: 783 Registered: May 1995
|
Senior Member |
|
|
Zorch Tierod wrote:
> Hey there,
> I've got an application that uses two types of objects, each with
> several different method procedures.
>
> What I'm trying to do is to calculate some stuff based on the
> interaction of one of the objects with an array of the other type of
> objects. Illustrative example (but not the REAL application!):
>
> sb = {bullet, param1:.....} ;protoype for bullet object
> st = {target, param1:......} ;prototype for target object
>
> target_array = obj_arr('target',10) ;make a bunch of targets
> projectile = obj_new('bullet') ;make a bullet
>
> jtarget = which_hit(target_array, projectile) ;return which target is
> hit
>
> My problem seems to be that the function 'which_hit' has no access to
> the data of either the 'bullet' or the 'target' objects, because it is
> not a method of either - and I can't make it a method of both...
The standard way of dealing with this in IDL is to expose the properties
you need via GetProperty & SetProperty methods. Yes, this can be a lot
of work and, no, it doesn't allow for discrimination between friend and
non-friend callers.
I suppose you could have FriendGetProperty & FriendSetProperty methods
which asked for authentication from the caller, but really, why would
you bother? If you don't want non-friends to access certain properties,
then just don't do it.
--
Mark Hadfield "Ka puwaha te tai nei, Hoea tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
Add extraneous new text to keep news server happy. Add extraneous new
text to keep news server happy. Add extraneous new text to keep news
server happy. Add extraneous new text to keep news server happy. Add
extraneous new text to keep news server happy. Add extraneous new text
to keep news server happy. Add extraneous new text to keep news server
happy. Add extraneous new text to keep news server happy. Add extraneous
new text to keep news server happy. Add extraneous new text to keep news
server happy. Add extraneous new text to keep news server happy. Add
extraneous new text to keep news server happy. Add extraneous new text
to keep news server happy. Add extraneous new text to keep news server
happy. Add extraneous new text to keep news server happy. Add extraneous
new text to keep news server happy. Add extraneous new text to keep news
server happy. Add extraneous new text to keep news server happy. Add
extraneous new text to keep news server happy. Add extraneous new text
to keep news server happy. Add extraneous new text to keep news server
happy. Add extraneous new text to keep news server happy. Add extraneous
new text to keep news server happy.
|
|
|