ETHistory class documentation

Authors

Truls Becken (truls.becken@gmail.com)
A generic history class which can contain arbitary entries located in the past or the future.

Copyright: (C) 2008 Truls Becken

Software documentation for the ETHistory class

ETHistory : NSObject

Declared in:
ETHistory.h
Conforms to:
ETCollection

@group Collection Additions

ETHistory keeps a history of objects of some kind. After going back in time, it can go forward again towards the most recent object. Adding an object while at a historic point will discard the forward history.

It is also possible to give ETHistory an NSEnumerator to use as a lazy source for the forward history. This way, a collection of objects can be added as a "future", replacing the current forward history.

ETHistory supports ETCollection protocol, but not ETCollectionMutation which means -[NSObject isMutableCollection] returns NO and an history won't be considered as a mutable represented object by EtoileUI.

Method summary

history 

+ (id) history;

Return a new autoreleased history.


addObject: 

- (void) addObject: (id)object;

Set new current object, discarding the forward history.


back 

- (void) back;

Go one step back if possible.


clear 

- (void) clear;

Forget the history and discard the future.


currentObject 

- (id) currentObject;

Return the current object.


displayName 

- (NSString*) displayName;

Return 'History'.

See also -[NSObject displayName].


forward 

- (void) forward;

After going back, call this to go one step forward again.


hasNext 

- (BOOL) hasNext;

Return YES if it is possible to go forward.


hasPrevious 

- (BOOL) hasPrevious;

Return YES if it is possible to go back.


init 

- (id) init;
This is a designated initialiser for the class.

Initialize the history.


isOrdered 

- (BOOL) isOrdered;

Returns YES.


maxHistorySize 

- (int) maxHistorySize;

Return the maximum number of objects to remember.


nextObject 

- (id) nextObject;

Go forward, and return the new current object or nil if already at the end.


peek: 

- (id) peek: (int)relativeIndex;

Return an object at a position relative to the current object. Return nil if the index refers to a point before the beginning or after the end of time.


previousObject 

- (id) previousObject;

Go back, and return the new current object or nil if already at the start.


setFuture: 

- (void) setFuture: (NSEnumerator*)enumerator;

Set an enumerator to use as the forward history, discarding everything after the current object.


setMaxHistorySize: 

- (void) setMaxHistorySize: (int)maxSize;

Set the maximum number of objects to remember. When more objects than this are added, the oldest ones are forgotten.

The default is to remember an unlimited number of objects (max size = 0).

Note that max size only limits the number of objects before -currentObject . Setting a future and peeking into it may force the history to temporarily hold more objects.