MCPClassDescription


Inherits From:
NSObject
Declared In:
MCPClassDescription.h


Class Description

$Id: MCPConnection.m,v 1.4 2004/05/14 11:16:04 sergecohen Exp $ $Author: $

This Class is used in conjunction with MCPObject to get a object/relational layer on top of SMySQL. The class description is responsible for handling all the mapping information: like which table correspond to which class, and within a class which attribute correspond to which column.

It is important to realise that an object of the class MCPClassDescription will instantiated for each CLASS (and not object) of super class MCPObject.

More details now : This class will handle the following informations: -# The Class name. -className- -# The Table name. -externalName- -# An array of all the attributes (object of class MCPAttribute). -attributes- -# An array of attributes (MCPAttribute) defining the identity of the row/object. -identityAttributes- (just the name of the attributes) -# An array of attributes (MCPAttribute) defining the primary key of the row/object. -primaryKeyAttributes- (just the name of the attributes) -# A flag, telling if the primary key is a single auto-generated integer. Generated from the gathered information. -# Finally an array of RelationShips (to other objects) NOT IMPLEMENTERD YET! -relationships-

All this information is saved in a plist in the bundle of the MCPObject subclass. This plist is parsed at runtime and used to generate the MCPClassDescription for each subclass of MCPObject.

Note that the flag for autogenerated integer primary key is inferred at runtime from the information of the primary key and autogenerated information.


Instance Variables

NSString *className;
NSString *externalName;
NSArray *attributes;
NSArray *relationships;
NSArray *primaryKeyAttributes;
NSArray *identityAttributes;
BOOL singleAutoGenKey;

classNameNo description.
externalNameNo description.
attributesNo description.
relationshipsNo description.
primaryKeyAttributesNo description.
identityAttributesNo description.
singleAutoGenKeyNo description.


Method Types

Initing the MCPDescription class :
- initForClass:
- dealloc
Overriding the necessary function from NSClassDescription.
- attributeKeys
- inverseRelationshipKey:
- toManyRelationshipKeys
- toOneRelationshipKeys
Specifics to MCPClassDescription :
- attributes
- primaryKeyAttributes
- identityAttributes
- identityAttributes
- className
- externalName
- attributeWithName:
- singleAutoGenKey
Output for logging... :
- description

Instance Methods

attributeKeys

- (NSArray *)attributeKeys

No method description.


attributeWithName:

- (MCPAttribute *)attributeWithName:(NSString *)iName

Return the MCPAttribute description of the attribute, given the attribute name (object side, not externalName). If no attributes are named iName, it will return nil.


attributes

- (NSArray *)attributes

Returns the array of MCPAttribute for the class (not only attribute names).


className

- (NSString *)className

Returns the name of the class it describe.


dealloc

- (void)dealloc

release the instance variable of the description.


description

- (NSString *)description

Used for logging and debugging


externalName

- (NSString *)externalName

Return the name of the table used to store the information of the object.


identityAttributes

- (NSArray *)identityAttributes

No method description.


identityAttributes

- (NSArray *)identityAttributes

Returns an array of MCPAttributes that should be used to check for 'identity' between two objects. Typically these can be used to check if a given entry is already in the DB and then avoid inserting it again.


initForClass:

- (id)initForClass:(Class)aClass

Generate a class description for the class aClass.

It will use the bundle of the class to try to find a plist named : className.plist in the resource. This plist should contains the information required by the MCPClassDescription... see class description.


inverseRelationshipKey:

- (NSString *)inverseRelationshipKey:(NSString *)relationshipKey

No method description.


primaryKeyAttributes

- (NSArray *)primaryKeyAttributes

Returns an array containing the attribute(s) name constituting the primary key (NSArray of MCPAttributes).


singleAutoGenKey

- (BOOL)singleAutoGenKey

No method description.


toManyRelationshipKeys

- (NSArray *)toManyRelationshipKeys

See the NSClassDescription reference for details on this message.


toOneRelationshipKeys

- (NSArray *)toOneRelationshipKeys

See the NSClassDescription reference for details on this message.


Version 1.4 Copyright ©2004 by Serge Cohen. All Rights Reserved. Mon Aug 09 11:00:28 2004