On Sat, 31 Aug 2002, mark wrote:
Secondly are you going to restore the states of externals?
I'm not... I'm not going to violate encapsulation to do that. the "Undo" feature should work as if the operations were done by hand, for simplicity.
And here comes my first problem - I can't use pointers to the objects my deleted object was connected to because those objects may be deleted and restored (thus changing any pointers) - so I need ways of
What can I say but: well don't use pointers then.
What you have to do is to create a stack on which you push the operations that are required to undo what the user has done. The operations may be {add "+ 4" as object # 15} upon a delete or {remove-connection 15 0 4 2} upon a add-connection.
The objects must be indexed so that each object has a unique id in its patcher, and that id is to be reused by only a new instance created by the undo queue.
There is a big difference in undoing changes in a object network that undoing operations on an array.
so far i have reduced the graph-of-objects problem down to a problem of maintaining one undoqueue for two dictionaries, one for objects and one for connections, plus a marshaller (which is already implemented for load/save)...
...which is a problem i have solved before.
Mathieu Bouchard http://artengine.ca/matju