OLMemFun Class Reference
[Function Objects]

A function object that sends a given message to a given object and returns the result. More...

#import <ObjectiveLib/Functional.h>

Inheritance diagram for OLMemFun:

Inheritance graph
[legend]
List of all members.

Public Member Functions

(void) - encodeWithCoder:
 Encode the function object.
(id) - performUnaryFunctionWithArg:
 Send the stored message to the object referenced by arg.
(void) - writeSelfToStream:
 Write the object to a stream.
Initializers and Deallocators
(id) - initWithCoder:
 Initialize the function object.
(id) - initWithObjectInStream:
 Initialize the object.
(id) - initWithSelector:
 Initialize the function object with the given selector.

Static Public Member Functions

(id) + functorWithSelector:
 Create and return an instance of OLMemFun.

Protected Attributes

SEL sel
 The selector to perform.

Detailed Description

A function object that sends a given message to a given object and returns the result.

The selector is stored in the function object and then is invoked by the function object using the given argument as the object to which to send the message.

See also:
OLMemFun1


Member Function Documentation

- (void) encodeWithCoder: (NSCoder *)  encoder  

Encode the function object.

The function object is saved to an archive using encoder. The function object will be retrieved from the archive using the initializer initWithCoder:.

Parameters:
encoder the coder which will save the function object to the archive

Reimplemented from OLStreamableFunctor.

+ (id) functorWithSelector: (SEL)  selector  

Create and return an instance of OLMemFun.

Note:
If OpenStep is present the returned object will be autoreleased before being returned.
Parameters:
selector the selector to store for future invocation
Returns:
a new functor

- (id) initWithCoder: (NSCoder *)  decoder  

Initialize the function object.

This initializer creates a new function object from an archive and returns it.

Postcondition:
The function object returned will be identical to the function object saved to the archive using the encodeWithCoder: message.
Parameters:
decoder the coder which will decode the archived function object
Returns:
a reference to this function object

Reimplemented from OLStreamableFunctor.

- (id) initWithObjectInStream: (OLObjectInStream *)  stream  

Initialize the object.

Each instance variable is read from stream and all other initialization is performed.

Parameters:
stream the stream from which to read
Returns:
a reference to this object

Reimplemented from OLStreamableFunctor.

- (id) initWithSelector: (SEL)  selector  

Initialize the function object with the given selector.

Parameters:
selector the selector to store for future invocation
Returns:
a reference to this function object

- (id) performUnaryFunctionWithArg: (id)  arg  

Send the stored message to the object referenced by arg.

The object returned may or may not be owned by the sender of the message, depending on the nature of the message being sent. No attempt is made by the function object to control memory management of the returned object.

Precondition:
arg must respond to the selector passed to the initializer.
Parameters:
arg the object to which to send the message
Returns:
the result of invoking the message. Note that memory management is not controlled by the function object and the question of whether to deallocate the returned object depends on the nature of the message.

Reimplemented from < OLUnaryFunction >.

- (void) writeSelfToStream: (OLObjectOutStream *)  stream  

Write the object to a stream.

All instance variables are written to stream.

Parameters:
stream the stream to which to write.

Reimplemented from OLStreamableFunctor.


Member Data Documentation

- (SEL) sel [protected]

The selector to perform.


The documentation for this class was generated from the following file:
ObjectiveLibGenerated Sun Apr 22 15:13:35 2007, © 2004-2007 Will Mason
SourceForge.net Logo