//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
//  THIS FILE IS GENERATED BY EASY BINDINGS, DO NOT MODIFY IT
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

import Cocoa

//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
//    ReadOnlyArrayOf_CommentInSchematic
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

class ReadOnlyArrayOf_CommentInSchematic : ReadOnlyAbstractArrayProperty <CommentInSchematic> {

  //····················································································································

  internal override func updateObservers (removedSet inRemovedSet : EBReferenceSet <CommentInSchematic>,
                                          addedSet inAddedSet : EBReferenceSet <CommentInSchematic>) {
    super.updateObservers (removedSet: inRemovedSet, addedSet: inAddedSet)
  //--- Remove observers from removed objects
    if !inRemovedSet.isEmpty {
      self.removeEBObserversOf_mColor_fromElementsOfSet (inRemovedSet) // Stored property
      self.removeEBObserversOf_mSize_fromElementsOfSet (inRemovedSet) // Stored property
      self.removeEBObserversOf_mHorizontalAlignment_fromElementsOfSet (inRemovedSet) // Stored property
      self.removeEBObserversOf_mVerticalAlignment_fromElementsOfSet (inRemovedSet) // Stored property
      self.removeEBObserversOf_mX_fromElementsOfSet (inRemovedSet) // Stored property
      self.removeEBObserversOf_mY_fromElementsOfSet (inRemovedSet) // Stored property
      self.removeEBObserversOf_mComment_fromElementsOfSet (inRemovedSet) // Stored property
      self.removeEBObserversOf_objectDisplay_fromElementsOfSet (inRemovedSet) // Transient property
      self.removeEBObserversOf_selectionDisplay_fromElementsOfSet (inRemovedSet) // Transient property
    }
  //--- Add observers to added objects
    if !inAddedSet.isEmpty {
      self.addEBObserversOf_mColor_toElementsOfSet (inAddedSet) // Stored property
      self.addEBObserversOf_mSize_toElementsOfSet (inAddedSet) // Stored property
      self.addEBObserversOf_mHorizontalAlignment_toElementsOfSet (inAddedSet) // Stored property
      self.addEBObserversOf_mVerticalAlignment_toElementsOfSet (inAddedSet) // Stored property
      self.addEBObserversOf_mX_toElementsOfSet (inAddedSet) // Stored property
      self.addEBObserversOf_mY_toElementsOfSet (inAddedSet) // Stored property
      self.addEBObserversOf_mComment_toElementsOfSet (inAddedSet) // Stored property
      self.addEBObserversOf_objectDisplay_toElementsOfSet (inAddedSet) // Transient property
      self.addEBObserversOf_selectionDisplay_toElementsOfSet (inAddedSet) // Transient property
   }
  }

  //····················································································································
  //   Observers of 'mColor' stored property
  //····················································································································

  private final var mObserversOf_mColor = EBWeakEventSet ()

  //····················································································································

  final func addEBObserverOf_mColor (_ inObserver : EBEvent) {
    self.addEBObserver (inObserver)
    self.mObserversOf_mColor.insert (inObserver)
    switch self.selection {
    case .empty, .multiple :
      break
    case .single (let v) :
      for managedObject in v {
        managedObject.mColor_property.addEBObserver (inObserver)
      }
    }
  }

  //····················································································································

  final func removeEBObserverOf_mColor (_ inObserver : EBEvent) {
    self.removeEBObserver (inObserver)
    self.mObserversOf_mColor.remove (inObserver)
    switch self.selection {
    case .empty, .multiple :
      break
    case .single (let v) :
      for managedObject in v {
        managedObject.mColor_property.removeEBObserver (inObserver)
      }
    }
  }

  //····················································································································

  final func addEBObserversOf_mColor_toElementsOfSet (_ inSet : EBReferenceSet <CommentInSchematic>) {
    if !self.mObserversOf_mColor.isEmpty {
      for managedObject in inSet.values {
        self.mObserversOf_mColor.apply { (_ observer : EBEvent) in
          managedObject.mColor_property.addEBObserver (observer)
        }
      }
    }
  }

  //····················································································································

  final func removeEBObserversOf_mColor_fromElementsOfSet (_ inSet : EBReferenceSet <CommentInSchematic>) {
    self.mObserversOf_mColor.apply { (_ observer : EBEvent) in
      observer.postEvent ()
      for managedObject in inSet.values {
        managedObject.mColor_property.removeEBObserver (observer)
      }
    }
  }

  //····················································································································
  //   Observers of 'mSize' stored property
  //····················································································································

  private final var mObserversOf_mSize = EBWeakEventSet ()

  //····················································································································

  final func addEBObserverOf_mSize (_ inObserver : EBEvent) {
    self.addEBObserver (inObserver)
    self.mObserversOf_mSize.insert (inObserver)
    switch self.selection {
    case .empty, .multiple :
      break
    case .single (let v) :
      for managedObject in v {
        managedObject.mSize_property.addEBObserver (inObserver)
      }
    }
  }

  //····················································································································

  final func removeEBObserverOf_mSize (_ inObserver : EBEvent) {
    self.removeEBObserver (inObserver)
    self.mObserversOf_mSize.remove (inObserver)
    switch self.selection {
    case .empty, .multiple :
      break
    case .single (let v) :
      for managedObject in v {
        managedObject.mSize_property.removeEBObserver (inObserver)
      }
    }
  }

  //····················································································································

  final func addEBObserversOf_mSize_toElementsOfSet (_ inSet : EBReferenceSet <CommentInSchematic>) {
    if !self.mObserversOf_mSize.isEmpty {
      for managedObject in inSet.values {
        self.mObserversOf_mSize.apply { (_ observer : EBEvent) in
          managedObject.mSize_property.addEBObserver (observer)
        }
      }
    }
  }

  //····················································································································

  final func removeEBObserversOf_mSize_fromElementsOfSet (_ inSet : EBReferenceSet <CommentInSchematic>) {
    self.mObserversOf_mSize.apply { (_ observer : EBEvent) in
      observer.postEvent ()
      for managedObject in inSet.values {
        managedObject.mSize_property.removeEBObserver (observer)
      }
    }
  }

  //····················································································································
  //   Observers of 'mHorizontalAlignment' stored property
  //····················································································································

  private final var mObserversOf_mHorizontalAlignment = EBWeakEventSet ()

  //····················································································································

  final func addEBObserverOf_mHorizontalAlignment (_ inObserver : EBEvent) {
    self.addEBObserver (inObserver)
    self.mObserversOf_mHorizontalAlignment.insert (inObserver)
    switch self.selection {
    case .empty, .multiple :
      break
    case .single (let v) :
      for managedObject in v {
        managedObject.mHorizontalAlignment_property.addEBObserver (inObserver)
      }
    }
  }

  //····················································································································

  final func removeEBObserverOf_mHorizontalAlignment (_ inObserver : EBEvent) {
    self.removeEBObserver (inObserver)
    self.mObserversOf_mHorizontalAlignment.remove (inObserver)
    switch self.selection {
    case .empty, .multiple :
      break
    case .single (let v) :
      for managedObject in v {
        managedObject.mHorizontalAlignment_property.removeEBObserver (inObserver)
      }
    }
  }

  //····················································································································

  final func addEBObserversOf_mHorizontalAlignment_toElementsOfSet (_ inSet : EBReferenceSet <CommentInSchematic>) {
    if !self.mObserversOf_mHorizontalAlignment.isEmpty {
      for managedObject in inSet.values {
        self.mObserversOf_mHorizontalAlignment.apply { (_ observer : EBEvent) in
          managedObject.mHorizontalAlignment_property.addEBObserver (observer)
        }
      }
    }
  }

  //····················································································································

  final func removeEBObserversOf_mHorizontalAlignment_fromElementsOfSet (_ inSet : EBReferenceSet <CommentInSchematic>) {
    self.mObserversOf_mHorizontalAlignment.apply { (_ observer : EBEvent) in
      observer.postEvent ()
      for managedObject in inSet.values {
        managedObject.mHorizontalAlignment_property.removeEBObserver (observer)
      }
    }
  }

  //····················································································································
  //   Observers of 'mVerticalAlignment' stored property
  //····················································································································

  private final var mObserversOf_mVerticalAlignment = EBWeakEventSet ()

  //····················································································································

  final func addEBObserverOf_mVerticalAlignment (_ inObserver : EBEvent) {
    self.addEBObserver (inObserver)
    self.mObserversOf_mVerticalAlignment.insert (inObserver)
    switch self.selection {
    case .empty, .multiple :
      break
    case .single (let v) :
      for managedObject in v {
        managedObject.mVerticalAlignment_property.addEBObserver (inObserver)
      }
    }
  }

  //····················································································································

  final func removeEBObserverOf_mVerticalAlignment (_ inObserver : EBEvent) {
    self.removeEBObserver (inObserver)
    self.mObserversOf_mVerticalAlignment.remove (inObserver)
    switch self.selection {
    case .empty, .multiple :
      break
    case .single (let v) :
      for managedObject in v {
        managedObject.mVerticalAlignment_property.removeEBObserver (inObserver)
      }
    }
  }

  //····················································································································

  final func addEBObserversOf_mVerticalAlignment_toElementsOfSet (_ inSet : EBReferenceSet <CommentInSchematic>) {
    if !self.mObserversOf_mVerticalAlignment.isEmpty {
      for managedObject in inSet.values {
        self.mObserversOf_mVerticalAlignment.apply { (_ observer : EBEvent) in
          managedObject.mVerticalAlignment_property.addEBObserver (observer)
        }
      }
    }
  }

  //····················································································································

  final func removeEBObserversOf_mVerticalAlignment_fromElementsOfSet (_ inSet : EBReferenceSet <CommentInSchematic>) {
    self.mObserversOf_mVerticalAlignment.apply { (_ observer : EBEvent) in
      observer.postEvent ()
      for managedObject in inSet.values {
        managedObject.mVerticalAlignment_property.removeEBObserver (observer)
      }
    }
  }

  //····················································································································
  //   Observers of 'mX' stored property
  //····················································································································

  private final var mObserversOf_mX = EBWeakEventSet ()

  //····················································································································

  final func addEBObserverOf_mX (_ inObserver : EBEvent) {
    self.addEBObserver (inObserver)
    self.mObserversOf_mX.insert (inObserver)
    switch self.selection {
    case .empty, .multiple :
      break
    case .single (let v) :
      for managedObject in v {
        managedObject.mX_property.addEBObserver (inObserver)
      }
    }
  }

  //····················································································································

  final func removeEBObserverOf_mX (_ inObserver : EBEvent) {
    self.removeEBObserver (inObserver)
    self.mObserversOf_mX.remove (inObserver)
    switch self.selection {
    case .empty, .multiple :
      break
    case .single (let v) :
      for managedObject in v {
        managedObject.mX_property.removeEBObserver (inObserver)
      }
    }
  }

  //····················································································································

  final func addEBObserversOf_mX_toElementsOfSet (_ inSet : EBReferenceSet <CommentInSchematic>) {
    if !self.mObserversOf_mX.isEmpty {
      for managedObject in inSet.values {
        self.mObserversOf_mX.apply { (_ observer : EBEvent) in
          managedObject.mX_property.addEBObserver (observer)
        }
      }
    }
  }

  //····················································································································

  final func removeEBObserversOf_mX_fromElementsOfSet (_ inSet : EBReferenceSet <CommentInSchematic>) {
    self.mObserversOf_mX.apply { (_ observer : EBEvent) in
      observer.postEvent ()
      for managedObject in inSet.values {
        managedObject.mX_property.removeEBObserver (observer)
      }
    }
  }

  //····················································································································
  //   Observers of 'mY' stored property
  //····················································································································

  private final var mObserversOf_mY = EBWeakEventSet ()

  //····················································································································

  final func addEBObserverOf_mY (_ inObserver : EBEvent) {
    self.addEBObserver (inObserver)
    self.mObserversOf_mY.insert (inObserver)
    switch self.selection {
    case .empty, .multiple :
      break
    case .single (let v) :
      for managedObject in v {
        managedObject.mY_property.addEBObserver (inObserver)
      }
    }
  }

  //····················································································································

  final func removeEBObserverOf_mY (_ inObserver : EBEvent) {
    self.removeEBObserver (inObserver)
    self.mObserversOf_mY.remove (inObserver)
    switch self.selection {
    case .empty, .multiple :
      break
    case .single (let v) :
      for managedObject in v {
        managedObject.mY_property.removeEBObserver (inObserver)
      }
    }
  }

  //····················································································································

  final func addEBObserversOf_mY_toElementsOfSet (_ inSet : EBReferenceSet <CommentInSchematic>) {
    if !self.mObserversOf_mY.isEmpty {
      for managedObject in inSet.values {
        self.mObserversOf_mY.apply { (_ observer : EBEvent) in
          managedObject.mY_property.addEBObserver (observer)
        }
      }
    }
  }

  //····················································································································

  final func removeEBObserversOf_mY_fromElementsOfSet (_ inSet : EBReferenceSet <CommentInSchematic>) {
    self.mObserversOf_mY.apply { (_ observer : EBEvent) in
      observer.postEvent ()
      for managedObject in inSet.values {
        managedObject.mY_property.removeEBObserver (observer)
      }
    }
  }

  //····················································································································
  //   Observers of 'mComment' stored property
  //····················································································································

  private final var mObserversOf_mComment = EBWeakEventSet ()

  //····················································································································

  final func addEBObserverOf_mComment (_ inObserver : EBEvent) {
    self.addEBObserver (inObserver)
    self.mObserversOf_mComment.insert (inObserver)
    switch self.selection {
    case .empty, .multiple :
      break
    case .single (let v) :
      for managedObject in v {
        managedObject.mComment_property.addEBObserver (inObserver)
      }
    }
  }

  //····················································································································

  final func removeEBObserverOf_mComment (_ inObserver : EBEvent) {
    self.removeEBObserver (inObserver)
    self.mObserversOf_mComment.remove (inObserver)
    switch self.selection {
    case .empty, .multiple :
      break
    case .single (let v) :
      for managedObject in v {
        managedObject.mComment_property.removeEBObserver (inObserver)
      }
    }
  }

  //····················································································································

  final func addEBObserversOf_mComment_toElementsOfSet (_ inSet : EBReferenceSet <CommentInSchematic>) {
    if !self.mObserversOf_mComment.isEmpty {
      for managedObject in inSet.values {
        self.mObserversOf_mComment.apply { (_ observer : EBEvent) in
          managedObject.mComment_property.addEBObserver (observer)
        }
      }
    }
  }

  //····················································································································

  final func removeEBObserversOf_mComment_fromElementsOfSet (_ inSet : EBReferenceSet <CommentInSchematic>) {
    self.mObserversOf_mComment.apply { (_ observer : EBEvent) in
      observer.postEvent ()
      for managedObject in inSet.values {
        managedObject.mComment_property.removeEBObserver (observer)
      }
    }
  }

  //····················································································································
  //   Observers of 'objectDisplay' transient property
  //····················································································································

  private final var mObserversOf_objectDisplay = EBWeakEventSet ()

  //····················································································································

  final func addEBObserverOf_objectDisplay (_ inObserver : EBEvent) {
    self.addEBObserver (inObserver)
    self.mObserversOf_objectDisplay.insert (inObserver)
    switch self.selection {
    case .empty, .multiple :
      break
    case .single (let v) :
      for managedObject in v {
        managedObject.objectDisplay_property.addEBObserver (inObserver)
      }
    }
  }

  //····················································································································

  final func removeEBObserverOf_objectDisplay (_ inObserver : EBEvent) {
    self.removeEBObserver (inObserver)
    self.mObserversOf_objectDisplay.remove (inObserver)
    switch self.selection {
    case .empty, .multiple :
      break
    case .single (let v) :
      for managedObject in v {
        managedObject.objectDisplay_property.removeEBObserver (inObserver)
      }
    }
  }

  //····················································································································

  final func addEBObserversOf_objectDisplay_toElementsOfSet (_ inSet : EBReferenceSet <CommentInSchematic>) {
    for managedObject in inSet.values {
      self.mObserversOf_objectDisplay.apply { (_ observer : EBEvent) in
        managedObject.objectDisplay_property.addEBObserver (observer)
      }
    }
  }

  //····················································································································

  final func removeEBObserversOf_objectDisplay_fromElementsOfSet (_ inSet : EBReferenceSet <CommentInSchematic>) {
    for managedObject in inSet.values {
      self.mObserversOf_objectDisplay.apply { (_ observer : EBEvent) in
        managedObject.objectDisplay_property.removeEBObserver (observer)
      }
    }
  }

  //····················································································································
  //   Observers of 'selectionDisplay' transient property
  //····················································································································

  private final var mObserversOf_selectionDisplay = EBWeakEventSet ()

  //····················································································································

  final func addEBObserverOf_selectionDisplay (_ inObserver : EBEvent) {
    self.addEBObserver (inObserver)
    self.mObserversOf_selectionDisplay.insert (inObserver)
    switch self.selection {
    case .empty, .multiple :
      break
    case .single (let v) :
      for managedObject in v {
        managedObject.selectionDisplay_property.addEBObserver (inObserver)
      }
    }
  }

  //····················································································································

  final func removeEBObserverOf_selectionDisplay (_ inObserver : EBEvent) {
    self.removeEBObserver (inObserver)
    self.mObserversOf_selectionDisplay.remove (inObserver)
    switch self.selection {
    case .empty, .multiple :
      break
    case .single (let v) :
      for managedObject in v {
        managedObject.selectionDisplay_property.removeEBObserver (inObserver)
      }
    }
  }

  //····················································································································

  final func addEBObserversOf_selectionDisplay_toElementsOfSet (_ inSet : EBReferenceSet <CommentInSchematic>) {
    for managedObject in inSet.values {
      self.mObserversOf_selectionDisplay.apply { (_ observer : EBEvent) in
        managedObject.selectionDisplay_property.addEBObserver (observer)
      }
    }
  }

  //····················································································································

  final func removeEBObserversOf_selectionDisplay_fromElementsOfSet (_ inSet : EBReferenceSet <CommentInSchematic>) {
    for managedObject in inSet.values {
      self.mObserversOf_selectionDisplay.apply { (_ observer : EBEvent) in
        managedObject.selectionDisplay_property.removeEBObserver (observer)
      }
    }
  }

  //····················································································································

}

//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
//    TransientArrayOf CommentInSchematic
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

final class TransientArrayOf_CommentInSchematic : ReadOnlyArrayOf_CommentInSchematic {

  //····················································································································
  //   Sort
  //····················································································································

  private var mIsOrderedBefore : Optional < (_ left : CommentInSchematic, _ right : CommentInSchematic) -> Bool > = nil
  private var mSortObserver : EBModelNotifierEvent? = nil
  private var mModelEvent = EBModelEvent ()

  //····················································································································

  override init () {
    super.init ()
    self.mModelEvent.mEventCallBack = { [weak self] in self?.computeModelArray () }
  }

  //····················································································································
  //   Data provider
  //····················································································································

  private var mDataProvider : ReadOnlyArrayOf_CommentInSchematic? = nil
  private var mTransientKind : PropertyKind = .empty
  private var mModelArrayShouldBeComputed = true

  //····················································································································

  func setDataProvider (_ inProvider : ReadOnlyArrayOf_CommentInSchematic,
                        sortCallback inSortCallBack : Optional < (_ left : CommentInSchematic, _ right : CommentInSchematic) -> Bool >,
                        addSortObserversCallback inAddSortObserversCallback : (EBModelNotifierEvent) -> Void,
                        removeSortObserversCallback inRemoveSortObserversCallback : @escaping (EBModelNotifierEvent) -> Void) {
    if self.mDataProvider !== inProvider {
      self.mSortObserver?.removeSortObservers ()
      self.mSortObserver = nil
      self.mDataProvider?.detachClient (self)
      self.mDataProvider = inProvider
      self.mIsOrderedBefore = inSortCallBack
      self.mDataProvider?.attachClient (self)
      if inSortCallBack != nil {
        self.mSortObserver = EBModelNotifierEvent (
          self,
          addSortObserversCallback: inAddSortObserversCallback,
          removeSortObserversCallback: inRemoveSortObserversCallback
        )
      }else{
        self.mInternalArrayValue = EBReferenceArray ()
      }
    }
  }

  //····················································································································

  func resetDataProvider () {
    if self.mDataProvider != nil {
      self.mSortObserver = nil
      self.mDataProvider?.detachClient (self)
      self.mDataProvider = nil
      self.mIsOrderedBefore = nil
    }
  }

  //····················································································································

  override func notifyModelDidChange () {
    self.mModelEvent.postEvent ()
    self.mModelArrayShouldBeComputed = true
    super.notifyModelDidChange ()
  }

  //····················································································································

  private final func computeModelArray () {
    if self.mModelArrayShouldBeComputed {
      self.mModelArrayShouldBeComputed = false
      let newArray : EBReferenceArray <CommentInSchematic>
      if let dataProvider = self.mDataProvider {
        switch dataProvider.selection {
        case .empty :
          newArray = EBReferenceArray ()
          self.mTransientKind = .empty
        case .single (let v) :
          if let sortFunction = self.mIsOrderedBefore {
            newArray = EBReferenceArray (v.sorted { sortFunction ($0, $1) })
          }else{
            newArray = EBReferenceArray (v)
          }
          self.mTransientKind = .single
        case .multiple :
          newArray = EBReferenceArray ()
          self.mTransientKind = .multiple
        }
      }else{
        newArray = EBReferenceArray ()
        self.mTransientKind = .empty
      }
      self.mInternalArrayValue = newArray
    }
  }

  //····················································································································

  override var selection : EBSelection < [CommentInSchematic] > {
    self.computeModelArray ()
    switch self.mTransientKind {
    case .empty :
      return .empty
    case .single :
      return .single (self.mInternalArrayValue.values)
    case .multiple :
      return .multiple
    }
  }

  //····················································································································

  override var propval : EBReferenceArray <CommentInSchematic> {
    self.computeModelArray ()
    return self.mInternalArrayValue
  }

  //····················································································································

}

//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
//    TransientArrayOfSuperOf CommentInSchematic
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

final class TransientArrayOfSuperOf_CommentInSchematic <SUPER : EBManagedObject> : ReadOnlyArrayOf_CommentInSchematic {

  //····················································································································
  //   Data provider
  //····················································································································

  private var mDataProvider : ReadOnlyAbstractArrayProperty <SUPER>? = nil
  private var mTransientKind : PropertyKind = .empty
  private var mModelArrayShouldBeComputed = true
  private var mModelEvent = EBModelEvent ()

  //····················································································································

  override init () {
    super.init ()
    self.mModelEvent.mEventCallBack = { [weak self] in self?.computeModelArray () }
  }

  //····················································································································

  func setDataProvider (_ inProvider : ReadOnlyAbstractArrayProperty <SUPER>?) {
    if self.mDataProvider !== inProvider {
      self.mDataProvider?.detachClient (self)
      self.mDataProvider = inProvider
      self.mDataProvider?.attachClient (self)
    }
  }

  //····················································································································

  override func notifyModelDidChange () {
    self.mModelEvent.postEvent ()
    self.mModelArrayShouldBeComputed = true
    super.notifyModelDidChange ()
  }

  //····················································································································

  private final func computeModelArray () {
    if self.mModelArrayShouldBeComputed {
      self.mModelArrayShouldBeComputed = false
      var newModelArray : EBReferenceArray <SUPER>
      if let dataProvider = self.mDataProvider {
        switch dataProvider.selection {
        case .empty :
          newModelArray = EBReferenceArray ()
          self.mTransientKind = .empty
        case .single (let v) :
          newModelArray = EBReferenceArray (v)
          self.mTransientKind = .single
         case .multiple :
          newModelArray = EBReferenceArray ()
          self.mTransientKind = .multiple
        }
      }else{
        newModelArray = EBReferenceArray ()
        self.mTransientKind = .empty
      }
      var newArray = EBReferenceArray <CommentInSchematic> ()
      for superObject in newModelArray.values {
        if let object = superObject as? CommentInSchematic {
          newArray.append (object)
        }
      }
      self.mInternalArrayValue = newArray
    }
  }

  //····················································································································

  override var selection : EBSelection < [CommentInSchematic] > {
    self.computeModelArray ()
    switch self.mTransientKind {
    case .empty :
      return .empty
    case .single :
      return .single (self.mInternalArrayValue.values)
    case .multiple :
      return .multiple
    }
  }

  //····················································································································

  override var propval : EBReferenceArray <CommentInSchematic> {
    self.computeModelArray ()
    return self.mInternalArrayValue
  }

  //····················································································································

}

//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
//    To many relationship read write: CommentInSchematic
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

class ReadWriteArrayOf_CommentInSchematic : ReadOnlyArrayOf_CommentInSchematic {

  //····················································································································

  func setProp (_ value :  EBReferenceArray <CommentInSchematic>) { } // Abstract method

  //····················································································································

}

//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
//    Proxy: ProxyArrayOf_CommentInSchematic
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

final class ProxyArrayOf_CommentInSchematic : ReadWriteArrayOf_CommentInSchematic {

  //····················································································································

  private var mModel : ReadWriteArrayOf_CommentInSchematic? = nil

  //····················································································································

  func setModel (_ inModel : ReadWriteArrayOf_CommentInSchematic?) {
    if self.mModel !== inModel {
      self.mModel?.detachClient (self)
      self.mModel = inModel
      self.mModel?.attachClient (self)
    }
  }

  //····················································································································

  override func notifyModelDidChange () {
    let newModelArray : EBReferenceArray <CommentInSchematic>
    if let model = self.mModel {
      switch model.selection {
      case .empty :
        newModelArray = EBReferenceArray ()
      case .single (let v) :
        newModelArray = EBReferenceArray <CommentInSchematic> (v)
      case .multiple :
        newModelArray = EBReferenceArray ()
      }
    }else{
      newModelArray = EBReferenceArray ()
    }
    self.mInternalArrayValue = newModelArray
    super.notifyModelDidChange ()
  }

  //····················································································································

  override func setProp (_ inArrayValue : EBReferenceArray <CommentInSchematic>) {
    self.mModel?.setProp (inArrayValue)
  }

  //····················································································································

  override var selection : EBSelection < [CommentInSchematic] > {
    if let model = self.mModel {
      return model.selection
    }else{
      return .empty
    }
  }

  //····················································································································

  override var propval : EBReferenceArray <CommentInSchematic> {
    if let model = self.mModel {
      switch model.selection {
      case .empty, .multiple :
        return EBReferenceArray ()
      case .single (let v) :
        return EBReferenceArray (v)
      }
    }else{
      return EBReferenceArray ()
    }
  }

  //····················································································································

}

//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
//    Stored Array: CommentInSchematic
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

class StoredArrayOf_CommentInSchematic : ReadWriteArrayOf_CommentInSchematic, EBSignatureObserverProtocol {

  //····················································································································

  init (usedForSignature inUsedForSignature : Bool) {
    self.mUsedForSignature = inUsedForSignature
    super.init ()
  }

  //····················································································································
  //   Signature ?
  //····················································································································

  private final let mUsedForSignature : Bool

  //····················································································································
  //   Undo manager
  //····················································································································

  weak final var ebUndoManager : EBUndoManager? = nil // SOULD BE WEAK

  //····················································································································
  //   Opposite relationship management
  //····················································································································

  private final var mSetOppositeRelationship : Optional < (_ inManagedObject : CommentInSchematic) -> Void > = nil
  private final var mResetOppositeRelationship : Optional < (_ inManagedObject : CommentInSchematic) -> Void > = nil

  //····················································································································

  final func setOppositeRelationShipFunctions (setter inSetter : @escaping (_ inManagedObject : CommentInSchematic) -> Void,
                                               resetter inResetter : @escaping (_ inManagedObject : CommentInSchematic) -> Void) {
    self.mSetOppositeRelationship = inSetter
    self.mResetOppositeRelationship = inResetter
  }

  //····················································································································

  #if BUILD_OBJECT_EXPLORER
    final var mValueExplorer : NSPopUpButton? {
      didSet {
        if let unwrappedExplorer = self.mValueExplorer {
          switch self.selection {
          case .empty, .multiple :
            break ;
          case .single (let v) :
            updateManagedObjectToManyRelationshipDisplay (objectArray: v, popUpButton: unwrappedExplorer)
          }
        }
      }
    }
  #endif

  //····················································································································
  // Model will change
  //····················································································································

  override func notifyModelDidChangeFrom (oldValue inOldValue : EBReferenceArray <CommentInSchematic>) {
  //--- Register old value in undo manager
    self.ebUndoManager?.registerUndo (withTarget: self) { $0.mInternalArrayValue = inOldValue }
  //---
    super.notifyModelDidChangeFrom (oldValue: inOldValue)
  }

  //····················································································································
  // Model did change
  //····················································································································

  override func notifyModelDidChange () {
  //--- Update explorer
    #if BUILD_OBJECT_EXPLORER
      if let valueExplorer = self.mValueExplorer {
        updateManagedObjectToManyRelationshipDisplay (objectArray: self.mInternalArrayValue.values, popUpButton: valueExplorer)
      }
    #endif
  //--- Notify observers
    self.postEvent ()
  //---
    super.notifyModelDidChange ()
  }

  //····················································································································
  // Update observers
  //····················································································································

  override func updateObservers (removedSet inRemovedSet : EBReferenceSet <CommentInSchematic>,
                                 addedSet inAddedSet : EBReferenceSet <CommentInSchematic>) {
    for managedObject in inRemovedSet.values {
      if self.mUsedForSignature {
        managedObject.setSignatureObserver (observer: nil)
      }
      self.mResetOppositeRelationship? (managedObject)
   }
  //---
    for managedObject in inAddedSet.values {
      if self.mUsedForSignature {
        managedObject.setSignatureObserver (observer: self)
      }
      self.mSetOppositeRelationship? (managedObject)
    }
  //---
    super.updateObservers (removedSet: inRemovedSet, addedSet: inAddedSet)
 }

  //····················································································································

  override final var selection : EBSelection < [CommentInSchematic] > { return .single (self.mInternalArrayValue.values) }

  //····················································································································

  override func setProp (_ inValue : EBReferenceArray <CommentInSchematic>) { self.mInternalArrayValue = inValue }

  //····················································································································

  override final var propval : EBReferenceArray <CommentInSchematic> { return self.mInternalArrayValue }

  //····················································································································

  final func remove (_ object : CommentInSchematic) {
    if let idx = self.mInternalArrayValue.firstIndex (of: object) {
      self.mInternalArrayValue.remove (at: idx)
    }
  }

  //····················································································································

  final func add (_ object : CommentInSchematic) {
    if !self.internalSetValue.contains (object) {
      self.mInternalArrayValue.append (object)
    }
  }

  //····················································································································
  //   signature
  //····················································································································

  private weak final var mSignatureObserver : EBSignatureObserverProtocol? = nil // SOULD BE WEAK

  //····················································································································

  private final var mSignatureCache : UInt32? = nil

  //····················································································································

  final func setSignatureObserver (observer : EBSignatureObserverProtocol?) {
    self.mSignatureObserver?.clearSignatureCache ()
    self.mSignatureObserver = observer
    observer?.clearSignatureCache ()
    self.clearSignatureCache ()
 }

  //····················································································································

  final func signature () -> UInt32 {
    let computedSignature : UInt32
    if let s = self.mSignatureCache {
      computedSignature = s
    }else{
      computedSignature = self.computeSignature ()
      self.mSignatureCache = computedSignature
    }
    return computedSignature
  }

  //····················································································································

  final private func computeSignature () -> UInt32 {
    var crc : UInt32 = 0
    for object in self.mInternalArrayValue.values {
      crc.accumulateUInt32 (object.signature ())
    }
    return crc
  }

  //····················································································································

  final func clearSignatureCache () {
    if self.mSignatureCache != nil {
      self.mSignatureCache = nil
      self.mSignatureObserver?.clearSignatureCache ()
    }
  }

  //····················································································································

}

//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
//    Stand alone Array: CommentInSchematic
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

final class StandAloneArrayOf_CommentInSchematic : ReadWriteArrayOf_CommentInSchematic {

  //····················································································································

  override var selection : EBSelection < [CommentInSchematic] > { return .single (self.mInternalArrayValue.values) }

  //····················································································································

  override func setProp (_ inValue : EBReferenceArray <CommentInSchematic>) { self.mInternalArrayValue = inValue }

  //····················································································································

  override var propval : EBReferenceArray <CommentInSchematic> { return self.mInternalArrayValue }

  //····················································································································

  override func notifyModelDidChange () {
    self.postEvent ()
    super.notifyModelDidChange ()
  }

  //····················································································································

  func remove (_ object : CommentInSchematic) {
    if let idx = self.mInternalArrayValue.firstIndex (of: object) {
      self.mInternalArrayValue.remove (at: idx)
    }
  }

  //····················································································································

  func add (_ object : CommentInSchematic) {
    if !self.internalSetValue.contains (object) {
      self.mInternalArrayValue.append (object)
    }
  }

  //····················································································································

}

//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
//    Preferences array: CommentInSchematic
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

final class PreferencesArrayOf_CommentInSchematic : StoredArrayOf_CommentInSchematic {

  //····················································································································

  private let mPrefKey : String
  private let mObserverForWritingPreferences = EBOutletEvent ()

  //····················································································································

  init (prefKey : String) {
    self.mPrefKey = prefKey
    super.init (usedForSignature: false)
    if let array = UserDefaults.standard.array (forKey: prefKey) as? [NSDictionary] {
      var objectArray = EBReferenceArray <CommentInSchematic> ()
      for dictionary in array {
        if let object = newInstanceOfEntityNamed (self.ebUndoManager, "CommentInSchematic") as? CommentInSchematic {
          object.setUpAtomicPropertiesWithDictionary (dictionary)
          objectArray.append (object)
        }
      }
      self.setProp (objectArray)
    }
    self.addEBObserverOf_mColor (self.mObserverForWritingPreferences)
    self.addEBObserverOf_mSize (self.mObserverForWritingPreferences)
    self.addEBObserverOf_mHorizontalAlignment (self.mObserverForWritingPreferences)
    self.addEBObserverOf_mVerticalAlignment (self.mObserverForWritingPreferences)
    self.addEBObserverOf_mX (self.mObserverForWritingPreferences)
    self.addEBObserverOf_mY (self.mObserverForWritingPreferences)
    self.addEBObserverOf_mComment (self.mObserverForWritingPreferences)
    self.mObserverForWritingPreferences.mEventCallBack = { self.writeInPreferences () }
 }

  //····················································································································

  private func writeInPreferences () {
    var dictionaryArray = [NSDictionary] ()
    for object in self.mInternalArrayValue.values {
      let d = NSMutableDictionary ()
      object.saveIntoDictionary (d)
      d [ENTITY_KEY] = nil // Remove entity key, not used in preferences
      dictionaryArray.append (d)
    }
    UserDefaults.standard.set (dictionaryArray, forKey: self.mPrefKey)
  }

  //····················································································································

}

//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

