ObjFW
Public Member Functions | Static Public Member Functions | Public Attributes
OFObject Class Reference

The root class for all other classes inside ObjFW. More...

#include <OFObject.h>

Inheritance diagram for OFObject:
<OFObject> OFAllocFailedException OFApplication OFArray OFAutoreleasePool OFDataArray OFDate OFDictionary OFEnumerator OFException OFHash OFHTTPRequest OFHTTPRequestResult OFList OFMutex OFNumber OFPlugin OFStream OFStreamObserver OFString OFThread OFTLSKey OFURL OFXMLAttribute OFXMLElement OFXMLElementBuilder OFXMLParser

List of all members.

Public Member Functions

id init ()
OFStringclassName ()
BOOL conformsToProtocol: (Protocol *protocol)
IMP methodForSelector: (SEL selector)
const char * typeEncodingForSelector: (SEL selector)
OFStringdescription ()
void addMemoryToPool: (void *ptr)
void * allocMemoryWithSize: (size_t size)
void * allocMemoryForNItems:withSize: (size_t nitems,[withSize] size_t size)
void * resizeMemory:toSize: (void *ptr,[toSize] size_t size)
void * resizeMemory:toNItems:withSize: (void *ptr,[toNItems] size_t nitems,[withSize] size_t size)
void freeMemory: (void *ptr)
void dealloc ()

Static Public Member Functions

void load ()
void initialize ()
id alloc ()
Class class ()
OFStringclassName ()
BOOL isSubclassOfClass: (Class class_)
Class superclass ()
BOOL instancesRespondToSelector: (SEL selector)
BOOL conformsToProtocol: (Protocol *protocol)
IMP instanceMethodForSelector: (SEL selector)
const char * typeEncodingForInstanceSelector: (SEL selector)
OFStringdescription ()
IMP setImplementation:forClassMethod: (IMP newimp,[forClassMethod] SEL selector)
IMP replaceClassMethod:withMethodFromClass: (SEL selector,[withMethodFromClass] Class class_)
IMP setImplementation:forInstanceMethod: (IMP newimp,[forInstanceMethod] SEL selector)
IMP replaceInstanceMethod:withMethodFromClass: (SEL selector,[withMethodFromClass] Class class_)

Public Attributes

Class isa
 The class of the object.

Detailed Description

The root class for all other classes inside ObjFW.


Member Function Documentation

void OFObject::addMemoryToPool: ( void*  ptr) [virtual]

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:
ptrA pointer to add to the memory pool
id OFObject::alloc ( ) [static, virtual]

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 * OFObject::allocMemoryForNItems:withSize: ( size_t  nitems,
[withSize] size_t  size 
) [virtual]

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:
nitemsThe number of items to allocate
sizeThe size of each item to allocate
Returns:
A pointer to the allocated memory
void * OFObject::allocMemoryWithSize: ( size_t  size) [virtual]

Allocates memory and stores it in the object's memory pool so it can be free'd automatically when the object is deallocated.

Parameters:
sizeThe size of the memory to allocate
Returns:
A pointer to the allocated memory
Class OFObject::class ( ) [static, virtual]
Returns:
The class

Reimplemented from <OFObject>.

OFString * OFObject::className ( ) [static, virtual]
Returns:
The name of the class as a C string
OFString* OFObject::className ( ) [virtual]
Returns:
The name of the object's class.
BOOL OFObject::conformsToProtocol: ( Protocol*  protocol) [static, virtual]

Checks whether the class conforms to a given protocol.

Parameters:
protocolThe protocol which should be checked for conformance
Returns:
A boolean whether the class conforms to the specified protocol
BOOL OFObject::conformsToProtocol: ( Protocol *  protocol) [virtual]
Parameters:
protocolThe protocol which should be checked for conformance
Returns:
A boolean whether the objects conforms to the specified protocol
void OFObject::dealloc ( ) [virtual]

Deallocates the object and also frees all memory in its memory pool.

It is also called when the retain count reaches zero.

OFString * OFObject::description ( ) [static, virtual]

Returns a description for the class, which is usually the class name.

This is mostly for debugging purposes.

Reimplemented in OFException, and OFAllocFailedException.

OFString* OFObject::description ( ) [virtual]

Returns a description for the object.

This is mostly for debugging purposes.

Reimplemented in OFException, and OFAllocFailedException.

void OFObject::freeMemory: ( void*  ptr) [virtual]

Frees allocated memory and removes it from the object's memory pool. Does nothing if ptr is NULL.

Parameters:
ptrA pointer to the allocated memory
id OFObject::init ( ) [virtual]

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, and OFTLSKey.

void OFObject::initialize ( ) [static, virtual]

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 OFObject::instanceMethodForSelector: ( SEL  selector) [static, virtual]
Parameters:
selectorThe 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 OFObject::instancesRespondToSelector: ( SEL  selector) [static, virtual]

Checks whether instances of the class respond to a given selector.

Parameters:
selectorThe selector which should be checked for respondance
Returns:
A boolean whether instances of the class respond to the specified selector
BOOL OFObject::isSubclassOfClass: ( Class  class_) [static, virtual]
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
void OFObject::load ( ) [static, virtual]

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 OFObject::methodForSelector: ( SEL  selector) [virtual]
Parameters:
selectorThe selector for which the method should be returned
Returns:
The implementation for the specified selector
IMP OFObject::replaceClassMethod:withMethodFromClass: ( SEL  selector,
[withMethodFromClass] Class  class_ 
) [static, virtual]

Replaces a class method with a class method from another class.

Parameters:
selectorThe selector of the class method to replace
class_The class from which the new class method should be taken
Returns:
The old implementation
IMP OFObject::replaceInstanceMethod:withMethodFromClass: ( SEL  selector,
[withMethodFromClass] Class  class_ 
) [static, virtual]

Replaces an instance method with an instance method from another class.

Parameters:
selectorThe selector of the instance method to replace
class_The class from which the new instance method should be taken
Returns:
The old implementation
void * OFObject::resizeMemory:toNItems:withSize: ( void*  ptr,
[toNItems] size_t  nitems,
[withSize] size_t  size 
) [virtual]

Resizes memory in the object's memory pool to the specific number of items of the specified size.

Parameters:
ptrA pointer to the already allocated memory
nitemsThe number of items to resize to
sizeThe size of each item to resize to
Returns:
A pointer to the resized memory chunk
void * OFObject::resizeMemory:toSize: ( void*  ptr,
[toSize] size_t  size 
) [virtual]

Resizes memory in the object's memory pool to the specified size.

Parameters:
ptrA pointer to the already allocated memory
sizeThe new size for the memory chunk
Returns:
A pointer to the resized memory chunk
IMP OFObject::setImplementation:forClassMethod: ( IMP  newimp,
[forClassMethod] SEL  selector 
) [static, virtual]

Replaces a class method implementation with another implementation.

Parameters:
newimpThe new implementation for the class method
selectorThe selector of the class method to replace
Returns:
The old implementation
IMP OFObject::setImplementation:forInstanceMethod: ( IMP  newimp,
[forInstanceMethod] SEL  selector 
) [static, virtual]

Replaces an instance method implementation with another implementation.

Parameters:
newimpThe new implementation for the instance method
selectorThe selector of the instance method to replace
Returns:
The old implementation
Class OFObject::superclass ( ) [static, virtual]
Returns:
The superclass of the class
const char * OFObject::typeEncodingForInstanceSelector: ( SEL  selector) [static, virtual]
Parameters:
selectorThe selector for which the type encoding should be returned
Returns:
The type encoding of the instance method for the specified selector
const char * OFObject::typeEncodingForSelector: ( SEL  selector) [virtual]
Parameters:
selectorThe selector for which the type encoding should be returned
Returns:
The type encoding for the specified selector

The documentation for this class was generated from the following files:
 All Classes Functions Variables