OFObject Class Reference
The root class for all other classes inside ObjFW.
More...
#import <OFObject.h>
List of all members.
Detailed Description
The root class for all other classes inside ObjFW.
Member Function Documentation
- (id) addMemoryToPool: |
|
(void*) |
ptr |
|
|
Adds a pointer to the object's memory pool.
This is useful to add memory allocated by functions such as asprintf to the pool so it gets free'd automatically when the object is deallocated.
- Parameters:
-
| ptr | A pointer to add to the memory pool |
Allocates memory for an instance of the class and sets up the memory pool for the object.
alloc will never return nil, instead, it will throw an OFAllocFailedException.
- Returns:
- The allocated object.
- (void *) allocMemoryForNItems: |
|
(size_t) |
nitems |
withSize: |
|
(size_t) |
size | |
|
|
| | |
Allocates memory for the specified number of items and stores it in the object's memory pool so it can be free'd automatically when the object is deallocated.
- Parameters:
-
| nitems | The number of items to allocate |
| size | The size of each item to allocate |
- Returns:
- A pointer to the allocated memory
- (void *) allocMemoryWithSize: |
|
(size_t) |
size |
|
|
Allocates memory and stores it in the object's memory pool so it can be free'd automatically when the object is deallocated.
- Parameters:
-
| size | The size of the memory to allocate |
- Returns:
- A pointer to the allocated memory
- Returns:
- The class of the object
- (const char*) className |
|
|
|
|
- Returns:
- The name of the object's class as a C string
+ (const char *) className |
|
|
|
|
- Returns:
- The name of the class as a C string
- (BOOL) conformsToProtocol: |
|
(Protocol *) |
protocol |
|
|
- Parameters:
-
| protocol | The protocol which should be checked for conformance |
- Returns:
- A boolean whether the objects conforms to the specified protocol
+ (BOOL) conformsToProtocol: |
|
(Protocol*) |
protocol |
|
|
Checks whether the class conforms to a given protocol.
- Parameters:
-
| protocol | The protocol which should be checked for conformance |
- Returns:
- A boolean whether the class conforms to the specified protocol
Deallocates the object and also frees all memory in its memory pool.
It is also called when the retain count reaches zero.
- (id) freeMemory: |
|
(void*) |
ptr |
|
|
Frees allocated memory and removes it from the object's memory pool. Does nothing if ptr is NULL.
- Parameters:
-
| ptr | A pointer to the allocated memory |
Calculates a hash for the object.
Classes containing data (like strings, arrays, lists etc.) should reimplement this!
- Returns:
- A 32 bit hash for the object
Initializes an already allocated object.
Derived classes may override this, but need to do self = [super init] before they do any initialization themselves. init may never return nil, instead an exception (for example OFInitializationFailed) should be thrown.
- Returns:
- An initialized object
Reimplemented in OFDictionary, OFString, and OFTLSKey.
This code is executed once when a method of the class is called for the first time.
Derived classes can override this to execute their own code on initialization.
+ (IMP) instanceMethodForSelector: |
|
(SEL) |
selector |
|
|
- Parameters:
-
| selector | The selector for which the method should be returned |
- Returns:
- The implementation of the instance method for the specified selector or nil if it isn't implemented
+ (BOOL) instancesRespondToSelector: |
|
(SEL) |
selector |
|
|
Checks whether instances of the class respond to a given selector.
- Parameters:
-
| selector | The selector which should be checked for respondance |
- Returns:
- A boolean whether instances of the class respond to the specified selector
Checks two objects for equality.
Classes containing data (like strings, arrays, lists etc.) should reimplement this!
- Parameters:
-
| obj | The object which should be tested for equality |
- Returns:
- A boolean whether the object is equal to the specified object
- (BOOL) isKindOfClass: |
|
(Class) |
class_ |
|
|
- Parameters:
-
| class_ | The class whose kind is checked |
- Returns:
- A boolean whether the object is of the specified kind
+ (BOOL) isSubclassOfClass: |
|
(Class) |
class_ |
|
|
- Parameters:
-
| class_ | The class which is checked for being a superclass |
- Returns:
- A boolean whether the class class is a subclass of the specified class
This code is executed once when the class is loaded into the runtime.
Derived classes can overide this to execute their own code when the class is loaded.
- (IMP) methodForSelector: |
|
(SEL) |
selector |
|
|
- Parameters:
-
| selector | The selector for which the method should be returned |
- Returns:
- The implementation for the specified selector
Decreases the retain count.
Each time an object is released, the retain count gets decreased and the object deallocated if it reaches 0.
Reimplemented in OFAutoreleasePool.
+ (IMP) replaceMethod: |
|
(SEL) |
selector |
withMethodFromClass: |
|
(Class) |
class_ | |
|
|
| | |
Replaces a method with a method from another class.
- Parameters:
-
| selector | The selector of the method to replace |
| class_ | The class from which the new method should be taken |
- Returns:
- The old implementation
- (void *) resizeMemory: |
|
(void*) |
ptr |
toNItems: |
|
(size_t) |
nitems |
withSize: |
|
(size_t) |
size | |
|
|
| | |
Resizes memory in the object's memory pool to the specific number of items of the specified size.
- Parameters:
-
| ptr | A pointer to the already allocated memory |
| nitems | The number of items to resize to |
| size | The size of each item to resize to |
- Returns:
- A pointer to the resized memory chunk
- (void *) resizeMemory: |
|
(void*) |
ptr |
toSize: |
|
(size_t) |
size | |
|
|
| | |
Resizes memory in the object's memory pool to the specified size.
- Parameters:
-
| ptr | A pointer to the already allocated memory |
| size | The new size for the memory chunk |
- Returns:
- A pointer to the resized memory chunk
- (BOOL) respondsToSelector: |
|
(SEL) |
selector |
|
|
- Parameters:
-
| selector | The selector which should be checked for respondance |
- Returns:
- A boolean whether the objects responds to the specified selector
Increases the retain count.
Each time an object is released, the retain count gets decreased and the object deallocated if it reaches 0.
+ (IMP) setImplementation: |
|
(IMP) |
newimp |
forMethod: |
|
(SEL) |
selector | |
|
|
| | |
Replaces a method implementation with another implementation.
- Parameters:
-
| newimp | The new implementation for the method |
| selector | The selector of the method to replace |
- Returns:
- The old implementation
The documentation for this class was generated from the following files: