The only solution I can think of without switching entirely to the Command pattern is to generate a kind of incremental backup of the object as a memento instead of using the whole object.
The idea is that you would strip from the memento any data that haven't changed. You would then only store the difference.
When doing an undo, you would use the current state of the object and the difference to generate a memento and inject it in the process.
Here's basically how it will look like:
- The caretaker is going to do something to the originator, but wants to be able to undo the change.
- The caretaker first asks the originator for a memento object.
- Then it does whatever operation (or sequence of operations) it was going to do.
- A compressor will compare the memento and the new state of the originator and generate a diff object which will be stored on the operation stack
To undo:
- The compressor will recreate a memento object from the originator state and the diff object
- The new memento is then used to restore the originator state.
The implementation of the compressor class might be tricky and will depend on the type of operations you will perform.
You will be using one single memento object and store only the diff objects which can also be compressed if needed but will probably be rather small.