comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Object within an Object's Structure
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Object within an Object's Structure [message #71367 is a reply to message #71281] Thu, 10 June 2010 15:00 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
carl wrote:
> Hello,
>
> I am trying to make use of what OOP functionality IDL has, and I wish
> to have as an object variable another object of a different type.
>
> Is this possible? If so, how do I specify this?
>
> I have an object type orbitingBody, and want to make an object
> orbitingPair. Would this work? how would it be then coded in my init
> function?
>
> pro orbitingpair__define
> struct = { orbitingPair,
> planet: obj_new('orbitingbody', args)
> star: obj_new('orbitingbody', args)
> etc...}
> end

Hmm. Why restrict yourself to only planetary and star orbiting bodies? (e.g. asteroids?
comets?) Or even just two?

Assuming your "orbitingbody" object definition contains property information about the
type of orbiting body (i.e. planet, star, moon, asteroid, comet, etc), why not something like:

pro orbitingSet__define
void = { orbitingSet,
n_bodies = 0L, $
; Container for orbiting bodies
INHERITS IDL_Container }
end

?

You can then add as many orbiting bodies as you like:

pro orbitingSet::Add, $
obj, $ ; Object to add
_REF_EXTRA = Extra ; Keywords passed onto IDL_Container::Add

; Add object to the container
self->IDL_Container::Add, obj, _EXTRA = Extra

; If the object added is an orbitingBody object, increment the counter
IF ( OBJ_ISA(obj, 'orbitingBody') ) THEN self.n_bodies++
end

This way you can store more information in your "orbitingSet" container if the need ever
arises... and the objects you add needn't be just orbitingBody objects either.

cheers,

paulv
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: Creating a sub array from an array
Next Topic: Re: Contour data with two different lon/lat grids onto the same map projection

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 14:36:40 PDT 2025

Total time taken to generate the page: 1.75871 seconds