- Inherits From:
- NSObject
- Declared In:
- MCPClassDescription.h
$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.
NSString *className;
NSString *externalName;
NSArray *attributes;
NSArray *relationships;
NSArray *primaryKeyAttributes;
NSArray *identityAttributes;
BOOL singleAutoGenKey;
className No description. externalName No description. attributes No description. relationships No description. primaryKeyAttributes No description. identityAttributes No description. singleAutoGenKey No description.
Initing the MCPDescription class :Overriding the necessary function from NSClassDescription.
- - initForClass:
- - dealloc
Specifics to MCPClassDescription :
- - attributeKeys
- - inverseRelationshipKey:
- - toManyRelationshipKeys
- - toOneRelationshipKeys
Output for logging... :
- - attributes
- - primaryKeyAttributes
- - identityAttributes
- - identityAttributes
- - className
- - externalName
- - attributeWithName:
- - singleAutoGenKey
- - description
- (NSArray *)attributeKeys
No method description.
- (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.
- (NSArray *)attributes
Returns the array of MCPAttribute for the class (not only attribute names).
- (NSString *)className
Returns the name of the class it describe.
- (void)dealloc
release the instance variable of the description.
- (NSString *)description
Used for logging and debugging
- (NSString *)externalName
Return the name of the table used to store the information of the object.
- (NSArray *)identityAttributes
No method description.
- (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.
- (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.
- (NSString *)inverseRelationshipKey:(NSString *)relationshipKey
No method description.
- (NSArray *)primaryKeyAttributes
Returns an array containing the attribute(s) name constituting the primary key (NSArray of MCPAttributes).
- (BOOL)singleAutoGenKey
No method description.
- (NSArray *)toManyRelationshipKeys
See the NSClassDescription reference for details on this message.
- (NSArray *)toOneRelationshipKeys
See the NSClassDescription reference for details on this message.