Skip to content

Undo & Redo via the Object Constructor History

dougbinks edited this page Sep 8, 2014 · 1 revision

The Object Constructor History in the Object Factory gives developers Undo / Redo functionality for their code changes.

This is controlled via the IObjectFactorySystem interface functions:

// sets the history of object constructors to a given size
// if set to smaller than before, will preserve the latest
// will not resize smaller than required to preserve current undo state
// default history size is 0, which means history is off (no undo & redo)
// if AddConstructors is called when the current history location is -ve,
// the constructors are updated to locatin 0 (current) prior to adding.
virtual void				SetObjectConstructorHistorySize( int num_ ) = 0;
virtual int					GetObjectConstructorHistorySize() = 0;

// undo & redo object constructor changes
// this will only undo swapped constructors, not new ones
virtual bool				UndoObjectConstructorChange() = 0;
virtual bool				RedoObjectConstructorChange() = 0;

// history location is 0 for current, +ve number for a previous location
// undo calls causes location +1, redo -1 bounded by HistorySize and 0.
virtual int					GetObjectContstructorHistoryLocation() = 0;

The default history size is 0, meaning undo/redo is turned off. Set this to a non zero positive value to activate undo/redo - the memory usage should be fairly low as it only stores vectors of pointers to the before and after versions of changed object constructors. Take care as to where you call the undo/redo calls, as this will result in the changed objects being deleted after the new ones are created, so if called from that code any non static members accessed after the call may be invalid.

You can’t perform that action at this time.