// // ComponentStorage.swift // FirebladeECS // // Created by Christian Treffs on 10.10.17. // /* public typealias ComponentIndex = Int public protocol ComponentStorage { @discardableResult func add(_ component: C) -> Bool func makeIterator(_ componentType: C.Type) -> AnyIterator func makeIterator(_ componentId: ComponentIdentifier) -> AnyIterator func has(_ component: C) -> Bool func has(_ componentType: C.Type) -> Bool func has(_ componentId: ComponentIdentifier) -> Bool func get(_ componentType: C.Type) -> Component? subscript(_ componentType: C.Type) -> Component? { get } func get(_ componentId: ComponentIdentifier) -> Component? subscript(_ componentId: ComponentIdentifier) -> Component? { get } @discardableResult func remove(_ component: C) -> Bool @discardableResult func remove(_ componentType: C.Type) -> Bool @discardableResult func remove(_ componentId: ComponentIdentifier) -> Bool func clear() } class GeneralComponentStorage: ComponentStorage { fileprivate var componentMap: [ComponentIdentifier: ContiguousArray] = [:] func add(_ component: C) -> Bool where C : Component { if var comps: ContiguousArray = componentMap[component.uct] { comps.append(component) } else { componentMap[component.uct] = ContiguousArray() componentMap[component.uct]!.append(component) } return true } func makeIterator(_ componentType: C.Type) -> AnyIterator where C : Component { fatalError() } func makeIterator(_ componentId: ComponentIdentifier) -> AnyIterator { fatalError() } func has(_ component: C) -> Bool where C : Component { fatalError() } func has(_ componentType: C.Type) -> Bool where C : Component { fatalError() } func has(_ componentId: ComponentIdentifier) -> Bool { fatalError() } func get(_ componentType: C.Type) -> Component? where C : Component { fatalError() } subscript(componentType: C.Type) -> Component? where C: Component { fatalError() } func get(_ componentId: ComponentIdentifier) -> Component? { fatalError() } subscript(componentId: ComponentIdentifier) -> Component? { fatalError() } func remove(_ component: C) -> Bool where C : Component { fatalError() } func remove(_ componentType: C.Type) -> Bool where C : Component { fatalError() } func remove(_ componentId: ComponentIdentifier) -> Bool { fatalError() } func clear() { fatalError() } } */