Managing several object instances [message #81497] |
Mon, 17 September 2012 15:05 |
Helder Marchetto
Messages: 520 Registered: November 2011
|
Senior Member |
|
|
Dear all,
it's quite late and I can't get some sleep, so I thought that the forum would be a pretty good way to clear out some thoughts that have been keeping me from sleeping. Soooo, after having written up a pretty large image analysis GUI, I'm considering implementing for the first time (for me of course!) an object into it the big software. The reasons are two:
1) some when I have to start/learn how to use objects. It's something cool and I've been missing out
2) It seems to fit this sort of application.
The idea is a that in the main program one can generate lines on an image. The user may select any of those lines to plot a profile (cross-section or whatever you like to call it) and the object would plot it in a new window/GUI with several options (save,...). Not to overload the system, only one of those lines may be working "live"/be connected with the object updating it live. I would implement some sort of "token" system.
However, I'm not coming around a problem. How can I efficiently keep track of the generated object instances. Suppose the user generates 5 line profiles, and destroys the third and then generates a new one and so on and so forth.
What is the most efficient way of keeping track of the existing/running object instances so that I can efficiently pass around my token?
That means that I need to be able to add and delete object instances in a record and at any time be able to know which ones are working and active...
I was thinking of an object array where given n-elements, the next is added as:
OldArr = MyObjArr
MyObjArr = OBJARR(n+1)
MyObjArr[0:(n-1)] = OldArr
MyObjArr[n] = OBJ_NEW('MyNewObject')
And in a similar fashion I would erase objects.
However, I find this not "smart". It will not really be computationally inefficient, because I don't expect (or will limit) the number of instances to maybe 5 or 10 and for sure not 1000.
Thanks for any help and good night.
Cheers, h
|
|
|