@@ -11,12 +11,12 @@ import arcs.core.storage.StorageKey
11
11
import arcs.core.storage.api.Entity
12
12
import arcs.core.storage.api.EntitySpec
13
13
import arcs.core.storage.api.Handle
14
- import arcs.core.storage.api.ReadWriteCollection
15
- import arcs.core.storage.api.ReadWriteSingleton
16
- import arcs.core.storage.api.ReadableCollection
17
- import arcs.core.storage.api.ReadableSingleton
18
- import arcs.core.storage.api.WritableCollection
19
- import arcs.core.storage.api.WritableSingleton
14
+ import arcs.core.storage.api.ReadCollectionHandle
15
+ import arcs.core.storage.api.ReadSingletonHandle
16
+ import arcs.core.storage.api.ReadWriteCollectionHandle
17
+ import arcs.core.storage.api.ReadWriteSingletonHandle
18
+ import arcs.core.storage.api.WriteCollectionHandle
19
+ import arcs.core.storage.api.WriteSingletonHandle
20
20
import arcs.core.storage.handle.CollectionImpl
21
21
import arcs.core.storage.handle.HandleManager
22
22
import arcs.core.storage.handle.SetData
@@ -37,14 +37,16 @@ typealias CollectionSenderCallbackAdapter<E> =
37
37
38
38
/* *
39
39
* Wraps a [HandleManager] and creates [Entity] handles based on [HandleMode], such as
40
- * [ReadableSingleton ] for [HandleMode.Read]. To obtain a [HandleHolder], use
40
+ * [ReadSingletonHandle ] for [HandleMode.Read]. To obtain a [HandleHolder], use
41
41
* `arcs_kt_schema` on a manifest file to generate a `{ParticleName}Handles' class, and
42
42
* invoke its default constructor, or obtain it from the [BaseParticle.handles] field.
43
+ *
44
+ * TODO(cromwellian): Add support for creating Singleton/Set handles of [Reference]s.
43
45
*/
44
46
class EntityHandleManager (val handleManager : HandleManager ) {
45
47
/* *
46
- * Creates and returns a new [SingletonHandle]. Will also populate the appropriate field inside
47
- * the given [HandleHolder].
48
+ * Creates and returns a new [SingletonHandle] for managing an [Entity] . Will also populate the
49
+ * appropriate field inside the given [HandleHolder].
48
50
*
49
51
* @property handleHolder contains handle and entitySpec declarations
50
52
* @property handleName name for the handle, must be present in [HandleHolder.entitySpecs]
@@ -65,15 +67,20 @@ class EntityHandleManager(val handleManager: HandleManager) {
65
67
) = createSdkHandle(
66
68
handleHolder,
67
69
handleName,
68
- handleManager.singletonHandle(storageKey, schema, canRead = handleMode != HandleMode .Write ),
70
+ handleManager.rawEntitySingletonHandle(
71
+ storageKey,
72
+ schema,
73
+ name = handleName,
74
+ canRead = handleMode != HandleMode .Write
75
+ ),
69
76
handleMode,
70
77
idGenerator,
71
78
sender
72
79
)
73
80
74
81
/* *
75
- * Creates and returns a new [SetHandle]. Will also populate the appropriate field inside
76
- * the given [HandleHolder].
82
+ * Creates and returns a new [SetHandle] for a set of [Entity]s . Will also populate the
83
+ * appropriate field inside the given [HandleHolder].
77
84
*
78
85
* @property handleHolder contains handle and entitySpec declarations
79
86
* @property handleName name for the handle, must be present in [HandleHolder.entitySpecs]
@@ -94,7 +101,12 @@ class EntityHandleManager(val handleManager: HandleManager) {
94
101
) = createSdkHandle(
95
102
handleHolder,
96
103
handleName,
97
- handleManager.setHandle(storageKey, schema, canRead = handleMode != HandleMode .Write ),
104
+ handleManager.rawEntitySetHandle(
105
+ storageKey,
106
+ schema,
107
+ name = handleName,
108
+ canRead = handleMode != HandleMode .Write
109
+ ),
98
110
handleMode,
99
111
idGenerator,
100
112
sender
@@ -216,12 +228,12 @@ internal open class HandleEventBase<T, H : Handle> {
216
228
}
217
229
}
218
230
219
- internal open class ReadableSingletonHandleImpl <T : Entity >(
231
+ internal open class ReadSingletonHandleImpl <T : Entity >(
220
232
val entitySpec : EntitySpec <T >,
221
233
val handleName : String ,
222
234
val storageHandle : SingletonHandle <RawEntity >,
223
235
val sender : Sender
224
- ) : HandleEventBase<T?, ReadableSingleton <T>>(), ReadableSingleton <T> {
236
+ ) : HandleEventBase<T?, ReadSingletonHandle <T>>(), ReadSingletonHandle <T> {
225
237
init {
226
238
storageHandle.callback = SingletonSenderCallbackAdapter (
227
239
this ::fetch,
@@ -242,11 +254,11 @@ internal open class ReadableSingletonHandleImpl<T : Entity>(
242
254
}
243
255
}
244
256
245
- internal class WritableSingletonHandleImpl <T : Entity >(
257
+ internal class WriteSingletonHandleImpl <T : Entity >(
246
258
val handleName : String ,
247
259
val storageHandle : SingletonHandle <RawEntity >,
248
260
val idGenerator : Id .Generator
249
- ) : WritableSingleton <T> {
261
+ ) : WriteSingletonHandle <T> {
250
262
override val name: String
251
263
get() = handleName
252
264
@@ -265,24 +277,24 @@ internal class ReadWriteSingletonHandleImpl<T : Entity>(
265
277
storageHandle : SingletonHandle <RawEntity >,
266
278
idGenerator : Id .Generator ,
267
279
sender : Sender ,
268
- private val writableSingleton : WritableSingletonHandleImpl <T > = WritableSingletonHandleImpl (
280
+ private val writableSingleton : WriteSingletonHandleImpl <T > = WriteSingletonHandleImpl (
269
281
handleName,
270
282
storageHandle,
271
283
idGenerator
272
284
)
273
- ) : ReadWriteSingleton <T>,
274
- ReadableSingletonHandleImpl <T >(entitySpec, handleName, storageHandle, sender),
275
- WritableSingleton <T > by writableSingleton {
285
+ ) : ReadWriteSingletonHandle <T>,
286
+ ReadSingletonHandleImpl <T >(entitySpec, handleName, storageHandle, sender),
287
+ WriteSingletonHandle <T > by writableSingleton {
276
288
override val name: String
277
289
get() = writableSingleton.name
278
290
}
279
291
280
- internal open class ReadableCollectionHandleImpl <T : Entity >(
292
+ internal open class ReadCollectionHandleImpl <T : Entity >(
281
293
val entitySpec : EntitySpec <T >,
282
294
val handleName : String ,
283
295
val storageHandle : SetHandle <RawEntity >,
284
296
val sender : Sender
285
- ) : HandleEventBase<Set<T>, ReadableCollection <T>>(), ReadableCollection <T> {
297
+ ) : HandleEventBase<Set<T>, ReadCollectionHandle <T>>(), ReadCollectionHandle <T> {
286
298
init {
287
299
storageHandle.callback = CollectionSenderCallbackAdapter (
288
300
this ::fetchAll,
@@ -307,11 +319,11 @@ internal open class ReadableCollectionHandleImpl<T : Entity>(
307
319
}.toSet()
308
320
}
309
321
310
- internal class WritableCollectionHandleImpl <T : Entity >(
322
+ internal class WriteCollectionHandleImpl <T : Entity >(
311
323
val handleName : String ,
312
324
val storageHandle : CollectionImpl <RawEntity >,
313
325
val idGenerator : Id .Generator
314
- ) : WritableCollection <T> {
326
+ ) : WriteCollectionHandle <T> {
315
327
override val name: String
316
328
get() = handleName
317
329
@@ -336,14 +348,14 @@ internal class ReadWriteCollectionHandleImpl<T : Entity>(
336
348
storageHandle : CollectionImpl <RawEntity >,
337
349
idGenerator : Id .Generator ,
338
350
sender : Sender ,
339
- private val writableCollection : WritableCollectionHandleImpl <T > = WritableCollectionHandleImpl (
351
+ private val writableCollection : WriteCollectionHandleImpl <T > = WriteCollectionHandleImpl (
340
352
handleName,
341
353
storageHandle,
342
354
idGenerator
343
355
)
344
- ) : ReadWriteCollection <T>,
345
- ReadableCollectionHandleImpl <T >(entitySpec, handleName, storageHandle, sender),
346
- WritableCollection <T > by writableCollection {
356
+ ) : ReadWriteCollectionHandle <T>,
357
+ ReadCollectionHandleImpl <T >(entitySpec, handleName, storageHandle, sender),
358
+ WriteCollectionHandle <T > by writableCollection {
347
359
override val name: String
348
360
get() = writableCollection.name
349
361
}
@@ -396,13 +408,13 @@ private fun <T : Entity> createSingletonHandle(
396
408
idGenerator,
397
409
sender
398
410
)
399
- HandleMode .Read -> ReadableSingletonHandleImpl <T >(
411
+ HandleMode .Read -> ReadSingletonHandleImpl <T >(
400
412
entitySpec,
401
413
handleName,
402
414
storageHandle,
403
415
sender
404
416
)
405
- HandleMode .Write -> WritableSingletonHandleImpl <T >(
417
+ HandleMode .Write -> WriteSingletonHandleImpl <T >(
406
418
handleName,
407
419
storageHandle,
408
420
idGenerator
@@ -426,13 +438,13 @@ private fun <T : Entity> createSetHandle(
426
438
idGenerator,
427
439
sender
428
440
)
429
- HandleMode .Read -> ReadableCollectionHandleImpl <T >(
441
+ HandleMode .Read -> ReadCollectionHandleImpl <T >(
430
442
entitySpec,
431
443
handleName,
432
444
storageHandle,
433
445
sender
434
446
)
435
- HandleMode .Write -> WritableCollectionHandleImpl <T >(
447
+ HandleMode .Write -> WriteCollectionHandleImpl <T >(
436
448
handleName,
437
449
storageHandle,
438
450
idGenerator
0 commit comments