mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-02-21 18:40:51 +00:00
* EOAccess/EOModel.m (-dealloc): Set entities model to nil.
* EOAccess/EOEntityPriv.h: Add functions for maintining list of relationships and their destination entities. * EOAccess/EOEntity.m: Implement new functions. (-dealloc:): Set attributes entities, and relationships source and destinations entities to nil. (+initialize:): Initialize static map table. * EOAccess/EORelationship.m: Call functions to maintain destination entities. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@23954 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a1605b6f72
commit
9e08693c96
5 changed files with 81 additions and 2 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,6 +1,16 @@
|
||||||
2006-10-23 Matt Rice <ratmice@yahoo.com>
|
2006-10-23 Matt Rice <ratmice@yahoo.com>
|
||||||
|
|
||||||
* EOAccess: Revert previous changes.
|
* EOAccess: Revert previous changes.
|
||||||
|
|
||||||
|
* EOAccess/EOModel.m (-dealloc): Set entities model to nil.
|
||||||
|
* EOAccess/EOEntityPriv.h: Add functions for maintining list of
|
||||||
|
relationships and their destination entities.
|
||||||
|
* EOAccess/EOEntity.m: Implement new functions.
|
||||||
|
(-dealloc:): Set attributes entities, and relationships source and
|
||||||
|
destinations entities to nil.
|
||||||
|
(+initialize:): Initialize static map table.
|
||||||
|
* EOAccess/EORelationship.m: Call functions to maintain destination
|
||||||
|
entities.
|
||||||
|
|
||||||
2006-10-22 Matt Rice <ratmice@yahoo.com>
|
2006-10-22 Matt Rice <ratmice@yahoo.com>
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,57 @@ RCS_ID("$Id$")
|
||||||
#include "EOPrivate.h"
|
#include "EOPrivate.h"
|
||||||
#include "EOEntityPriv.h"
|
#include "EOEntityPriv.h"
|
||||||
#include "EOAttributePriv.h"
|
#include "EOAttributePriv.h"
|
||||||
|
#include "../EOControl/EOPrivate.h"
|
||||||
|
|
||||||
|
static NSMapTable *_destinationEntitiesRelationshipMap;
|
||||||
|
|
||||||
|
void GDL2DestinationEntitiesAddRelationship(EOEntity *entity, EORelationship *relationship);
|
||||||
|
void GDL2DestinationEntitiesRemoveRelationship(EOEntity *entity, EORelationship *relationship);
|
||||||
|
|
||||||
|
static void GDL2DestinationEntitiesRemoveEntity(EOEntity *entity)
|
||||||
|
{
|
||||||
|
GDL2NonRetainingMutableArray *rels;
|
||||||
|
|
||||||
|
rels = NSMapGet(_destinationEntitiesRelationshipMap, entity);
|
||||||
|
if (rels)
|
||||||
|
{
|
||||||
|
[rels makeObjectsPerformSelector:@selector(_joinsChanged)];
|
||||||
|
}
|
||||||
|
NSMapRemove(_destinationEntitiesRelationshipMap, entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GDL2DestinationEntitiesAddRelationship(EOEntity *entity, EORelationship *relationship)
|
||||||
|
{
|
||||||
|
GDL2NonRetainingMutableArray *rels;
|
||||||
|
|
||||||
|
if (!entity) return;
|
||||||
|
|
||||||
|
rels = NSMapGet(_destinationEntitiesRelationshipMap, entity);
|
||||||
|
if (!rels)
|
||||||
|
{
|
||||||
|
rels = [[GDL2NonRetainingMutableArray alloc] init];
|
||||||
|
NSMapInsert(_destinationEntitiesRelationshipMap, entity, rels);
|
||||||
|
RELEASE(rels);
|
||||||
|
}
|
||||||
|
[rels addObject:relationship];
|
||||||
|
}
|
||||||
|
|
||||||
|
void GDL2DestinationEntitiesRemoveRelationship(EOEntity *entity, EORelationship *relationship)
|
||||||
|
{
|
||||||
|
GDL2NonRetainingMutableArray *rels;
|
||||||
|
|
||||||
|
if (!entity) return;
|
||||||
|
|
||||||
|
rels = NSMapGet(_destinationEntitiesRelationshipMap, entity);
|
||||||
|
|
||||||
|
[rels removeObject:relationship];
|
||||||
|
if ([rels count] == 0)
|
||||||
|
{
|
||||||
|
NSMapRemove(_destinationEntitiesRelationshipMap, entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@interface EOModel (Privat)
|
@interface EOModel (Privat)
|
||||||
- (void)_updateCache;
|
- (void)_updateCache;
|
||||||
|
@ -106,7 +157,9 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
{
|
{
|
||||||
initialized=YES;
|
initialized=YES;
|
||||||
|
_destinationEntitiesRelationshipMap =
|
||||||
|
NSCreateMapTable(NSNonRetainedObjectMapKeyCallBacks,
|
||||||
|
NSObjectMapValueCallBacks, 0);
|
||||||
GDL2_EOAccessPrivateInit();
|
GDL2_EOAccessPrivateInit();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -521,6 +574,13 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
|
[_attributes makeObjectsPerform:@selector(setParent:) withObject:nil];
|
||||||
|
[_relationships makeObjectsPerform:@selector(setEntity:) withObject:nil];
|
||||||
|
// this must come after _attributes is cleared.
|
||||||
|
GDL2DestinationEntitiesRemoveEntity(self);
|
||||||
|
|
||||||
|
DESTROY(_relationshipsByName);
|
||||||
|
DESTROY(_relationships);
|
||||||
DESTROY(_attributes);
|
DESTROY(_attributes);
|
||||||
DESTROY(_name);
|
DESTROY(_name);
|
||||||
DESTROY(_className);
|
DESTROY(_className);
|
||||||
|
|
|
@ -34,6 +34,8 @@
|
||||||
@class EOExpressionArray;
|
@class EOExpressionArray;
|
||||||
@class EOSQLExpression;
|
@class EOSQLExpression;
|
||||||
|
|
||||||
|
GDL2ACCESS_EXPORT void GDL2DestinationEntitiesAddRelationship(EOEntity *entity, EORelationship *relationship);
|
||||||
|
GDL2ACCESS_EXPORT void GDL2DestinationEntitiesRemoveRelationship(EOEntity *entity, EORelationship *relationship);
|
||||||
|
|
||||||
@interface EOEntity (EOEntityPrivate)
|
@interface EOEntity (EOEntityPrivate)
|
||||||
|
|
||||||
|
|
|
@ -248,7 +248,8 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||||
|
[[self entities] makeObjectsPerformSelector:@selector(_setModel:)
|
||||||
|
withObject:nil];
|
||||||
if (_entitiesByClass)
|
if (_entitiesByClass)
|
||||||
{
|
{
|
||||||
NSFreeMapTable(_entitiesByClass);
|
NSFreeMapTable(_entitiesByClass);
|
||||||
|
|
|
@ -154,6 +154,9 @@ RCS_ID("$Id$")
|
||||||
if (destinationEntityName) //If not, this is because it's a definition
|
if (destinationEntityName) //If not, this is because it's a definition
|
||||||
{
|
{
|
||||||
destinationEntity = [model entityNamed: destinationEntityName];
|
destinationEntity = [model entityNamed: destinationEntityName];
|
||||||
|
|
||||||
|
GDL2DestinationEntitiesRemoveRelationship(_destination, self);
|
||||||
|
GDL2DestinationEntitiesAddRelationship(destinationEntity, self);
|
||||||
_destination = destinationEntity;
|
_destination = destinationEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1264,6 +1267,7 @@ relationships. Nil if none" **/
|
||||||
EOFLOGObjectLevelArgs(@"EORelationship", @"_definitionArray=%@", _definitionArray);
|
EOFLOGObjectLevelArgs(@"EORelationship", @"_definitionArray=%@", _definitionArray);
|
||||||
EOFLOGObjectLevelArgs(@"EORelationship", @"[self definition]=%@", [self definition]);
|
EOFLOGObjectLevelArgs(@"EORelationship", @"[self definition]=%@", [self definition]);
|
||||||
|
|
||||||
|
GDL2DestinationEntitiesRemoveRelationship(_destination, self);
|
||||||
_destination = nil;
|
_destination = nil;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -2370,6 +2374,8 @@ dst entity primaryKeyAttributeNames
|
||||||
EOAttribute *destinationAttribute = [join destinationAttribute];
|
EOAttribute *destinationAttribute = [join destinationAttribute];
|
||||||
EOEntity *destinationEntity = [destinationAttribute entity];
|
EOEntity *destinationEntity = [destinationAttribute entity];
|
||||||
|
|
||||||
|
GDL2DestinationEntitiesRemoveRelationship(_destination, self);
|
||||||
|
GDL2DestinationEntitiesAddRelationship(destinationEntity, self);
|
||||||
_destination = destinationEntity;
|
_destination = destinationEntity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue