// // HOMIteratedVarWrapper.h // HigherOrderMessaging // // Created by Ofri Wolfus on 18/10/05. // Copyright 2005 Ofri Wolfus. All rights reserved. // #import /*! * @header HOMIteratedVarWrapper * HOMIteratedVarWrapper is used to hold an enumerator which is used by the -each HOM. This is a PRIVATE header! * @copyright Created by Ofri Wolfus on 18/10/05. Copyright 2004-2005 Ofri Wolfus. All rights reserved. * @updated 2005-10-18 * @version 0.1 */ //Pointer to objectAtIndex: method of NSArray typedef id (* IMPWithUnsignedArg)(id, SEL, unsigned); /*! * @class HOMIteratedVarWrapper * @abstract HOMIteratedVarWrapper is used to hold contents of a collection which is used by the -each HOM. Messages to it we'll be forwarded to all objects in its contents array. * HOMIteratedVarWrapper instances are recycled by default. */ @interface HOMIteratedVarWrapper : NSProxy { NSArray *contents; BOOL autoReleases; IMPWithUnsignedArg objectAtIndexIMP; unsigned nextIndex; unsigned count; } /*! * @method iteratedVarWrapperWithContents:autoReleases: * @abstract Creates and returns an initialized autoreleased HOMIteratedVarWrapper instance. */ + (id)iteratedVarWrapperWithContents:(NSArray *)array autoReleases:(BOOL)flag; /*! * @method initWithContents:autoReleases: * @abstract Returns an initialized HOMIteratedVarWrapper instance. * @discussion If flag is YES, the receiver will automatically release itself after the iteration through its contents is complete (that is, when -HOMNextObject returns nil). * The contents of the receiver is a new array containing all objects from array. */ - (id)initWithContents:(NSArray *)array autoReleases:(BOOL)flag; /*! * autoReleases * @abstract Returns a flag indicating whether the receiver will release itself when HOMNextObject returns nil or not. */ - (BOOL)autoReleases; /*! * setAutoReleases: * @abstract Sets the autoReleases flag of the receiver. */ - (void)setAutoReleases:(BOOL)flag; /*! * @method HOMContents * @abstract Returns the contents of the receiver. */ - (NSArray *)HOMContents; /*! * @method HOMNextObject * @abstract Calls -nextObject on the enumerator of the receiver, and returns its value. * If the autoReleases flag is YES then the receiver will release itself when HOMNextObject returns nil. */ - (id)HOMNextObject; /*! * @method resetIteration * @abstract Resets the receiver and causes the iteration through its contents to start from the beginning. * @discussion Generally, you should never call this method if the autoReleases flag is set to YES. * If you really have to, then remember that each time the receiver will reach to its last object it'll release itself and therefor you must retain it before. */ - (void)resetIteration; @end