MediaLibraryBaseModel.swift 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*****************************************************************************
  2. * MediaLibraryBaseModel.swift
  3. *
  4. * Copyright © 2018 VLC authors and VideoLAN
  5. * Copyright © 2018 Videolabs
  6. *
  7. * Authors: Soomin Lee <bubu@mikan.io>
  8. *
  9. * Refer to the COPYING file of the official project for license.
  10. *****************************************************************************/
  11. protocol MediaLibraryModelView {
  12. func dataChanged()
  13. }
  14. // Expose a "shadow" version without associatedType in order to use it as a type
  15. protocol MediaLibraryBaseModel {
  16. init(medialibrary: VLCMediaLibraryManager)
  17. var anyfiles: [VLCMLObject] { get }
  18. var updateView: (() -> Void)? { get set }
  19. var indicatorName: String { get }
  20. func append(_ item: VLCMLObject)
  21. func isIncluded(_ item: VLCMLObject)
  22. }
  23. protocol MLBaseModel: MediaLibraryBaseModel {
  24. associatedtype MLType where MLType: VLCMLObject
  25. init(medialibrary: VLCMediaLibraryManager)
  26. var files: [MLType] { get set }
  27. var updateView: (() -> Void)? { get set }
  28. var indicatorName: String { get }
  29. func append(_ item: MLType)
  30. func isIncluded(_ item: MLType)
  31. }
  32. extension MLBaseModel {
  33. var anyfiles: [VLCMLObject] {
  34. return files
  35. }
  36. func append(_ item: VLCMLObject) {
  37. fatalError()
  38. }
  39. func isIncluded(_ item: VLCMLObject) {
  40. fatalError()
  41. }
  42. }