4
Copyright (C) 2000, MDlink online service center GmbH, Helge Hess
7
Author: Helge Hess <helge.hess@mdlink.de>
9
This file is part of libFoundation.
11
Permission to use, copy, modify, and distribute this software and its
12
documentation for any purpose and without fee is hereby granted, provided
13
that the above copyright notice appear in all copies and that both that
14
copyright notice and this permission notice appear in supporting
17
We disclaim all warranties with regard to this software, including all
18
implied warranties of merchantability and fitness, in no event shall
19
we be liable for any special, indirect or consequential damages or any
20
damages whatsoever resulting from loss of use, data or profits, whether in
21
an action of contract, negligence or other tortious action, arising out of
22
or in connection with the use or performance of this software.
25
#include <Foundation/NSClassDescription.h>
26
#include <Foundation/NSNotification.h>
27
#include <Foundation/NSString.h>
30
LF_DECLARE NSString *NSClassDescriptionNeededForClassNotification =
31
@"NSClassDescriptionNeededForClass";
33
@implementation NSClassDescription
35
static NSMapTable *classToDesc = NULL; // THREAD
39
if (classToDesc == NULL) {
40
classToDesc = NSCreateMapTable(NSObjectMapKeyCallBacks,
41
NSObjectMapValueCallBacks,
48
+ (NSClassDescription *)classDescriptionForClass:(Class)_class
50
NSClassDescription *d;
52
if ((d = NSMapGet(classToDesc, _class)))
55
[[NSNotificationCenter defaultCenter]
57
NSClassDescriptionNeededForClassNotification
60
return NSMapGet(classToDesc, _class);
63
+ (void)registerClassDescription:(NSClassDescription *)_clazzDesc
64
forClass:(Class)_class
66
if (_clazzDesc == nil)
70
NSMapInsert(classToDesc, _class, _clazzDesc);
73
+ (void)invalidateClassDescriptionCache
75
NSResetMapTable(classToDesc);
80
- (NSArray *)attributeKeys
85
- (NSArray *)toManyRelationshipKeys
89
- (NSArray *)toOneRelationshipKeys
93
- (NSString *)inverseForRelationshipKey:(NSString *)_key
98
@end /* NSClassDescription */
100
@implementation NSObject(ClassDescriptionForwards)
102
static Class NSClassDescriptionClass = Nil;
104
- (NSClassDescription *)classDescription
106
if (NSClassDescriptionClass == Nil)
107
NSClassDescriptionClass = [NSClassDescription class];
109
return [NSClassDescriptionClass classDescriptionForClass:[self class]];
112
- (NSArray *)attributeKeys
114
return [[self classDescription] attributeKeys];
117
- (NSArray *)toManyRelationshipKeys
119
return [[self classDescription] toManyRelationshipKeys];
122
- (NSArray *)toOneRelationshipKeys
124
return [[self classDescription] toOneRelationshipKeys];
127
- (NSString *)inverseForRelationshipKey:(NSString *)_key
129
return [[self classDescription] inverseForRelationshipKey:_key];
132
@end /* NSObject(ClassDescriptionForwards) */