Re: Managing several object instances [message #81481 is a reply to message #81480] |
Wed, 19 September 2012 08:45   |
Helder Marchetto
Messages: 520 Registered: November 2011
|
Senior Member |
|
|
Hi
On Wednesday, September 19, 2012 4:11:58 PM UTC+2, Paul van Delst wrote:
> Hello,
>
>
>
> Without addressing the "why are you doing this", what about:
>
>
>
> 1) using a List, or a Hash, object to store your objects? You can use
>
> their Add (for Lists)
>
> and Remove methods to manage your own object collection.
>
> 2) create your own object handling class that inherits the IDL_Container
>
> class - which
>
> also has its own Add and Remove methods
>
>
>
> I was also going to suggest extending (2) a bit an generate your own
>
> linked list, but I don't
>
> think your usage requires a linked list.
>
>
>
> I would start with (1) since lists are a subclass of IDL_Container already:
>
>
>
> IDL> x=list()
>
> IDL> help, x, /object
>
> ** Object class LIST, 2 direct superclasses, 1 known method
>
> Superclasses:
>
> COLLECTION <Direct>
>
> IDL_OBJECT
>
> IDL_CONTAINER <Direct>
>
> Known Function Methods:
>
> LIST::INIT
>
>
>
>
>
> cheers,
>
>
>
> paulv
Dear Paul and David,
thank you very much for your suggestions. Thank you for sharing your thoughts on this.
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...
Cheers,
Helder
|
|
|