ObjFW
src/OFObject.h
00001 /*
00002  * Copyright (c) 2008, 2009, 2010, 2011, 2012
00003  *   Jonathan Schleifer <js@webkeks.org>
00004  *
00005  * All rights reserved.
00006  *
00007  * This file is part of ObjFW. It may be distributed under the terms of the
00008  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
00009  * the packaging of this file.
00010  *
00011  * Alternatively, it may be distributed under the terms of the GNU General
00012  * Public License, either version 2 or 3, which can be found in the file
00013  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
00014  * file.
00015  */
00016 
00017 #import "objfw-defs.h"
00018 
00019 #ifndef __STDC_LIMIT_MACROS
00020 # define __STDC_LIMIT_MACROS
00021 #endif
00022 #ifndef __STDC_CONSTANT_MACROS
00023 # define __STDC_CONSTANT_MACROS
00024 #endif
00025 
00026 #include <stddef.h>
00027 #include <stdint.h>
00028 #include <limits.h>
00029 
00030 #ifdef OF_OBJFW_RUNTIME
00031 # import <objfw-rt.h>
00032 #else
00033 # import <objc/objc.h>
00034 #endif
00035 
00036 #define OF_RETAIN_COUNT_MAX UINT_MAX
00037 #define OF_INVALID_INDEX SIZE_MAX
00038 
00042 typedef enum of_comparison_result_t {
00044         OF_ORDERED_ASCENDING = -1,
00046         OF_ORDERED_SAME = 0,
00048         OF_ORDERED_DESCENDING = 1
00049 } of_comparison_result_t;
00050 
00054 typedef enum of_endianess_t {
00055         OF_ENDIANESS_BIG_ENDIAN,
00056         OF_ENDIANESS_LITTLE_ENDIAN
00057 } of_endianess_t;
00058 
00062 typedef struct of_range_t {
00064         size_t start;
00066         size_t length;
00067 } of_range_t;
00068 
00072 typedef struct of_point_t {
00073         float x;
00074         float y;
00075 } of_point_t;
00076 
00080 typedef struct of_dimension_t {
00081         float width;
00082         float height;
00083 } of_dimension_t;
00084 
00088 typedef struct of_rectangle_t
00089 {
00090         of_point_t origin;
00091         of_dimension_t size;
00092 } of_rectangle_t;
00093 
00094 @class OFString;
00095 
00099 @protocol OFObject
00105 - (Class)class;
00106 
00113 - (BOOL)isKindOfClass: (Class)class_;
00114 
00122 - (BOOL)respondsToSelector: (SEL)selector;
00123 
00130 - (BOOL)conformsToProtocol: (Protocol*)protocol;
00131 
00138 - (IMP)methodForSelector: (SEL)selector;
00139 
00146 - (const char*)typeEncodingForSelector: (SEL)selector;
00147 
00154 - (id)performSelector: (SEL)selector;
00155 
00164 - (id)performSelector: (SEL)selector
00165            withObject: (id)object;
00166 
00177 - (id)performSelector: (SEL)selector
00178            withObject: (id)object
00179            withObject: (id)otherObject;
00180 
00190 - (BOOL)isEqual: (id)object;
00191 
00200 - (uint32_t)hash;
00201 
00208 - retain;
00209 
00215 - (unsigned int)retainCount;
00216 
00223 - (void)release;
00224 
00231 - autorelease;
00232 
00238 - self;
00239 @end
00240 
00244 @interface OFObject <OFObject>
00245 {
00246 @public
00248         Class isa;
00249 }
00250 
00258 + (void)load;
00259 
00269 + (void)initialize;
00270 
00280 + alloc;
00281 
00286 + new;
00287 
00293 + (Class)class;
00294 
00300 + (OFString*)className;
00301 
00309 + (BOOL)isSubclassOfClass: (Class)class_;
00310 
00316 + (Class)superclass;
00317 
00325 + (BOOL)instancesRespondToSelector: (SEL)selector;
00326 
00333 + (BOOL)conformsToProtocol: (Protocol*)protocol;
00334 
00343 + (IMP)instanceMethodForSelector: (SEL)selector;
00344 
00352 + (const char*)typeEncodingForInstanceSelector: (SEL)selector;
00353 
00361 + (OFString*)description;
00362 
00370 + (IMP)setImplementation: (IMP)newImp
00371           forClassMethod: (SEL)selector;
00372 
00380 + (IMP)replaceClassMethod: (SEL)selector
00381       withMethodFromClass: (Class)class_;
00382 
00391 + (IMP)setImplementation: (IMP)newImp
00392        forInstanceMethod: (SEL)selector;
00393 
00402 + (IMP)replaceInstanceMethod: (SEL)selector
00403          withMethodFromClass: (Class)class_;
00404 
00417 + (BOOL)addClassMethod: (SEL)selector
00418       withTypeEncoding: (const char*)typeEncoding
00419         implementation: (IMP)implementation;
00420 
00433 + (BOOL)addInstanceMethod: (SEL)selector
00434          withTypeEncoding: (const char*)typeEncoding
00435            implementation: (IMP)implementation;
00436 
00455 + (void)inheritMethodsFromClass: (Class)class_;
00456 
00466 - init;
00467 
00473 - (OFString*)className;
00474 
00482 - (OFString*)description;
00483 
00492 - (void)addMemoryToPool: (void*)pointer;
00493 
00502 - (void*)allocMemoryWithSize: (size_t)size;
00503 
00514 - (void*)allocMemoryForNItems: (size_t)nItems
00515                        ofSize: (size_t)size;
00516 
00527 - (void*)resizeMemory: (void*)pointer
00528                toSize: (size_t)size;
00529 
00542 - (void*)resizeMemory: (void*)pointer
00543              toNItems: (size_t)nItems
00544                ofSize: (size_t)size;
00545 
00553 - (void)freeMemory: (void*)pointer;
00554 
00562 - (void)dealloc;
00563 @end
00564 
00568 @protocol OFCopying
00578 - copy;
00579 @end
00580 
00587 @protocol OFMutableCopying
00593 - mutableCopy;
00594 @end
00595 
00601 @protocol OFComparing <OFObject>
00608 - (of_comparison_result_t)compare: (id)object;
00609 @end
00610 
00611 #import "OFObject+Serialization.h"
00612 
00613 #ifdef __cplusplus
00614 extern "C" {
00615 #endif
00616 extern id objc_getProperty(id, SEL, ptrdiff_t, BOOL);
00617 extern void objc_setProperty(id, SEL, ptrdiff_t, id, BOOL, BOOL);
00618 extern size_t of_pagesize;
00619 #ifdef __cplusplus
00620 }
00621 #endif
 All Classes Functions Variables Properties