Call -willChange: to support EOObserving in EOModel, EOEntity, EOAttribute,

EORelationship, EOStoredProcedure.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20745 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Matt Rice 2005-02-18 16:46:38 +00:00
parent 6b4ef319c9
commit 74a8e976bf
6 changed files with 87 additions and 1 deletions

View file

@ -1,3 +1,37 @@
2005-02-18 Matt Rice <ratmice@yahoo.com>
* EOAccess/EOModel.m (-addEntity:, -setName:): Call -willChange:
when modifying the receiver.
(-setConnectionDictionary:, -addEntity:, -removeEntity:): Ditto.
(-addStoredProcedure:, -removeStoredProcedure:, -setAdaptorName): Ditto.
* EOAccess/EOAttribute.m (-setName:, -setProtoType:,): Ditto.
(-setDefinition:, -setReadOnly:, -setWidth:, -setPrecision:): Ditto.
(-setScale:, -setWriteFormat:, -setReadFormat:): Ditto.
(-setParameterDirection:, -setServerTimeZone:): Ditto.
(-setValueFactoryMethodName:): Ditto.
(-setAdaptorValueConversionMethodName:): Ditto.
(-setFactoryMethodArgumentType:): Ditto.
* EOAccess/EOEntity.m (-setRestrictingQualifier:): Ditto.
(-setCachesObjects:, -setReadOnly:, -addAttribute:): Ditto.
(-removeAttribute:, -addRelationship:, -removeRelationship:): Ditto.
(-addFetchSpecification:withName:): Ditto.
(-removeFetchSpecificationNamed:): Ditto.
(-setClassProperties:, -setPrimaryKeyAttributes:): Ditto.
(-setAttributesUsedForLocking:, -addSubEntity:): Ditto.
(-removeSubEntity:, -setIsAbstractEntity:): Ditto.
(-setMaxNumberOfInstancesToBatch:): Ditto.
(-setStoredProcedure:forOperation:): Ditto.
(-setParentEntity:): Ditto, And add comments
* EOAccess/EORelationship.m (setToMany:): Call -willChange when
modifying the receiver
(-setNumberOfToManyFaultsToBatch:, -setDeleteRule:): Ditto.
(-setInverseRelationship:): Ditto and comment.
(-removeJoin:): Move -willChange call after error handling.
* EOAccess/EOStoredProcedure: Include EOObserving headers.
(-setName:, -setExternalName:, -setArguments:): Call -willChange:
when modifying the receiver.
(-setUserInfo:): Ditto.
2005-02-17 David Ayers <d.ayers@inode.at>
* EOAccess/EOEntity.m: Remove unnecessary include.

View file

@ -782,6 +782,7 @@ RCS_ID("$Id$")
{
[[self validateName: name] raise];
[self willChange];
ASSIGN(_name, name);
if (_flags.isParentAnEOEntity)
{
@ -792,6 +793,7 @@ RCS_ID("$Id$")
- (void)setPrototype: (EOAttribute *)prototype
{
[self willChange];
ASSIGN(_prototype, prototype);
}
@ -857,6 +859,7 @@ return nexexp
{
if(definition)
{
[self willChange];
[self _setDefinitionWithoutFlushingCaches: definition];
[_parent _setIsEdited];
DESTROY(_columnName);//??
@ -872,6 +875,7 @@ return nexexp
NSStringFromClass([self class]),
self];
[self willChange];
_flags.isReadOnly = yn;
}
@ -916,16 +920,19 @@ return nexexp
- (void)setWidth: (unsigned)length
{
[self willChange];
_width = length;
}
- (void)setPrecision: (unsigned)precision
{
[self willChange];
_precision = precision;
}
- (void)setScale: (int)scale
{
[self willChange];
_scale = scale;
}
@ -941,16 +948,19 @@ return nexexp
- (void)setWriteFormat: (NSString *)string
{
[self willChange];
ASSIGN(_writeFormat, string);
}
- (void)setReadFormat: (NSString *)string
{
[self willChange];
ASSIGN(_readFormat, string);
}
- (void)setParameterDirection: (EOParameterDirection)parameterDirection
{
[self willChange];
_parameterDirection = parameterDirection;
}
@ -1051,6 +1061,7 @@ return nexexp
- (void)setServerTimeZone: (NSTimeZone *)tz
{
[self willChange];
ASSIGN(_serverTimeZone, tz);
}
@ -1360,12 +1371,14 @@ return nexexp
- (void)setValueFactoryMethodName: (NSString *)factoryMethodName
{
[self willChange];
ASSIGN(_valueFactoryMethodName, factoryMethodName);
_valueFactoryMethod = NSSelectorFromString(_valueFactoryMethodName);
}
- (void)setAdaptorValueConversionMethodName: (NSString *)conversionMethodName
{
[self willChange];
ASSIGN(_adaptorValueConversionMethodName, conversionMethodName);
_adaptorValueConversionMethod = NSSelectorFromString(_adaptorValueConversionMethodName);
@ -1373,6 +1386,7 @@ return nexexp
- (void)setFactoryMethodArgumentType: (EOFactoryMethodArgumentType)argumentType
{
[self willChange];
_argumentType = argumentType;
}

View file

@ -1929,18 +1929,21 @@ createInstanceWithEditingContext:globalID:zone:
- (void)setRestrictingQualifier: (EOQualifier *)qualifier
{
[self willChange];
ASSIGN(_restrictingQualifier, qualifier);
}
- (void)setReadOnly: (BOOL)flag
{
//OK
[self willChange];
_flags.isReadOnly = flag;
}
- (void)setCachesObjects: (BOOL)flag
{
//OK
[self willChange];
_flags.cachesObjects = flag;
}
@ -1965,6 +1968,7 @@ createInstanceWithEditingContext:globalID:zone:
NSStringFromClass([[attribute parent] class]),
[(EOEntity *)[attribute parent] name]);
[self willChange];
if ([self createsMutableObjects])
[(GCMutableArray *)_attributes addObject: attribute];
else
@ -1985,6 +1989,7 @@ createInstanceWithEditingContext:globalID:zone:
{
if (attribute)
{
[self willChange];
[attribute setParent: nil];
NSEmitTODO(); //TODO
@ -2026,6 +2031,7 @@ createInstanceWithEditingContext:globalID:zone:
self,
relationshipName];
[self willChange];
if ([self createsMutableObjects])
[(GCMutableArray *)_relationships addObject: relationship];
else
@ -2049,6 +2055,7 @@ createInstanceWithEditingContext:globalID:zone:
//TODO
if (relationship)
{
[self willChange];
[relationship setEntity:nil];
if(_relationshipsByName != nil)
@ -2077,6 +2084,7 @@ createInstanceWithEditingContext:globalID:zone:
_fetchSpecificationDictionary = [NSMutableDictionary new];
}
[self willChange];
[_fetchSpecificationDictionary setObject: fetchSpec forKey: name];
ASSIGN(_fetchSpecificationNames, [[_fetchSpecificationDictionary allKeys]
sortedArrayUsingSelector:
@ -2085,6 +2093,7 @@ createInstanceWithEditingContext:globalID:zone:
- (void)removeFetchSpecificationNamed: (NSString *)name
{
[self willChange];
[_fetchSpecificationDictionary removeObjectForKey:name];
ASSIGN(_fetchSpecificationNames, [[_fetchSpecificationDictionary allKeys]
sortedArrayUsingSelector:
@ -2138,6 +2147,7 @@ createInstanceWithEditingContext:globalID:zone:
if (![self isValidClassProperty: [properties objectAtIndex:i]])
return NO;
[self willChange];
DESTROY(_classProperties);
if ([properties isKindOfClass:[GCArray class]]
|| [properties isKindOfClass: [GCMutableArray class]])
@ -2158,6 +2168,7 @@ createInstanceWithEditingContext:globalID:zone:
if (![self isValidPrimaryKeyAttribute: [keys objectAtIndex:i]])
return NO;
[self willChange];
DESTROY(_primaryKeyAttributes);
if ([keys isKindOfClass:[GCArray class]]
@ -2179,6 +2190,7 @@ createInstanceWithEditingContext:globalID:zone:
if (![self isValidAttributeUsedForLocking: [attributes objectAtIndex: i]])
return NO;
[self willChange];
DESTROY(_attributesUsedForLocking);
if ([attributes isKindOfClass: [GCArray class]] // TODO
@ -2268,12 +2280,14 @@ createInstanceWithEditingContext:globalID:zone:
- (void)addSubEntity: (EOEntity *)child
{
[self willChange];
[_subEntities addObject: child];
[child setParentEntity: self];
}
- (void)removeSubEntity: (EOEntity *)child
{
[self willChange];
[child setParentEntity: nil];
[_subEntities removeObject: child];
}
@ -2281,11 +2295,13 @@ createInstanceWithEditingContext:globalID:zone:
- (void)setIsAbstractEntity: (BOOL)flag
{
//OK
[self willChange];
_flags.isAbstractEntity = flag;
}
- (void)setMaxNumberOfInstancesToBatchFetch: (unsigned int)size
{
[self willChange];
_batchCount = size;
}
@ -2404,6 +2420,7 @@ createInstanceWithEditingContext:globalID:zone:
- (void)setStoredProcedure: (EOStoredProcedure *)storedProcedure
forOperation: (NSString *)operation
{
[self willChange];
[_storedProcedures setObject: storedProcedure
forKey: operation];
}
@ -2618,8 +2635,12 @@ createInstanceWithEditingContext:globalID:zone:
_model = model;
}
/* TODO this method should probably be private.
it doesn't tell the parent we are a subEntity and since
-addSubEntity: calls it doing so would cause a recursive loop */
- (void)setParentEntity: (EOEntity *)parent
{
[self willChange]; // TODO: verify
ASSIGN(_parent, parent);
}

View file

@ -1423,6 +1423,7 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
self modelGroup;
//todo if modelgroup;
*/
[self willChange];
ASSIGN(_name, name);
/*
self modelGroup;
@ -1433,11 +1434,13 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
- (void) setAdaptorName: (NSString *)adaptorName
{
[self willChange];
ASSIGN(_adaptorName, adaptorName);
}
- (void) setConnectionDictionary: (NSDictionary *)connectionDictionary
{
[self willChange];
ASSIGN(_connectionDictionary, connectionDictionary);
}
@ -1468,6 +1471,7 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
@"Entity '%@' is already owned by model '%@'.",
[entity name], [[entity model] name]);
[self willChange];
/* Do not access _entities until cache is triggered */
if ([self createsMutableObjects])
[(GCMutableArray *)[self entities] addObject: entity];
@ -1505,6 +1509,7 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
className = [entity className];
NSAssert1(className, @"No className in %@", entity);
[self willChange];
NSMapRemove(_entitiesByClass, className);
/* Do not access _entities until cache is triggered */
@ -1535,6 +1540,7 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
self,
[storedProcedure name]];
NSAssert(_storedProcedures, @"Uninitialised _storedProcedures!");
[self willChange];
if ([self createsMutableObjects])
[(GCMutableArray *)_storedProcedures addObject: storedProcedure];
else
@ -1551,6 +1557,7 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
{
NSAssert(_storedProcedures, @"Uninitialised _storedProcedures!");
[self willChange];
if ([self createsMutableObjects])
[(GCMutableArray *)_storedProcedures removeObject: storedProcedure];
else

View file

@ -1288,6 +1288,7 @@ relationships. Nil if none" **/
NSStringFromClass([self class]),
self];
[self willChange];
_flags.isToMany = flag;
}
@ -1587,7 +1588,6 @@ relationships. Nil if none" **/
EOFLOGObjectFnStart();
[self _flushCache];
[self willChange];
if ([self isFlattened] == YES)
[NSException raise: NSInvalidArgumentException
@ -1597,6 +1597,7 @@ relationships. Nil if none" **/
self];
else
{
[self willChange];
if ([self createsMutableObjects])
{
[(GCMutableArray *)_joins removeObject: join];
@ -1698,6 +1699,7 @@ becomes "name", and "FIRST_NAME" becomes "firstName".*/
- (void)setNumberOfToManyFaultsToBatchFetch: (unsigned int)size
{
[self willChange];
_batchCount = size;
}
@ -1707,6 +1709,7 @@ becomes "name", and "FIRST_NAME" becomes "firstName".*/
@"Bad deleteRule numeric value: %d",
deleteRule);
[self willChange];
_flags.deleteRule = deleteRule;
}
@ -1821,8 +1824,10 @@ becomes "name", and "FIRST_NAME" becomes "firstName".*/
return _flags.createsMutableObjects;
}
/* TODO this method should probably be private. */
- (void)setInverseRelationship: (EORelationship*)relationship
{
[self willChange]; // TODO: verify
ASSIGN(_inverseRelationship,relationship);
}

View file

@ -50,6 +50,7 @@ RCS_ID("$Id$")
#include <GNUstepBase/GCObject.h>
#include <EOControl/EODebug.h>
#include <EOControl/EOObserver.h>
#include <EOAccess/EOStoredProcedure.h>
#include <EOAccess/EOAttribute.h>
@ -222,16 +223,19 @@ RCS_ID("$Id$")
- (void)setName: (NSString *)name
{
[self willChange];
ASSIGN(_name, name);
}
- (void)setExternalName: (NSString *)name
{
[self willChange];
ASSIGN(_externalName, name);
}
- (void)setArguments: (NSArray *)arguments
{
[self willChange];
if ([arguments isKindOfClass: [GCArray class]]
|| [arguments isKindOfClass: [GCMutableArray class]])
ASSIGN(_arguments, arguments);
@ -241,6 +245,7 @@ RCS_ID("$Id$")
- (void)setUserInfo: (NSDictionary *)dictionary
{
[self willChange];
ASSIGN(_userInfo, dictionary);
}