mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-02-21 02:20:55 +00:00
* EOControl/EOClassDescription.m/h:
o added -dictionaryForProperties o added EOEntityClassDescription -dictionaryForProperties wich use entity -_dictionaryForProperties * EOControl/EOGenericRecord.m/h: o use EOClassDescription -dictionaryForProperties instead of building itself it's dictionary so we can always use the same EOMKKDInitializer to save (lots of) memory. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@18227 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ce6dc1bf92
commit
93e970430f
5 changed files with 73 additions and 22 deletions
|
@ -82,6 +82,15 @@
|
|||
o implemented -bindingKeys
|
||||
o implemented -keyPathForBindingKey:
|
||||
o added EOQualifierVariableSubstitutionException;
|
||||
* EOControl/EOClassDescription.m/h:
|
||||
o added -dictionaryForProperties
|
||||
o added EOEntityClassDescription -dictionaryForProperties
|
||||
wich use entity -_dictionaryForProperties
|
||||
* EOControl/EOGenericRecord.m/h:
|
||||
o use EOClassDescription -dictionaryForProperties
|
||||
instead of building itself it's dictionary so we can
|
||||
always use the same EOMKKDInitializer to save (lots of)
|
||||
memory.
|
||||
|
||||
2003-10-24 David Ayers <d.ayers@inode.at>
|
||||
|
||||
|
|
|
@ -84,6 +84,10 @@ fromFetchInEditingContext: (EOEditingContext *)editingContext;
|
|||
- (NSArray *)attributeKeys;
|
||||
- (NSArray *)toOneRelationshipKeys;
|
||||
- (NSArray *)toManyRelationshipKeys;
|
||||
|
||||
/** returns a new autoreleased mutable dictionary to store properties **/
|
||||
- (NSMutableDictionary*) dictionaryForInstanceProperties;
|
||||
|
||||
- (EORelationship *)relationshipNamed: (NSString *)relationshipName;
|
||||
- (EORelationship *)anyRelationshipNamed: (NSString *)relationshipNamed;
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ RCS_ID("$Id$")
|
|||
#include <EOControl/EOCheapArray.h>
|
||||
#include <EOControl/EONSAddOns.h>
|
||||
#include <EOControl/EODebug.h>
|
||||
#include <EOControl/EOMutableKnownKeyDictionary.h>
|
||||
|
||||
// NOTE: (stephane@sente.ch) Should we subclass NSClassDescription?
|
||||
|
||||
|
@ -262,6 +263,39 @@ static id classDelegate = nil;
|
|||
return nil;
|
||||
}
|
||||
|
||||
/** returns a new autoreleased mutable dictionary to store properties **/
|
||||
- (NSMutableDictionary*) dictionaryForInstanceProperties
|
||||
{
|
||||
// Default implementation create a new EOMKKDInitializer. But subclass
|
||||
// implementation like EOEntityClassDescription can (should :-) use the
|
||||
// same EOMKKDInitializer to save memory.
|
||||
|
||||
NSMutableArray* classPropertyNames=nil;
|
||||
NSMutableDictionary* dictionary=nil;
|
||||
|
||||
EOFLOGObjectFnStart();
|
||||
|
||||
// Get class properties (attributes + relationships)
|
||||
classPropertyNames = [[NSMutableArray alloc]
|
||||
initWithArray: [self attributeKeys]];
|
||||
[classPropertyNames addObjectsFromArray:
|
||||
[self toOneRelationshipKeys]];
|
||||
[classPropertyNames addObjectsFromArray:
|
||||
[self toManyRelationshipKeys]];
|
||||
|
||||
NSAssert1([classPropertyNames count] > 0,
|
||||
@"No classPropertyNames in %@", self);
|
||||
|
||||
dictionary = [EOMutableKnownKeyDictionary
|
||||
dictionaryWithInitializer:
|
||||
[[EOMKKDInitializer newWithKeyArray: classPropertyNames] autorelease]];
|
||||
[classPropertyNames release];
|
||||
|
||||
EOFLOGObjectFnStop();
|
||||
|
||||
return dictionary;
|
||||
};
|
||||
|
||||
- (void)awakeObject: (id)object
|
||||
fromFetchInEditingContext: (EOEditingContext *)anEditingContext
|
||||
{
|
||||
|
|
|
@ -68,6 +68,11 @@
|
|||
|
||||
- (NSString *)debugDictionaryDescription;
|
||||
|
||||
/** should returns an array of property names to exclude from entity
|
||||
instanceDictionaryInitializer.
|
||||
You can override this to exclude properties manually handled by derived object **/
|
||||
+ (NSArray *)_instanceDictionaryInitializerExcludedPropertyNames;
|
||||
|
||||
@end /* EOGenericRecord */
|
||||
|
||||
|
||||
|
|
|
@ -129,6 +129,16 @@ static NSRecursiveLock *allGenericRecordsLock = nil;
|
|||
[allGenericRecordsLock unlock];
|
||||
}
|
||||
|
||||
-(void)_createDictionaryForInstanceProperties
|
||||
{
|
||||
// Ayers: Review
|
||||
// We use entity dictionaryForProperties to avoid creation
|
||||
//of new EOMKKDInitializer
|
||||
ASSIGN(dictionary,[classDescription dictionaryForInstanceProperties]);
|
||||
EOFLOGObjectLevelArgs(@"EOGenericRecord", @"Record %p: dictionary=%@",
|
||||
self, dictionary);
|
||||
};
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
|
@ -145,9 +155,6 @@ static NSRecursiveLock *allGenericRecordsLock = nil;
|
|||
{
|
||||
if ((self = [self init]))
|
||||
{
|
||||
NSMutableArray *classPropertyNames = nil;
|
||||
EOMutableKnownKeyDictionary *entityMKKD = nil;
|
||||
|
||||
if (!classDesc)
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
|
@ -162,25 +169,7 @@ static NSRecursiveLock *allGenericRecordsLock = nil;
|
|||
|
||||
ASSIGN(classDescription, classDesc);
|
||||
|
||||
// Get class properties (attributes + relationships)
|
||||
classPropertyNames = [[NSMutableArray alloc]
|
||||
initWithArray: [classDesc attributeKeys]];
|
||||
[classPropertyNames addObjectsFromArray:
|
||||
[classDesc toOneRelationshipKeys]];
|
||||
[classPropertyNames addObjectsFromArray:
|
||||
[classDesc toManyRelationshipKeys]];
|
||||
|
||||
NSAssert1([classPropertyNames count] > 0,
|
||||
@"No classPropertyNames in %@", classDesc);
|
||||
|
||||
entityMKKD = [EOMutableKnownKeyDictionary
|
||||
dictionaryWithInitializer:
|
||||
[[EOMKKDInitializer newWithKeyArray: classPropertyNames] autorelease]];
|
||||
|
||||
ASSIGN(dictionary,entityMKKD);
|
||||
EOFLOGObjectLevelArgs(@"EOGenericRecord", @"Record %p: dictionary=%@",
|
||||
self, dictionary);
|
||||
[classPropertyNames release];
|
||||
[self _createDictionaryForInstanceProperties];
|
||||
}
|
||||
|
||||
return self;
|
||||
|
@ -998,6 +987,16 @@ infinite loop in description **/
|
|||
return [dictionary debugDescription];
|
||||
}
|
||||
|
||||
/** should returns an array of property names to exclude from entity
|
||||
instanceDictionaryInitializer.
|
||||
You can override this to exclude properties manually handled by derived object **/
|
||||
+ (NSArray *)_instanceDictionaryInitializerExcludedPropertyNames
|
||||
{
|
||||
//Ayers: Review (There is also an NSObject category making kind of redundant)
|
||||
// default implementation returns nil
|
||||
return nil;
|
||||
};
|
||||
|
||||
/*dictionary has following entries:
|
||||
- NSMutableDictionary* processed: processed entries (key=object address, value=size)
|
||||
- NSMutableDictionary* summaryNb: objects by class name (key=class name, value=number of objects)
|
||||
|
|
Loading…
Reference in a new issue