Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Need advice on building an object container
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Paul van Delst  
View profile  
 More options Apr 27 2009, 10:41 am
Newsgroups: comp.lang.idl-pvwave
From: Paul van Delst <Paul.vanDe...@noaa.gov>
Date: Mon, 27 Apr 2009 10:41:53 -0400
Local: Mon, Apr 27 2009 10:41 am
Subject: Need advice on building an object container
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
ben.bighair  
View profile  
 More options Apr 29 2009, 7:58 am
Newsgroups: comp.lang.idl-pvwave
From: "ben.bighair" <ben.bigh...@gmail.com>
Date: Wed, 29 Apr 2009 04:58:23 -0700 (PDT)
Local: Wed, Apr 29 2009 7:58 am
Subject: Re: Need advice on building an object container
On Apr 27, 10:41 am, Paul van Delst <Paul.vanDe...@noaa.gov> wrote:

Hi Paul,

Have you considered crafting two new object containers - one for
holding a vector of profile data-objects for a given channel and the
other for holding an vector of channels.  Assuming that the smallest
reasonable element to craft an object around is one of your profile
thingys, you could nest the containers something like this.

RTS is a container for
  RTS_ChannelsBucket is a container for
    RTS_ProfilesBucket is a container for
      RTS_ProfileElement

Your RTS object could have a method for retrieving a specific profile
by channel and profile number...

myProfile = RTS::GetElement(thisChannel, thatProfile)

This method would then get thisChannel...

FUNCTION RTS::GetElement, thisChannel, thatProfile, count = count
  myChannel = self->Get(thisChannel, count = count)
  if (count GT 0) then begin
    profile = myChannel->Get(thatProfile, count = count)
  endif else profile = -1
  return, profile
end

Or perhaps method for retrieving all of the profiles for a given
channel...

myChannel = RTS::GetChannel(thisChannel)

You probaby getthe idea. I suspect you could then manage all your file
elements with pointers only at the "lowest" level, the profile
elements.  I don't know how much performance overhead this will add,
but it should make it easier on you and will hide the darn elements
from your users.

Cheers,
Ben


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mike  
View profile  
 More options Apr 30 2009, 2:00 pm
Newsgroups: comp.lang.idl-pvwave
From: Mike <Michael.Mill...@gmail.com>
Date: Thu, 30 Apr 2009 11:00:15 -0700 (PDT)
Local: Thurs, Apr 30 2009 2:00 pm
Subject: Re: Need advice on building an object container
Have you looked at the IDL_Container object?  It could be inherited by
your containers and used to handle all the bookkeeping.

Mike


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul van Delst  
View profile  
 More options May 1 2009, 10:26 am
Newsgroups: comp.lang.idl-pvwave
From: Paul van Delst <paul.vande...@noaa.gov>
Date: Fri, 01 May 2009 10:26:46 -0400
Local: Fri, May 1 2009 10:26 am
Subject: Re: Need advice on building an object container

Mike wrote:
> Have you looked at the IDL_Container object?  It could be inherited by
> your containers and used to handle all the bookkeeping.

Umm... yes. That's why I used it in my original example:

>   PRO RTSfile__Define
>     void = { RTSfile, $
>              Filename : '', $
>              FileId   : 0L, $
>              INHERITS IDL_Container }
>   END

:o)

My problem is with the "packaging" of various levels of these objects. Or, alternatively,
translating my real world organisation of the data into something amenable to OOP
programming. My goal here is somewhat an academic exercise, but I want to be able to
easily change the definition of my base object without having to retool a bunch of code.

I think Ben's advice is what I needed. Just a pattern on which I can work with, or build on.

cheers,

paulv


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »