Permalink
Browse files

Moved to my own contributed templates folder, fixed transient check, …

…NSCoding support

Created a new subfolder in contributed templates to hold my Set-based
templates, added a missing transient check in all machine.m templates,
added yet another variant of the templates which is Set-based with
NSCoding support.
  • Loading branch information...
1 parent 5508a79 commit 018017be2c1ca34d79ef391d7b41c93292bf2c87 @tyrone-sudeium committed Nov 28, 2011
Showing with 4,091 additions and 290 deletions.
  1. +1 −1 contributed templates/Nikita Zhuk/ponso/code/ModelObject.h
  2. +16 −0 contributed templates/Nikita Zhuk/ponso/code/ModelObject.m
  3. +2 −1 contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/PonsoTest.xcodeproj/project.pbxproj
  4. +0 −1 contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/Model.h
  5. +11 −3 contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelAssistant.h
  6. +101 −41 contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelAssistant.m
  7. +15 −7 contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelCompany.h
  8. +109 −66 contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelCompany.m
  9. +13 −5 ...ributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartment.h
  10. +105 −58 ...ributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartment.m
  11. +7 −1 ...emplates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentAssistant.h
  12. +72 −27 ...emplates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentAssistant.m
  13. +7 −1 ...templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentEmployee.h
  14. +72 −27 ...templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentEmployee.m
  15. +11 −3 contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelEmployee.h
  16. +106 −42 contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelEmployee.m
  17. +2 −2 contributed templates/Nikita Zhuk/ponso/templates/machine.m.motemplate
  18. +45 −0 contributed templates/Tyrone Trevorrow/ponso/README.txt
  19. +58 −0 contributed templates/Tyrone Trevorrow/ponso/code/ModelObject.h
  20. +175 −0 contributed templates/Tyrone Trevorrow/ponso/code/ModelObject.m
  21. +8 −0 ... templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/MyModel.xcdatamodeld/.xccurrentversion
  22. BIN ...Tyrone Trevorrow/ponso/sample project/PonsoTest/MyModel.xcdatamodeld/MyModel.xcdatamodel/elements
  23. BIN ...s/Tyrone Trevorrow/ponso/sample project/PonsoTest/MyModel.xcdatamodeld/MyModel.xcdatamodel/layout
  24. +345 −0 ...ted templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/PonsoTest.xcodeproj/project.pbxproj
  25. +7 −0 ...w/ponso/sample project/PonsoTest/PonsoTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata
  26. BIN ...t.xcodeproj/project.xcworkspace/xcuserdata/t.trevorrow.xcuserdatad/UserInterfaceState.xcuserstate
  27. +84 −0 ...ect/PonsoTest/PonsoTest.xcodeproj/xcuserdata/t.trevorrow.xcuserdatad/xcschemes/PonsoTest.xcscheme
  28. +22 −0 ...nsoTest/PonsoTest.xcodeproj/xcuserdata/t.trevorrow.xcuserdatad/xcschemes/xcschememanagement.plist
  29. +8 −0 contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/PonsoTest/PonsoTest-Prefix.pch
  30. +129 −0 contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/PonsoTest/main.m
  31. +6 −0 contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/Model.h
  32. +11 −0 ...uted templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/ModelAssistant.h
  33. +18 −0 ...uted templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/ModelAssistant.m
  34. +11 −0 ...ibuted templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/ModelCompany.h
  35. +18 −0 ...ibuted templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/ModelCompany.m
  36. +11 −0 ...ted templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartment.h
  37. +18 −0 ...ted templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartment.m
  38. +11 −0 ...ates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartmentAssistant.h
  39. +21 −0 ...ates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartmentAssistant.m
  40. +11 −0 ...lates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartmentEmployee.h
  41. +21 −0 ...lates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartmentEmployee.m
  42. +11 −0 ...buted templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/ModelEmployee.h
  43. +20 −0 ...buted templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/ModelEmployee.m
  44. +63 −0 ...ted templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/_ModelAssistant.h
  45. +199 −0 ...ted templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/_ModelAssistant.m
  46. +68 −0 ...buted templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/_ModelCompany.h
  47. +293 −0 ...buted templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/_ModelCompany.m
  48. +63 −0 ...ed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartment.h
  49. +241 −0 ...ed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartment.m
  50. +52 −0 ...tes/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentAssistant.h
  51. +152 −0 ...tes/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentAssistant.m
  52. +52 −0 ...ates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentEmployee.h
  53. +152 −0 ...ates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentEmployee.m
  54. +67 −0 ...uted templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/_ModelEmployee.h
  55. +223 −0 ...uted templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/_ModelEmployee.m
  56. +15 −0 contributed templates/Tyrone Trevorrow/ponso/templates/NSSet/NSCoding/human.h.motemplate
  57. +45 −0 contributed templates/Tyrone Trevorrow/ponso/templates/NSSet/NSCoding/human.m.motemplate
  58. +52 −0 contributed templates/Tyrone Trevorrow/ponso/templates/NSSet/NSCoding/machine.h.motemplate
  59. +312 −0 contributed templates/Tyrone Trevorrow/ponso/templates/NSSet/NSCoding/machine.m.motemplate
  60. 0 contributed templates/{Nikita Zhuk → Tyrone Trevorrow}/ponso/templates/NSSet/human.h.motemplate
  61. 0 contributed templates/{Nikita Zhuk → Tyrone Trevorrow}/ponso/templates/NSSet/human.m.motemplate
  62. 0 contributed templates/{Nikita Zhuk → Tyrone Trevorrow}/ponso/templates/NSSet/machine.h.motemplate
  63. +7 −4 contributed templates/{Nikita Zhuk → Tyrone Trevorrow}/ponso/templates/NSSet/machine.m.motemplate
  64. +11 −0 contributed templates/Tyrone Trevorrow/ponso/templates/human.h.motemplate
  65. +24 −0 contributed templates/Tyrone Trevorrow/ponso/templates/human.m.motemplate
  66. +52 −0 contributed templates/Tyrone Trevorrow/ponso/templates/machine.h.motemplate
  67. +229 −0 contributed templates/Tyrone Trevorrow/ponso/templates/machine.m.motemplate
@@ -24,7 +24,7 @@
#import <Foundation/Foundation.h>
-@interface ModelObject : NSObject <NSCopying>
+@interface ModelObject : NSObject <NSCopying, NSCoding>
{
NSDictionary *sourceDictionaryRepresentation;
}
@@ -22,6 +22,22 @@
@implementation ModelObject
+- (id) initWithCoder: (NSCoder*) aDecoder
+{
+ self = [super init];
+ if (self) {
+ // Superclass implementation:
+ // If we add ivars/properties, here's where we'll load them
+ }
+ return self;
+}
+
+- (void) encodeWithCoder: (NSCoder*) aCoder
+{
+ // Superclass implementation:
+ // If we add ivars/properties, here's where we'll save them
+}
+
+ (id)createModelObjectFromFile:(NSString *)filePath
{
if(![[NSFileManager defaultManager] fileExistsAtPath:filePath])
@@ -188,6 +188,7 @@
457C267F1399FAC600BF00DD /* Project object */ = {
isa = PBXProject;
attributes = {
+ LastUpgradeCheck = 0420;
ORGANIZATIONNAME = "@nzhuk";
};
buildConfigurationList = 457C26821399FAC600BF00DD /* Build configuration list for PBXProject "PonsoTest" */;
@@ -219,7 +220,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "### Settings\n\nDATA_MODEL_FILE=\"$PROJECT_DIR/MyModel.xcdatamodeld/MyModel.xcdatamodel\"\nDATA_MODEL_SOURCE_DIR=\"$PROJECT_DIR/Sources/DataModel\"\n\nBASE_CLASS=\"ModelObject\"\nAGGREGATE_HEADER=\"$DATA_MODEL_SOURCE_DIR/Model.h\"\n\nMOGENERATOR_DIR=\"$PROJECT_DIR/../../../../../\"\nMOGENERATOR_BIN=\"$MOGENERATOR_DIR/mogenerator\" ## Adjust this so that it points to a compiled mogenerator binary.\nMOGENERATOR_TEMPLATES=\"$MOGENERATOR_DIR/contributed templates/Nikita Zhuk/ponso/templates\"\n\n### Logic\n\nsource \"$MOGENERATOR_DIR/ponso/generate.sh\"\n";
+ shellScript = "### Settings\n\nDATA_MODEL_FILE=\"$PROJECT_DIR/MyModel.xcdatamodeld/MyModel.xcdatamodel\"\nDATA_MODEL_SOURCE_DIR=\"$PROJECT_DIR/Sources/DataModel\"\n\nBASE_CLASS=\"ModelObject\"\nAGGREGATE_HEADER=\"$DATA_MODEL_SOURCE_DIR/Model.h\"\n\nMOGENERATOR_DIR=\"$PROJECT_DIR/../../../../../\"\nMOGENERATOR_BIN=`type -P mogenerator` ## Adjust this so that it points to a compiled mogenerator binary.\nMOGENERATOR_TEMPLATES=\"$MOGENERATOR_DIR/contributed templates/Nikita Zhuk/ponso/templates/NSSet/NSCoding\"\n\n### Logic\n\nsource \"$MOGENERATOR_DIR/ponso/generate.sh\"\n";
};
/* End PBXShellScriptBuildPhase section */
@@ -4,4 +4,3 @@
#import "ModelDepartmentAssistant.h"
#import "ModelDepartmentEmployee.h"
#import "ModelEmployee.h"
-
@@ -10,6 +10,7 @@
#import <Foundation/Foundation.h>
#import "ModelObject.h"
+#import "ModelObject.h"
@class ModelEmployee;
@class ModelCompany;
@@ -21,7 +22,7 @@
@end
-@interface _ModelAssistant : ModelObject
+@interface _ModelAssistant : ModelObject <NSCoding>
{
NSDate *birthDate;
NSString *name;
@@ -31,7 +32,7 @@
ModelCompany *company;
- NSArray *departments;
+ NSSet *departments;
}
@@ -42,14 +43,21 @@
@property (nonatomic, assign, readwrite) ModelCompany *company;
-@property (nonatomic, retain, readonly) NSArray *departments;
+@property (nonatomic, retain, readonly) NSSet *departments;
+- (void)addDepartmentsObject:(ModelDepartmentAssistant*)value_ settingInverse: (BOOL) setInverse;
- (void)addDepartmentsObject:(ModelDepartmentAssistant*)value_;
- (void)removeDepartmentsObjects;
+- (void)removeDepartmentsObject:(ModelDepartmentAssistant*)value_ settingInverse: (BOOL) setInverse;
- (void)removeDepartmentsObject:(ModelDepartmentAssistant*)value_;
+- (void) setBoss: (ModelEmployee*) boss_ settingInverse: (BOOL) setInverse;
+
+- (void) setCompany: (ModelCompany*) company_ settingInverse: (BOOL) setInverse;
+
+
@end
@@ -7,34 +7,68 @@
// Make changes to ModelAssistant.h instead.
//
+
#import "_ModelAssistant.h"
#import "ModelEmployee.h"
#import "ModelCompany.h"
#import "ModelDepartmentAssistant.h"
-
@interface _ModelAssistant()
-@property (nonatomic, retain, readwrite) NSArray *departments;
-
+@property (nonatomic, retain, readwrite) NSSet *departments;
@end
/** \ingroup DataModel */
-@implementation _ModelAssistant
+NS_INLINE NSMutableSet* NonretainingNSMutableSetMake()
+{
+ CFSetCallBacks callbacks = {0, NULL, NULL, CFCopyDescription, CFEqual, CFHash};
+ return [(NSMutableSet*) CFSetCreateMutable(0, 0, &callbacks) autorelease];
+}
+@implementation _ModelAssistant
- (id)init
{
if((self = [super init]))
{
-
}
return self;
}
-#pragma mark Scalar values
+- (id) initWithCoder: (NSCoder*) aDecoder
+{
+ if ([[super class] instancesRespondToSelector: @selector(initWithCoder:)]) {
+ self = [super initWithCoder: aDecoder];
+ } else {
+ self = [super init];
+ }
+ if (self) {
+ self.birthDate = [aDecoder decodeObjectForKey: @"birthDate"];
+ self.name = [aDecoder decodeObjectForKey: @"name"];
+ self.boss = [aDecoder decodeObjectForKey: @"boss"];
+ self.company = [aDecoder decodeObjectForKey: @"company"];
+ {
+ NSSet *set = [aDecoder decodeObjectForKey: @"departments"];
+ NSMutableSet *nonretainingSet = NonretainingNSMutableSetMake();
+ [nonretainingSet unionSet: set];
+ self.departments = nonretainingSet;
+ }
+ }
+ return self;
+}
+
+- (void) encodeWithCoder: (NSCoder*) aCoder
+{
+ [super encodeWithCoder: aCoder];
+ [aCoder encodeObject: self.birthDate forKey: @"birthDate"];
+ [aCoder encodeObject: self.name forKey: @"name"];
+ [aCoder encodeObject: self.boss forKey: @"boss"];
+ [aCoder encodeObject: self.company forKey: @"company"];
+ [aCoder encodeObject: self.departments forKey: @"departments"];
+}
+#pragma mark Scalar values
#pragma mark Dictionary representation
@@ -45,8 +79,6 @@ - (id)initWithDictionaryRepresentation:(NSDictionary *)dictionary
{
self.birthDate = [dictionary objectForKey:@"ModelAssistant.birthDate"];
self.name = [dictionary objectForKey:@"ModelAssistant.name"];
-
-
}
return self;
@@ -57,21 +89,9 @@ - (NSDictionary *)dictionaryRepresentation
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:[super dictionaryRepresentation]];
[dict setObjectIfNotNil:self.birthDate forKey:@"ModelAssistant.birthDate"];
[dict setObjectIfNotNil:self.name forKey:@"ModelAssistant.name"];
-
-
-
-
-
-
-
-
-
if([self.departments count] > 0)
{
-
}
-
-
return dict;
}
@@ -81,59 +101,99 @@ - (void)awakeFromDictionaryRepresentationInit
return; // awakeFromDictionaryRepresentationInit has been already executed on this object.
-
-
-
-
[super awakeFromDictionaryRepresentationInit];
}
#pragma mark Direct access
-
-- (void)addDepartmentsObject:(ModelDepartmentAssistant*)value_
+- (void)addDepartmentsObject:(ModelDepartmentAssistant*)value_ settingInverse: (BOOL) setInverse
{
- if(self.departments == nil)
+ if(self.departments == nil)
{
- self.departments = [NSMutableArray array];
+ self.departments = NonretainingNSMutableSetMake();
}
- [(NSMutableArray *)self.departments addObject:value_];
- value_.assistant = (ModelAssistant*)self;
+ [(NSMutableSet *)self.departments addObject:value_];
+ if (setInverse == YES) {
+ [value_ setAssistant: (ModelAssistant*)self settingInverse: NO];
+ }
+}
+
+- (void)addDepartmentsObject:(ModelDepartmentAssistant*)value_
+{
+ [self addDepartmentsObject:(ModelDepartmentAssistant*)value_ settingInverse: YES];
}
- (void)removeDepartmentsObjects
{
- self.departments = [NSMutableArray array];
+ self.departments = NonretainingNSMutableSetMake();
+}
+
+- (void)removeDepartmentsObject:(ModelDepartmentAssistant*)value_ settingInverse: (BOOL) setInverse
+{
+ if (setInverse == YES) {
+ [value_ setAssistant: nil settingInverse: NO];
+ }
+ [(NSMutableSet *)self.departments removeObject:value_];
}
- (void)removeDepartmentsObject:(ModelDepartmentAssistant*)value_
{
- value_.assistant = nil;
- [(NSMutableArray *)self.departments removeObject:value_];
+ [self removeDepartmentsObject:(ModelDepartmentAssistant*)value_ settingInverse: YES];
+}
+
+- (void) setBoss: (ModelEmployee*) boss_ settingInverse: (BOOL) setInverse
+{
+ if (boss_ == nil && setInverse == YES) {
+ [boss setAssistant: nil settingInverse: NO];
+ }
+ boss = boss_;
+ if (setInverse == YES) {
+ [boss setAssistant: (ModelAssistant*)self settingInverse: NO];
+ }
}
+- (void) setBoss: (ModelEmployee*) boss_
+{
+ [self setBoss: boss_ settingInverse: YES];
+}
+
+- (ModelEmployee*) boss{
+ return boss;
+}
+
+- (void) setCompany: (ModelCompany*) company_ settingInverse: (BOOL) setInverse
+{
+ if (company_ == nil && setInverse == YES) {
+ [company removeAssistantsObject: (ModelAssistant*)self settingInverse: NO];
+ }
+ company = company_;
+ if (setInverse == YES) {
+ [company addAssistantsObject: (ModelAssistant*)self settingInverse: NO];
+ }
+}
+
+- (void) setCompany: (ModelCompany*) company_
+{
+ [self setCompany: company_ settingInverse: YES];
+}
+
+- (ModelCompany*) company{
+ return company;
+}
- (void)dealloc
{
self.birthDate = nil;
self.name = nil;
-
- self.boss = nil;
- self.company = nil;
- self.departments = nil;
-
[super dealloc];
}
#pragma mark Synthesizes
@synthesize birthDate;
@synthesize name;
-
-@synthesize boss;
-@synthesize company;
@synthesize departments;
@end
@@ -10,6 +10,7 @@
#import <Foundation/Foundation.h>
#import "ModelObject.h"
+#import "ModelObject.h"
@class ModelAssistant;
@class ModelDepartment;
@@ -21,40 +22,47 @@
@end
-@interface _ModelCompany : ModelObject
+@interface _ModelCompany : ModelObject <NSCoding>
{
NSString *name;
NSNumber *yearFounded;
- NSArray *assistants;
+ NSSet *assistants;
- NSArray *departments;
+ NSSet *departments;
- NSArray *employees;
+ NSSet *employees;
}
@property (nonatomic, retain, readwrite) NSString *name;
@property (nonatomic, retain, readwrite) NSNumber *yearFounded;
@property (nonatomic, assign, readwrite) int yearFoundedValue;
-@property (nonatomic, retain, readonly) NSArray *assistants;
-@property (nonatomic, retain, readonly) NSArray *departments;
-@property (nonatomic, retain, readonly) NSArray *employees;
+@property (nonatomic, retain, readonly) NSSet *assistants;
+@property (nonatomic, retain, readonly) NSSet *departments;
+@property (nonatomic, retain, readonly) NSSet *employees;
+- (void)addAssistantsObject:(ModelAssistant*)value_ settingInverse: (BOOL) setInverse;
- (void)addAssistantsObject:(ModelAssistant*)value_;
- (void)removeAssistantsObjects;
+- (void)removeAssistantsObject:(ModelAssistant*)value_ settingInverse: (BOOL) setInverse;
- (void)removeAssistantsObject:(ModelAssistant*)value_;
+- (void)addDepartmentsObject:(ModelDepartment*)value_ settingInverse: (BOOL) setInverse;
- (void)addDepartmentsObject:(ModelDepartment*)value_;
- (void)removeDepartmentsObjects;
+- (void)removeDepartmentsObject:(ModelDepartment*)value_ settingInverse: (BOOL) setInverse;
- (void)removeDepartmentsObject:(ModelDepartment*)value_;
+- (void)addEmployeesObject:(ModelEmployee*)value_ settingInverse: (BOOL) setInverse;
- (void)addEmployeesObject:(ModelEmployee*)value_;
- (void)removeEmployeesObjects;
+- (void)removeEmployeesObject:(ModelEmployee*)value_ settingInverse: (BOOL) setInverse;
- (void)removeEmployeesObject:(ModelEmployee*)value_;
+
@end
Oops, something went wrong.

0 comments on commit 018017b

Please sign in to comment.