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

import Cocoa

//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
//    ReadOnlyArrayOf_SymbolPinTypeInDevice
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

class ReadOnlyArrayOf_SymbolPinTypeInDevice : ReadOnlyAbstractArrayProperty <SymbolPinTypeInDevice> {

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

  internal override func updateObservers (removedSet inRemovedSet : EBReferenceSet <SymbolPinTypeInDevice>,
                                          addedSet inAddedSet : EBReferenceSet <SymbolPinTypeInDevice>) {
    super.updateObservers (removedSet: inRemovedSet, addedSet: inAddedSet)
  //--- Remove observers from removed objects
    if !inRemovedSet.isEmpty {
      self.removeEBObserversOf_mPinX_fromElementsOfSet (inRemovedSet) // Stored property
      self.removeEBObserversOf_mPinY_fromElementsOfSet (inRemovedSet) // Stored property
      self.removeEBObserversOf_mXName_fromElementsOfSet (inRemovedSet) // Stored property
      self.removeEBObserversOf_mYName_fromElementsOfSet (inRemovedSet) // Stored property
      self.removeEBObserversOf_mName_fromElementsOfSet (inRemovedSet) // Stored property
      self.removeEBObserversOf_mNameHorizontalAlignment_fromElementsOfSet (inRemovedSet) // Stored property
      self.removeEBObserversOf_mPinNameIsDisplayedInSchematics_fromElementsOfSet (inRemovedSet) // Stored property
      self.removeEBObserversOf_mXNumber_fromElementsOfSet (inRemovedSet) // Stored property
      self.removeEBObserversOf_mYNumber_fromElementsOfSet (inRemovedSet) // Stored property
      self.removeEBObserversOf_mNumberHorizontalAlignment_fromElementsOfSet (inRemovedSet) // Stored property
      self.removeEBObserversOf_nameShape_fromElementsOfSet (inRemovedSet) // Transient property
    }
  //--- Add observers to added objects
    if !inAddedSet.isEmpty {
      self.addEBObserversOf_mPinX_toElementsOfSet (inAddedSet) // Stored property
      self.addEBObserversOf_mPinY_toElementsOfSet (inAddedSet) // Stored property
      self.addEBObserversOf_mXName_toElementsOfSet (inAddedSet) // Stored property
      self.addEBObserversOf_mYName_toElementsOfSet (inAddedSet) // Stored property
      self.addEBObserversOf_mName_toElementsOfSet (inAddedSet) // Stored property
      self.addEBObserversOf_mNameHorizontalAlignment_toElementsOfSet (inAddedSet) // Stored property
      self.addEBObserversOf_mPinNameIsDisplayedInSchematics_toElementsOfSet (inAddedSet) // Stored property
      self.addEBObserversOf_mXNumber_toElementsOfSet (inAddedSet) // Stored property
      self.addEBObserversOf_mYNumber_toElementsOfSet (inAddedSet) // Stored property
      self.addEBObserversOf_mNumberHorizontalAlignment_toElementsOfSet (inAddedSet) // Stored property
      self.addEBObserversOf_nameShape_toElementsOfSet (inAddedSet) // Transient property
   }
  }

  //····················································································································
  //   Observers of 'mPinX' stored property
  //····················································································································

  private final var mObserversOf_mPinX = EBWeakEventSet ()

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

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

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

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

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

  final func addEBObserversOf_mPinX_toElementsOfSet (_ inSet : EBReferenceSet <SymbolPinTypeInDevice>) {
    if !self.mObserversOf_mPinX.isEmpty {
      for managedObject in inSet.values {
        self.mObserversOf_mPinX.apply { (_ observer : EBEvent) in
          managedObject.mPinX_property.addEBObserver (observer)
        }
      }
    }
  }

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

  final func removeEBObserversOf_mPinX_fromElementsOfSet (_ inSet : EBReferenceSet <SymbolPinTypeInDevice>) {
    self.mObserversOf_mPinX.apply { (_ observer : EBEvent) in
      observer.postEvent ()
      for managedObject in inSet.values {
        managedObject.mPinX_property.removeEBObserver (observer)
      }
    }
  }

  //····················································································································
  //   Observers of 'mPinY' stored property
  //····················································································································

  private final var mObserversOf_mPinY = EBWeakEventSet ()

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

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

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

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

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

  final func addEBObserversOf_mPinY_toElementsOfSet (_ inSet : EBReferenceSet <SymbolPinTypeInDevice>) {
    if !self.mObserversOf_mPinY.isEmpty {
      for managedObject in inSet.values {
        self.mObserversOf_mPinY.apply { (_ observer : EBEvent) in
          managedObject.mPinY_property.addEBObserver (observer)
        }
      }
    }
  }

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

  final func removeEBObserversOf_mPinY_fromElementsOfSet (_ inSet : EBReferenceSet <SymbolPinTypeInDevice>) {
    self.mObserversOf_mPinY.apply { (_ observer : EBEvent) in
      observer.postEvent ()
      for managedObject in inSet.values {
        managedObject.mPinY_property.removeEBObserver (observer)
      }
    }
  }

  //····················································································································
  //   Observers of 'mXName' stored property
  //····················································································································

  private final var mObserversOf_mXName = EBWeakEventSet ()

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

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

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

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

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

  final func addEBObserversOf_mXName_toElementsOfSet (_ inSet : EBReferenceSet <SymbolPinTypeInDevice>) {
    if !self.mObserversOf_mXName.isEmpty {
      for managedObject in inSet.values {
        self.mObserversOf_mXName.apply { (_ observer : EBEvent) in
          managedObject.mXName_property.addEBObserver (observer)
        }
      }
    }
  }

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

  final func removeEBObserversOf_mXName_fromElementsOfSet (_ inSet : EBReferenceSet <SymbolPinTypeInDevice>) {
    self.mObserversOf_mXName.apply { (_ observer : EBEvent) in
      observer.postEvent ()
      for managedObject in inSet.values {
        managedObject.mXName_property.removeEBObserver (observer)
      }
    }
  }

  //····················································································································
  //   Observers of 'mYName' stored property
  //····················································································································

  private final var mObserversOf_mYName = EBWeakEventSet ()

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

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

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

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

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

  final func addEBObserversOf_mYName_toElementsOfSet (_ inSet : EBReferenceSet <SymbolPinTypeInDevice>) {
    if !self.mObserversOf_mYName.isEmpty {
      for managedObject in inSet.values {
        self.mObserversOf_mYName.apply { (_ observer : EBEvent) in
          managedObject.mYName_property.addEBObserver (observer)
        }
      }
    }
  }

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

  final func removeEBObserversOf_mYName_fromElementsOfSet (_ inSet : EBReferenceSet <SymbolPinTypeInDevice>) {
    self.mObserversOf_mYName.apply { (_ observer : EBEvent) in
      observer.postEvent ()
      for managedObject in inSet.values {
        managedObject.mYName_property.removeEBObserver (observer)
      }
    }
  }

  //····················································································································
  //   Observers of 'mName' stored property
  //····················································································································

  private final var mObserversOf_mName = EBWeakEventSet ()

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

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

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

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

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

  final func addEBObserversOf_mName_toElementsOfSet (_ inSet : EBReferenceSet <SymbolPinTypeInDevice>) {
    if !self.mObserversOf_mName.isEmpty {
      for managedObject in inSet.values {
        self.mObserversOf_mName.apply { (_ observer : EBEvent) in
          managedObject.mName_property.addEBObserver (observer)
        }
      }
    }
  }

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

  final func removeEBObserversOf_mName_fromElementsOfSet (_ inSet : EBReferenceSet <SymbolPinTypeInDevice>) {
    self.mObserversOf_mName.apply { (_ observer : EBEvent) in
      observer.postEvent ()
      for managedObject in inSet.values {
        managedObject.mName_property.removeEBObserver (observer)
      }
    }
  }

  //····················································································································
  //   Observers of 'mNameHorizontalAlignment' stored property
  //····················································································································

  private final var mObserversOf_mNameHorizontalAlignment = EBWeakEventSet ()

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

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

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

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

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

  final func addEBObserversOf_mNameHorizontalAlignment_toElementsOfSet (_ inSet : EBReferenceSet <SymbolPinTypeInDevice>) {
    if !self.mObserversOf_mNameHorizontalAlignment.isEmpty {
      for managedObject in inSet.values {
        self.mObserversOf_mNameHorizontalAlignment.apply { (_ observer : EBEvent) in
          managedObject.mNameHorizontalAlignment_property.addEBObserver (observer)
        }
      }
    }
  }

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

  final func removeEBObserversOf_mNameHorizontalAlignment_fromElementsOfSet (_ inSet : EBReferenceSet <SymbolPinTypeInDevice>) {
    self.mObserversOf_mNameHorizontalAlignment.apply { (_ observer : EBEvent) in
      observer.postEvent ()
      for managedObject in inSet.values {
        managedObject.mNameHorizontalAlignment_property.removeEBObserver (observer)
      }
    }
  }

  //····················································································································
  //   Observers of 'mPinNameIsDisplayedInSchematics' stored property
  //····················································································································

  private final var mObserversOf_mPinNameIsDisplayedInSchematics = EBWeakEventSet ()

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

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

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

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

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

  final func addEBObserversOf_mPinNameIsDisplayedInSchematics_toElementsOfSet (_ inSet : EBReferenceSet <SymbolPinTypeInDevice>) {
    if !self.mObserversOf_mPinNameIsDisplayedInSchematics.isEmpty {
      for managedObject in inSet.values {
        self.mObserversOf_mPinNameIsDisplayedInSchematics.apply { (_ observer : EBEvent) in
          managedObject.mPinNameIsDisplayedInSchematics_property.addEBObserver (observer)
        }
      }
    }
  }

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

  final func removeEBObserversOf_mPinNameIsDisplayedInSchematics_fromElementsOfSet (_ inSet : EBReferenceSet <SymbolPinTypeInDevice>) {
    self.mObserversOf_mPinNameIsDisplayedInSchematics.apply { (_ observer : EBEvent) in
      observer.postEvent ()
      for managedObject in inSet.values {
        managedObject.mPinNameIsDisplayedInSchematics_property.removeEBObserver (observer)
      }
    }
  }

  //····················································································································
  //   Observers of 'mXNumber' stored property
  //····················································································································

  private final var mObserversOf_mXNumber = EBWeakEventSet ()

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

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

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

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

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

  final func addEBObserversOf_mXNumber_toElementsOfSet (_ inSet : EBReferenceSet <SymbolPinTypeInDevice>) {
    if !self.mObserversOf_mXNumber.isEmpty {
      for managedObject in inSet.values {
        self.mObserversOf_mXNumber.apply { (_ observer : EBEvent) in
          managedObject.mXNumber_property.addEBObserver (observer)
        }
      }
    }
  }

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

  final func removeEBObserversOf_mXNumber_fromElementsOfSet (_ inSet : EBReferenceSet <SymbolPinTypeInDevice>) {
    self.mObserversOf_mXNumber.apply { (_ observer : EBEvent) in
      observer.postEvent ()
      for managedObject in inSet.values {
        managedObject.mXNumber_property.removeEBObserver (observer)
      }
    }
  }

  //····················································································································
  //   Observers of 'mYNumber' stored property
  //····················································································································

  private final var mObserversOf_mYNumber = EBWeakEventSet ()

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

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

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

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

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

  final func addEBObserversOf_mYNumber_toElementsOfSet (_ inSet : EBReferenceSet <SymbolPinTypeInDevice>) {
    if !self.mObserversOf_mYNumber.isEmpty {
      for managedObject in inSet.values {
        self.mObserversOf_mYNumber.apply { (_ observer : EBEvent) in
          managedObject.mYNumber_property.addEBObserver (observer)
        }
      }
    }
  }

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

  final func removeEBObserversOf_mYNumber_fromElementsOfSet (_ inSet : EBReferenceSet <SymbolPinTypeInDevice>) {
    self.mObserversOf_mYNumber.apply { (_ observer : EBEvent) in
      observer.postEvent ()
      for managedObject in inSet.values {
        managedObject.mYNumber_property.removeEBObserver (observer)
      }
    }
  }

  //····················································································································
  //   Observers of 'mNumberHorizontalAlignment' stored property
  //····················································································································

  private final var mObserversOf_mNumberHorizontalAlignment = EBWeakEventSet ()

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

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

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

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

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

  final func addEBObserversOf_mNumberHorizontalAlignment_toElementsOfSet (_ inSet : EBReferenceSet <SymbolPinTypeInDevice>) {
    if !self.mObserversOf_mNumberHorizontalAlignment.isEmpty {
      for managedObject in inSet.values {
        self.mObserversOf_mNumberHorizontalAlignment.apply { (_ observer : EBEvent) in
          managedObject.mNumberHorizontalAlignment_property.addEBObserver (observer)
        }
      }
    }
  }

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

  final func removeEBObserversOf_mNumberHorizontalAlignment_fromElementsOfSet (_ inSet : EBReferenceSet <SymbolPinTypeInDevice>) {
    self.mObserversOf_mNumberHorizontalAlignment.apply { (_ observer : EBEvent) in
      observer.postEvent ()
      for managedObject in inSet.values {
        managedObject.mNumberHorizontalAlignment_property.removeEBObserver (observer)
      }
    }
  }

  //····················································································································
  //   Observers of 'nameShape' transient property
  //····················································································································

  private final var mObserversOf_nameShape = EBWeakEventSet ()

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

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

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

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

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

  final func addEBObserversOf_nameShape_toElementsOfSet (_ inSet : EBReferenceSet <SymbolPinTypeInDevice>) {
    for managedObject in inSet.values {
      self.mObserversOf_nameShape.apply { (_ observer : EBEvent) in
        managedObject.nameShape_property.addEBObserver (observer)
      }
    }
  }

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

  final func removeEBObserversOf_nameShape_fromElementsOfSet (_ inSet : EBReferenceSet <SymbolPinTypeInDevice>) {
    for managedObject in inSet.values {
      self.mObserversOf_nameShape.apply { (_ observer : EBEvent) in
        managedObject.nameShape_property.removeEBObserver (observer)
      }
    }
  }

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

}

//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
//    TransientArrayOf SymbolPinTypeInDevice
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

final class TransientArrayOf_SymbolPinTypeInDevice : ReadOnlyArrayOf_SymbolPinTypeInDevice {

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

  private var mIsOrderedBefore : Optional < (_ left : SymbolPinTypeInDevice, _ right : SymbolPinTypeInDevice) -> 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_SymbolPinTypeInDevice? = nil
  private var mTransientKind : PropertyKind = .empty
  private var mModelArrayShouldBeComputed = true

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

  func setDataProvider (_ inProvider : ReadOnlyArrayOf_SymbolPinTypeInDevice,
                        sortCallback inSortCallBack : Optional < (_ left : SymbolPinTypeInDevice, _ right : SymbolPinTypeInDevice) -> 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 <SymbolPinTypeInDevice>
      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 < [SymbolPinTypeInDevice] > {
    self.computeModelArray ()
    switch self.mTransientKind {
    case .empty :
      return .empty
    case .single :
      return .single (self.mInternalArrayValue.values)
    case .multiple :
      return .multiple
    }
  }

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

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

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

}

//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
//    TransientArrayOfSuperOf SymbolPinTypeInDevice
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

final class TransientArrayOfSuperOf_SymbolPinTypeInDevice <SUPER : EBManagedObject> : ReadOnlyArrayOf_SymbolPinTypeInDevice {

  //····················································································································
  //   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 <SymbolPinTypeInDevice> ()
      for superObject in newModelArray.values {
        if let object = superObject as? SymbolPinTypeInDevice {
          newArray.append (object)
        }
      }
      self.mInternalArrayValue = newArray
    }
  }

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

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

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

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

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

}

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

class ReadWriteArrayOf_SymbolPinTypeInDevice : ReadOnlyArrayOf_SymbolPinTypeInDevice {

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

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

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

}

//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
//    Proxy: ProxyArrayOf_SymbolPinTypeInDevice
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

final class ProxyArrayOf_SymbolPinTypeInDevice : ReadWriteArrayOf_SymbolPinTypeInDevice {

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

  private var mModel : ReadWriteArrayOf_SymbolPinTypeInDevice? = nil

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

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

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

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

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

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

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

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

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

  override var propval : EBReferenceArray <SymbolPinTypeInDevice> {
    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: SymbolPinTypeInDevice
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

class StoredArrayOf_SymbolPinTypeInDevice : ReadWriteArrayOf_SymbolPinTypeInDevice, 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 : SymbolPinTypeInDevice) -> Void > = nil
  private final var mResetOppositeRelationship : Optional < (_ inManagedObject : SymbolPinTypeInDevice) -> Void > = nil

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

  final func setOppositeRelationShipFunctions (setter inSetter : @escaping (_ inManagedObject : SymbolPinTypeInDevice) -> Void,
                                               resetter inResetter : @escaping (_ inManagedObject : SymbolPinTypeInDevice) -> 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 <SymbolPinTypeInDevice>) {
  //--- 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 <SymbolPinTypeInDevice>,
                                 addedSet inAddedSet : EBReferenceSet <SymbolPinTypeInDevice>) {
    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 < [SymbolPinTypeInDevice] > { return .single (self.mInternalArrayValue.values) }

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

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

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

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

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

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

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

  final func add (_ object : SymbolPinTypeInDevice) {
    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: SymbolPinTypeInDevice
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

final class StandAloneArrayOf_SymbolPinTypeInDevice : ReadWriteArrayOf_SymbolPinTypeInDevice {

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

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

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

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

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

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

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

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

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

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

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

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

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

}

//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
//    Preferences array: SymbolPinTypeInDevice
//——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

final class PreferencesArrayOf_SymbolPinTypeInDevice : StoredArrayOf_SymbolPinTypeInDevice {

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

  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 <SymbolPinTypeInDevice> ()
      for dictionary in array {
        if let object = newInstanceOfEntityNamed (self.ebUndoManager, "SymbolPinTypeInDevice") as? SymbolPinTypeInDevice {
          object.setUpAtomicPropertiesWithDictionary (dictionary)
          objectArray.append (object)
        }
      }
      self.setProp (objectArray)
    }
    self.addEBObserverOf_mPinX (self.mObserverForWritingPreferences)
    self.addEBObserverOf_mPinY (self.mObserverForWritingPreferences)
    self.addEBObserverOf_mXName (self.mObserverForWritingPreferences)
    self.addEBObserverOf_mYName (self.mObserverForWritingPreferences)
    self.addEBObserverOf_mName (self.mObserverForWritingPreferences)
    self.addEBObserverOf_mNameHorizontalAlignment (self.mObserverForWritingPreferences)
    self.addEBObserverOf_mPinNameIsDisplayedInSchematics (self.mObserverForWritingPreferences)
    self.addEBObserverOf_mXNumber (self.mObserverForWritingPreferences)
    self.addEBObserverOf_mYNumber (self.mObserverForWritingPreferences)
    self.addEBObserverOf_mNumberHorizontalAlignment (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)
  }

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

}

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

