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

Home » Public Forums » archive » Need advice on building an object container
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Need advice on building an object container [message #66250] Mon, 27 April 2009 07:41 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Hello,

I need a bit of advice on building a container for object.

I have an object definition, let's say 'RTS', that contains the simulated
top-of-atmosphere radiances for various satellites. I also have files that contains all
the instance data for a whole bunch of those objects. Those data are organised by the
sensor channel (i.e. different frequencies) and atmospheric profiles. So, in my
pre-object-code I would create a structure array after determining the dimensions,
something like
Rts = PTRARR( n_Channels, n_Profiles )
FOR m = 0L, n_Profiles-1L DO BEGIN
FOR l = 0L, n_Channels-1L DO BEGIN
Rts[l,m] = PTR_NEW({CRTM_RTSolution})
...read the current record...
ENDFOR
ENDFOR

But now I want to use objects (mostly as a learning exercise, but also to stop folks from
mucking about with the innards of the structure when they use it).

So, the structure definition of RTS doubles as the object defn also. What do people
recommend for reading the datafile? I see two options:

1) Use OBJARR(). Read dimensions and create the array and then fill it. However, this
would still require the user to create the array after inquiring the file for its
dimensions, and basically keep track of things.

2) Use a container. This is what I came up with this morning:
PRO RTSfile__Define
void = { RTSfile, $
Filename : '', $
FileId : 0L, $
INHERITS IDL_Container }
END

and, in the RTSfile::Read method I would simply read each RTS object from the file and do a
rtsfile->Add, rts
But this method doesn't preserve the basic [n_Channels, n_Profiles] structure of the data.
And, there's no indication in the RTSfile definition that this is a container for RTS
objects, rather than a generic container -- but I'm wondering if worrying about that is
just a distraction?

3) Sort-of combining (1) and (2) doing something like:
PRO RTSfile__Define
void = { RTSfile, $
Filename : '', $
FileId : 0L, $
n_Channels : 0L, $
n_Profiles : 0L, $
rts : PTR_NEW() }
END
where, eventually,
rts = PTR_NEW(OBJARR(n_Channels, n_Profiles))
and then fill in the object references to the RTS object.

So I was wondering how people would structure their code to handle this sort of thing. I
think it's a common enough paradigm that a pattern probably exists but I haven't found it.

Any info, hints, tips, appreciated.

cheers,

paulv
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: A problem with envi_save_rois
Next Topic: IDL_tools version 2.0

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

Current Time: Fri Oct 10 18:59:11 PDT 2025

Total time taken to generate the page: 0.08138 seconds