< OLArithmetic > Protocol Reference

A protocol for performing simple arithmetic with arbitrary objects. More...

#import <ObjectiveLib/Arithmetic.h>

List of all members.

Public Member Functions

(id) - arithmeticAdd:
 Add the value of a given object to this object's value.
(id) - arithmeticDivideBy:
 Divide this object's value by the value of another object.
(id) - arithmeticModulus:
 Compute the remainder of division by the value of a given object.
(id) - arithmeticMultiply:
 Multiply this object's value by the value of a given one.
(id) - arithmeticNegate
 Negate the value of this object.
(id) - arithmeticSubtract:
 Subtract the value of a given object from this object's value.


Detailed Description

A protocol for performing simple arithmetic with arbitrary objects.

The primary use of this protocol is with function objects that perform arithmetic, like OLPlus. All the messages in this protocol perform an arithmetic operation on a passed-in argument, allocate a new object for the result of the operation and return it.

Note:
The objects returned by this protocol should be owned by the sender of the message. That is, no attempt in implementation should be made to autorelease the objects. The sender of the arithmetic message will handle memory management of the returned object. The reason is that this protocol is intended for use in function objects, which operate their own system of memory management.
See also:
Function Objects


Member Function Documentation

- (id) arithmeticAdd: (id)  value  

Add the value of a given object to this object's value.

The two values are added together and a new object containing the result is returned. The result should be the same as using operator + in Standard C.

Parameters:
value the value to add
Returns:
the result of the addition

- (id) arithmeticDivideBy: (id)  value  

Divide this object's value by the value of another object.

The result of the division is returned in a newly created object. The result should be the same as using operator / in Standard C.

Parameters:
value the value by which to divide
Returns:
the result of the division

- (id) arithmeticModulus: (id)  value  

Compute the remainder of division by the value of a given object.

The result is returned in a newly created object. The result should be the same as using operator % in Standard C.

Parameters:
value the value by which to divide
Returns:
the remainder of the division

- (id) arithmeticMultiply: (id)  value  

Multiply this object's value by the value of a given one.

The result of the multiplication is returned in a newly created object. The result should be the same as using operator * in Standard C.

Parameters:
value the value by which to multiply
Returns:
the result of the multiplication

- (id) arithmeticNegate  

Negate the value of this object.

The negated value is returned in a newly created object. The result should be the same as using the unary operator - in Standard C.

Returns:
the result of the negation

- (id) arithmeticSubtract: (id)  value  

Subtract the value of a given object from this object's value.

The given value is subtracted and a new object containing the result is returned. The result should be the same as using binary operator - in Standard C.

Parameters:
value the value to subtract
Returns:
the result of the subtraction


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