Mercurial > projects > dstep
comparison dstep/coredata/NSMigrationManager.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | |
children | b9de51448c6b |
comparison
equal
deleted
inserted
replaced
15:7ff919f595d5 | 16:19885b43130e |
---|---|
1 /** | |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Sep 25, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.coredata.NSMigrationManager; | |
8 | |
9 import dstep.coredata.NSEntityDescription; | |
10 import dstep.coredata.NSEntityMapping; | |
11 import dstep.coredata.NSManagedObject; | |
12 import dstep.coredata.NSManagedObjectContext; | |
13 import dstep.coredata.NSManagedObjectModel; | |
14 import dstep.coredata.NSMappingModel; | |
15 import dstep.foundation.NSArray; | |
16 import dstep.foundation.NSDictionary; | |
17 import dstep.foundation.NSError; | |
18 import dstep.foundation.NSObject; | |
19 import dstep.foundation.NSString; | |
20 import dstep.foundation.NSURL; | |
21 import dstep.objc.bridge.Bridge; | |
22 import dstep.objc.objc; | |
23 | |
24 class NSMigrationManager : NSObject | |
25 { | |
26 mixin (ObjcWrap); | |
27 | |
28 NSMigrationManager initWithSourceModel (NSManagedObjectModel sourceModel, NSManagedObjectModel destinationModel) | |
29 { | |
30 id result = invokeObjcSelf!(id, "initWithSourceModel:destinationModel:", NSManagedObjectModel, NSManagedObjectModel)(sourceModel, destinationModel); | |
31 return result is this.objcObject ? this : (result !is null ? new NSMigrationManager(result) : null); | |
32 } | |
33 | |
34 this (NSManagedObjectModel sourceModel, NSManagedObjectModel destinationModel) | |
35 { | |
36 super(NSMigrationManager.alloc.initWithSourceModel(sourceModel, destinationModel).objcObject); | |
37 } | |
38 | |
39 bool migrateStoreFromURL (NSURL sourceURL, NSString sStoreType, NSDictionary sOptions, NSMappingModel mappings, NSURL dURL, NSString dStoreType, NSDictionary dOptions, ref NSError error) | |
40 { | |
41 id __arg7; | |
42 | |
43 if (error) | |
44 __arg7 = error.objcObject; | |
45 | |
46 bool result = invokeObjcSelf!(bool, "migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error:", NSURL, NSString, NSDictionary, NSMappingModel, NSURL, NSString, NSDictionary, id*)(sourceURL, sStoreType, sOptions, mappings, dURL, dStoreType, dOptions, &__arg7); | |
47 | |
48 if (__arg7) | |
49 error = new NSError(__arg7); | |
50 | |
51 return result; | |
52 } | |
53 | |
54 void reset () | |
55 { | |
56 return invokeObjcSelf!(void, "reset"); | |
57 } | |
58 | |
59 NSMappingModel mappingModel () | |
60 { | |
61 return invokeObjcSelf!(NSMappingModel, "mappingModel"); | |
62 } | |
63 | |
64 NSManagedObjectModel sourceModel () | |
65 { | |
66 return invokeObjcSelf!(NSManagedObjectModel, "sourceModel"); | |
67 } | |
68 | |
69 NSManagedObjectModel destinationModel () | |
70 { | |
71 return invokeObjcSelf!(NSManagedObjectModel, "destinationModel"); | |
72 } | |
73 | |
74 NSManagedObjectContext sourceContext () | |
75 { | |
76 return invokeObjcSelf!(NSManagedObjectContext, "sourceContext"); | |
77 } | |
78 | |
79 NSManagedObjectContext destinationContext () | |
80 { | |
81 return invokeObjcSelf!(NSManagedObjectContext, "destinationContext"); | |
82 } | |
83 | |
84 NSEntityDescription sourceEntityForEntityMapping (NSEntityMapping mEntity) | |
85 { | |
86 return invokeObjcSelf!(NSEntityDescription, "sourceEntityForEntityMapping:", NSEntityMapping)(mEntity); | |
87 } | |
88 | |
89 NSEntityDescription destinationEntityForEntityMapping (NSEntityMapping mEntity) | |
90 { | |
91 return invokeObjcSelf!(NSEntityDescription, "destinationEntityForEntityMapping:", NSEntityMapping)(mEntity); | |
92 } | |
93 | |
94 void associateSourceInstance (NSManagedObject sourceInstance, NSManagedObject destinationInstance, NSEntityMapping entityMapping) | |
95 { | |
96 return invokeObjcSelf!(void, "associateSourceInstance:withDestinationInstance:forEntityMapping:", NSManagedObject, NSManagedObject, NSEntityMapping)(sourceInstance, destinationInstance, entityMapping); | |
97 } | |
98 | |
99 NSArray destinationInstancesForEntityMappingNamed (NSString mappingName, NSArray sourceInstances) | |
100 { | |
101 return invokeObjcSelf!(NSArray, "destinationInstancesForEntityMappingNamed:sourceInstances:", NSString, NSArray)(mappingName, sourceInstances); | |
102 } | |
103 | |
104 NSArray sourceInstancesForEntityMappingNamed (NSString mappingName, NSArray destinationInstances) | |
105 { | |
106 return invokeObjcSelf!(NSArray, "sourceInstancesForEntityMappingNamed:destinationInstances:", NSString, NSArray)(mappingName, destinationInstances); | |
107 } | |
108 | |
109 NSEntityMapping currentEntityMapping () | |
110 { | |
111 return invokeObjcSelf!(NSEntityMapping, "currentEntityMapping"); | |
112 } | |
113 | |
114 float migrationProgress () | |
115 { | |
116 return invokeObjcSelf!(float, "migrationProgress"); | |
117 } | |
118 | |
119 NSDictionary userInfo () | |
120 { | |
121 return invokeObjcSelf!(NSDictionary, "userInfo"); | |
122 } | |
123 | |
124 void setUserInfo (NSDictionary dict) | |
125 { | |
126 return invokeObjcSelf!(void, "setUserInfo:", NSDictionary)(dict); | |
127 } | |
128 | |
129 void cancelMigrationWithError (NSError error) | |
130 { | |
131 return invokeObjcSelf!(void, "cancelMigrationWithError:", NSError)(error); | |
132 } | |
133 } | |
134 |