aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/MCPKit/MCPEntrepriseKit/MCPAttribute.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2012-03-17 15:32:00 +0000
committerrowanbeentje <rowan@beent.je>2012-03-17 15:32:00 +0000
commitac8ebfe4bba6d7da6edad87c75b174156d919621 (patch)
tree08a3c2843d3c520090f40e6341b26043a7ccf014 /Frameworks/MCPKit/MCPEntrepriseKit/MCPAttribute.m
parent8886d935e933c6239aa9b35e900d96f7d07527c7 (diff)
parenteab6df4de773259f90dd5a1d25e44ca4d2765bbf (diff)
downloadsequelpro-ac8ebfe4bba6d7da6edad87c75b174156d919621.tar.gz
sequelpro-ac8ebfe4bba6d7da6edad87c75b174156d919621.tar.bz2
sequelpro-ac8ebfe4bba6d7da6edad87c75b174156d919621.zip
Merge in the SPMySQL Framework. This new framework should provide much of the functionality required from MCPKit and is based around its interface for relatively easy integration.
Externally visible changes as a result of this merge: - Speed improvements, particularly when loading large data sets - Stability improvements, particularly related to connection state after the connection is dropped (eg Issue #1256) - Improved support for new MySQL data types, which should address Issue #1052. - Database structure retrieval and query cancellation now use a single persistent helper connection instead of lots of connections on-demand. This should help Issue #1097. - More internal commands now use queries instead of MySQL functions; for example USE queries are now used to trigger database selection, improving transcripts. This addresses Issue #1247. - Improved internal encoding work; while this needs support within the UI, it lays the foundation for issues like Issue #1280. Code improvements: - Much improved class layouts including extensive category usage - Improved documentation across framework methods - Support for fast enumeration across result objects - Rewrite fixes use of a number of deprecate functions - Much less code duplication across result set types - Improved encapsultation within the framework, limiting the number of methods exposed, and also not exposing all the MySQL headers From the Readme file: The SPMySQL Framework is intended to provide a stable MySQL connection framework, with the ability to run text-based queries and rapidly retrieve result sets with conversion from MySQL data types to Cocoa objects. SPMySQL.framework has an interface loosely based around that provided by MCPKit by Serge Cohen and Bertrand Mansion (http://mysql-cocoa.sourceforge.net/), and in particular the heavily modified Sequel Pro version (http://www.sequelpro.com/). It is a full rewrite of the original framework, although it includes code from patches implementing the following Sequel Pro functionality, largely contributed by Hans-Jörg Bibiko, Stuart Connolly, Jakob Egger, and Rowan Beentje: - Connection locking (Jakob et al) - Ping & keepalive (Rowan et al) - Query cancellation (Rowan et al) - Delegate setup (Stuart et al) - SSL support (Rowan et al) - Connection checking (Rowan et al) - Version state (Stuart et al) - Maximum packet size control (Hans et al) - Result multithreading and streaming (Rowan et al) - Improved encoding support & switching (Rowan et al) - Database structure; moved to inside the app (Hans et al) - Query reattempts and error-handling approach (Rowan et al) - Geometry result class (Hans et al) - Connection proxy (Stuart et al)
Diffstat (limited to 'Frameworks/MCPKit/MCPEntrepriseKit/MCPAttribute.m')
-rw-r--r--Frameworks/MCPKit/MCPEntrepriseKit/MCPAttribute.m466
1 files changed, 0 insertions, 466 deletions
diff --git a/Frameworks/MCPKit/MCPEntrepriseKit/MCPAttribute.m b/Frameworks/MCPKit/MCPEntrepriseKit/MCPAttribute.m
deleted file mode 100644
index 085c1114..00000000
--- a/Frameworks/MCPKit/MCPEntrepriseKit/MCPAttribute.m
+++ /dev/null
@@ -1,466 +0,0 @@
-//
-// $Id$
-//
-// MCPAttribute.m
-// MCPkit
-//
-// Created by Serge Cohen (serge.cohen@m4x.org) on 09/08/04.
-// Copyright (c) 2004 Serge Cohen. All rights reserved.
-//
-// Forked by the Sequel Pro team (sequelpro.com), April 2009
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// More info at <http://mysql-cocoa.sourceforge.net/>
-// More info at <http://code.google.com/p/sequel-pro/>
-
-#import "MCPAttribute.h"
-
-#import "MCPEntrepriseNotifications.h"
-
-#import "MCPModel.h"
-#import "MCPClassDescription.h"
-#import "MCPRelation.h"
-#import "MCPJoin.h"
-
-static NSArray *MCPRecognisedInternalType;
-
-@interface MCPAttribute (Private)
-
-- (void)setValueClassName:(NSString *) iClassName;
-
-@end
-
-@implementation MCPAttribute
-
-#pragma mark Class methods
-+ (void) initialize
-{
- if (self == [MCPAttribute class]) {
- [self setVersion:010101]; // Ma.Mi.Re -> MaMiRe
- MCPRecognisedInternalType = [[NSArray alloc] initWithObjects:@"NSCalendarDate", @"NSData", @"NSNumber", @"NSString", nil];
- [self setKeys:[NSArray arrayWithObject:@"internalType"] triggerChangeNotificationsForDependentKey:@"valueClassName"];
- [self setKeys:[NSArray arrayWithObject:@"valueClassName"] triggerChangeNotificationsForDependentKey:@"internalType"];
- }
- return;
-}
-
-
-#pragma mark Life cycle
-- (id) initForClassDescription:(MCPClassDescription *) iClassDescription withName:(NSString *) iName
-{
- self = [super init];
- {
- classDescription = iClassDescription;
- [self setName:iName];
-// relations = (NSMutableArray *)(CFArrayCreateMutable (kCFAllocatorDefault, 0, NULL));
- joins = [[NSMutableArray alloc] init];
- }
- return self;
-}
-
-- (void) dealloc
-{
-// NSArray *theRelations;
-// unsigned int i;
-
- [name release];
- [internalType release];
- [externalName release];
- [externalType release];
- [defaultValue release];
-/*
- while ([relations count]) {
- [(MCPRelation *)[relations objectAtIndex:0] unjoinAttribute:self];
- }
-// By now relation should be empty anyway...
- [relations release];
- */
- while ([joins count]) {
- [[self objectInJoinsAtIndex:0] invalidate];
- }
- // By now the joins array should be empty
- [joins release];
- [super dealloc];
-}
-
-
-#pragma mark NSCoding protocol
-- (id) initWithCoder:(NSCoder *) decoder
-{
- self = [super init];
- if ((self) && ([decoder allowsKeyedCoding])) {
- NSString *theClassName = [decoder decodeObjectForKey:@"MCPvalueClassName"];
-
- classDescription = [decoder decodeObjectForKey:@"MCPclassDescription"];
- [self setName:[decoder decodeObjectForKey:@"MCPname"]];
- if (theClassName) {
- [self setValueClass:NSClassFromString(theClassName)];
- }
- [self setInternalType:[decoder decodeObjectForKey:@"MCPinternalType"]];
- [self setExternalName:[decoder decodeObjectForKey:@"MCPexternalName"]];
- [self setExternalType:[decoder decodeObjectForKey:@"MCPexternalType"]];
- [self setWidth:(NSUInteger)[decoder decodeInt32ForKey:@"MCPwidth"]];
- [self setAllowsNull:[decoder decodeBoolForKey:@"MCPallowsNull"]];
- [self setAutoGenerated:[decoder decodeBoolForKey:@"MCPautoGenerated"]];
- [self setIsPartOfKey:[decoder decodeBoolForKey:@"MCPisPartOfKey"]];
- [self setIsPartOfIdentity:[decoder decodeBoolForKey:@"MCPisPartOfIdentity"]];
- [self setHasAccessor:[decoder decodeBoolForKey:@"MCPhasAccessor"]];
- [self setDefaultValue:[decoder decodeObjectForKey:@"MCPdefaultValue"]];
-// Not sure that the next line is working (getting an array holding weak references), hence doing the thing expelcitly:
-// relations = [[decoder decodeObjectForKey:@"MCPrelations"] retain];
-// relations = (NSMutableArray *)(CFArrayCreateMutable (kCFAllocatorDefault, 0, NULL));
-// [relations addObjectsFromArray:[decoder decodeObjectForKey:@"MCPrelations"]];
- joins = [[NSMutableArray alloc] init]; // Will be filled in when the relations are read in.
- }
- else {
- NSLog(@"For some reason, unable to decode MCPAttribute from the coder!!!");
- }
-// NSLog(@"MAKING a new object : %@", self);
- return self;
-}
-
-- (void) encodeWithCoder:(NSCoder *) encoder
-{
- NSString *theValueClassName;
-
- if (! [encoder allowsKeyedCoding]) {
- NSLog(@"In MCPAttribute -encodeWithCoder : Unable to encode to a non-keyed encoder!!, will not perform encoding!!");
- return;
- }
-// theValueClassName = (valueClass) ? [valueClass className] : nil;
- theValueClassName = (valueClass) ? NSStringFromClass(valueClass) : nil;
- [encoder encodeObject:[self classDescription] forKey:@"MCPclassDescription"];
- [encoder encodeObject:[self name] forKey:@"MCPname"];
- if (theValueClassName) {
- [encoder encodeObject:theValueClassName forKey:@"MCPvalueClassName"];
- }
- [encoder encodeObject:[self internalType] forKey:@"MCPinternalType"];
- [encoder encodeObject:[self externalName] forKey:@"MCPexternalName"];
- [encoder encodeObject:[self externalType] forKey:@"MCPexternalType"];
- [encoder encodeInt32:(int32_t)[self width] forKey:@"MCPwidth"];
- [encoder encodeBool:[self allowsNull] forKey:@"MCPallowsNull"];
- [encoder encodeBool:[self autoGenerated] forKey:@"MCPautoGenerated"];
- [encoder encodeBool:[self isPartOfKey] forKey:@"MCPisPartOfKey"];
- [encoder encodeBool:[self isPartOfIdentity] forKey:@"MCPisPartOfIdentity"];
- [encoder encodeBool:[self hasAccessor] forKey:@"MCPhasAccessor"];
- [encoder encodeObject:[self defaultValue] forKey:@"MCPdefaultValue"];
-// [encoder encodeObject:relations forKey:@"MCPrelation"];
- // We don't have to save the joins here ... the joins are saving there attributes.
- // The links are recreated when the joins are decoded.
-}
-
-#pragma mark Setters
-- (void) setName:(NSString *) iName
-{
- if (iName != name) {
- [name release];
- name = [iName retain];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPModelChangedNotification object:[classDescription model]];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPClassDescriptionChangedNotification object:classDescription];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPAttributeChangedNotification object:self];
- }
-}
-
-- (void) setValueClass:(Class) iValueClass
-{
- if (iValueClass != valueClass) {
- valueClass = iValueClass;
- if (valueClass) { // Not nil : set the internalType accrodingly.
- // [internalType release];
- // internalType = [[valueClass className] copy];
-// [self setValue:[NSString stringWithString:[valueClass className]] forKey:@"internalType"];
- [self setValue:[NSString stringWithString:NSStringFromClass(valueClass)] forKey:@"internalType"];
- }
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPModelChangedNotification object:[classDescription model]];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPClassDescriptionChangedNotification object:classDescription];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPAttributeChangedNotification object:self];
- }
-}
-
-- (void) setInternalType:(NSString *) iInternalType
-{
- if (iInternalType != internalType) {
- [internalType release];
- internalType = [iInternalType retain];
- if ([MCPRecognisedInternalType containsObject:internalType]) {
- [self setValueClass:NSClassFromString(internalType)];
-// By itself does NOT provide observers the update.
-// but see setKeys:triggerChangeNotificationsForDependentKey... (in +initialize).
- }
- else {
- [self setValueClass:nil];
- }
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPModelChangedNotification object:[classDescription model]];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPClassDescriptionChangedNotification object:classDescription];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPAttributeChangedNotification object:self];
- }
-}
-
-- (void) setExternalType:(NSString *) iExternalType
-{
- if (iExternalType != externalType) {
- [externalType release];
- externalType = [iExternalType retain];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPModelChangedNotification object:[classDescription model]];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPClassDescriptionChangedNotification object:classDescription];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPAttributeChangedNotification object:self];
- }
-}
-
-- (void) setExternalName:(NSString *) iExternalName
-{
- if (iExternalName != externalName) {
- [externalName release];
- externalName = [iExternalName retain];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPModelChangedNotification object:[classDescription model]];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPClassDescriptionChangedNotification object:classDescription];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPAttributeChangedNotification object:self];
- }
-}
-
-- (void) setWidth:(NSUInteger) iWidth
-{
- if (iWidth != width) {
- width = iWidth;
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPModelChangedNotification object:[classDescription model]];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPClassDescriptionChangedNotification object:classDescription];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPAttributeChangedNotification object:self];
- }
-}
-
-- (void) setAllowsNull:(BOOL) iAllowsNull
-{
- if (iAllowsNull != allowsNull) {
- allowsNull = iAllowsNull;
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPModelChangedNotification object:[classDescription model]];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPClassDescriptionChangedNotification object:classDescription];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPAttributeChangedNotification object:self];
- }
-}
-
-- (void) setAutoGenerated:(BOOL) iAutoGenerated
-{
- if (iAutoGenerated != autoGenerated) {
- autoGenerated = iAutoGenerated;
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPModelChangedNotification object:[classDescription model]];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPClassDescriptionChangedNotification object:classDescription];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPAttributeChangedNotification object:self];
- }
-}
-
-- (void) setIsPartOfKey:(BOOL) iIsPartOfKey
-{
- if (iIsPartOfKey != isPartOfKey) {
- isPartOfKey = iIsPartOfKey;
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPModelChangedNotification object:[classDescription model]];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPClassDescriptionChangedNotification object:classDescription];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPAttributeChangedNotification object:self];
- }
-}
-
-- (void) setIsPartOfIdentity:(BOOL) iIsPartOfIdentity
-{
- if (iIsPartOfIdentity != isPartOfIdentity) {
- isPartOfIdentity = iIsPartOfIdentity;
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPModelChangedNotification object:[classDescription model]];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPClassDescriptionChangedNotification object:classDescription];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPAttributeChangedNotification object:self];
- }
-}
-
-- (void) setHasAccessor:(BOOL) iHasAccessor
-{
- if (iHasAccessor != hasAccessor) {
- hasAccessor = iHasAccessor;
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPModelChangedNotification object:[classDescription model]];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPClassDescriptionChangedNotification object:classDescription];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPAttributeChangedNotification object:self];
- }
-}
-
-- (void) setDefaultValue:(id) iDefaultValue
-{
- if (iDefaultValue != defaultValue) {
- [defaultValue release];
- defaultValue = [iDefaultValue retain];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPModelChangedNotification object:[classDescription model]];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPClassDescriptionChangedNotification object:classDescription];
- [[NSNotificationCenter defaultCenter] postNotificationName:MCPAttributeChangedNotification object:self];
- }
-}
-
-- (void) insertObject:(MCPJoin *) iJoin inJoinsAtIndex:(NSUInteger) index
-{
- [joins insertObject:iJoin atIndex:index];
-}
-
-- (void) removeObjectFromJoinsAtIndex:(NSUInteger) index
-{
- [joins removeObjectAtIndex:index];
-}
-
-/*
-- (void) addRelation:(MCPRelation *) iRelation
-{
-// Following implementation make sure that a given relation is only added once... but I don't see the reason for that to be true.
- /* if (NSNotFound == [relations indexOfObjectIdenticalTo:iRelation]) {
- [relations addObject:iRelation];
- }
- *//*
- [relations addObject:iRelation];
-}
-
-- (void) removeRelation:(MCPRelation *) iRelation
-{
-// Following implementation needs only one reference to a given relation to be working properly (not true)
-// [relations removeObjectIdenticalTo:iRelation];
- unsigned int i;
-
- i = [relations indexOfObjectIdenticalTo:iRelation];
- if (NSNotFound != i) {
- [relations removeObjectAtIndex:i];
- }
-// If the relation is there more than once, remove it only once.
-}
-*/
-
-#pragma mark Getters
-- (MCPClassDescription *) classDescription
-{
- return classDescription;
-}
-
-- (NSString *) name
-{
- return name;
-}
-
-- (Class) valueClass
-{
- return valueClass;
-}
-
-- (NSString *) valueClassName
-{
- return NSStringFromClass(valueClass);
-}
-
-- (NSString *) internalType
-{
- return internalType;
-}
-
-- (NSString *) externalName
-{
- return externalName;
-}
-
-- (NSString *) externalType
-{
- return externalType;
-}
-
-- (NSUInteger) width
-{
- return width;
-}
-
-- (BOOL) allowsNull
-{
- return allowsNull;
-}
-
-- (BOOL) autoGenerated
-{
- return autoGenerated;
-}
-
-- (BOOL) isPartOfKey
-{
- return isPartOfKey;
-}
-
-- (BOOL) isPartOfIdentity
-{
- return isPartOfIdentity;
-}
-
-- (BOOL) hasAccessor
-{
- return hasAccessor;
-}
-
-- (id) defaultValue
-{
- return defaultValue;
-}
-
-- (NSUInteger) countOfJoins
-{
- return [joins count];
-}
-
-- (MCPJoin *) objectInJoinsAtIndex:(NSUInteger) index
-{
- return (MCPJoin *)((NSNotFound != index) ? [joins objectAtIndex:index] : nil);
-}
-
-- (NSUInteger) indexOfJoinIdenticalTo:(id) iJoin
-{
- return [joins indexOfObjectIdenticalTo:iJoin];
-}
-
-#pragma mark Some general methods:
-- (BOOL) isEqual:(id) iObject
-// Equal to another attribute, if they have the same name and same class description.
-// Equal to a string (NSString), if the name of the attribute is equal to the string.
-{
- if ([iObject isKindOfClass:[MCPAttribute class]]) {
- MCPAttribute *theAttribute = (MCPAttribute *) iObject;
-
- return ([name isEqualToString:[theAttribute name]]) && ([classDescription isEqual:[theAttribute classDescription]]);
- }
- if ([iObject isKindOfClass:[NSString class]]) {
- return [name isEqualToString:(NSString *)iObject];
- }
- return NO;
-}
-
-#pragma mark For debugging the retain counting
-- (id) retain
-{
- [super retain];
- return self;
-}
-
-- (void) release
-{
- [super release];
- return;
-}
-
-@end
-
-@implementation MCPAttribute (Private)
-
-- (void)setValueClassName:(NSString *) iClassName
-{
- if (NSClassFromString(iClassName) != valueClass) {
- [self setValueClass:NSClassFromString(iClassName)];
- }
-}
-
-@end