Re: Managing several object instances [message #81480] |
Wed, 19 September 2012 09:29  |
DavidF[1]
Messages: 94 Registered: April 2012
|
Member |
|
|
Helder writes:
> Since your experience with writing software is beyond reach for me, I'll try to pick up on your suggestions to avoid making a list.
>
> However every time I think about this, I still cannot figure out how to manage the whole together.
>
> Suppose I have an "image manager" that loads an image from a stack. Image n is selected an on this image there are 5 lines. The users selects line 3 and opens a plot profile window. This means I initiate an instance of the object that displays the data. Then another instance is initiated with line 2 and a new profile window appears. Now a new image in the image manager is selected and line 1 is deleted. I need to update one or all of the plot profile window/objects. Don't I need to know which ones have been initiated and are still running and to which line each object is/was associated ?
>
> This is the only reason why I want to use a list where I store the object and associate the line that is connected to this object. I see no other way out of this.
>
> If there is a "proper" way to do this avoiding lists, I'm would be happy to learn that because this sort of problem I have quite often...
I don't see any way out of it, either, given your stated requirements. I'm just suggesting a couple of hours spent thinking about how to avoid those requirements might be time well spent. :-)
Sometimes there is no way out of it. Paul's suggestion to use a LIST is a good one. Before IDL 8, I have used either a Linked List (from the Coyote Library) or my own modified IDL_Container object (in the Catalyst Library). Our modfied container object had the option to be an indexed container or just a container. An indexed container is handy for keeping track of things like you describe, if you can find some way to keep it up to date as objects go into and out of service. (An image object could contain an index container with five spaces for the five allowed profile objects, for example. That way, it could keep track of its own profiles.)
But, if it were me, when a new image was selected, I would destroy ALL of the profile objects wantonly, so that I could start fresh. Figuring out how to update displays that may or may not be on the display sounds like a nightmare to me. :-)
Cheers,
David
|
|
|