// DO NOT EDIT.
//
// Generated by the Swift generator plugin for the protocol buffer compiler.
// Source: syft_proto/execution/v1/operation.proto
//
// For information on using the generated types, please see the documentation:
//   https://github.com/apple/swift-protobuf/

import Foundation
import SwiftProtobuf

// If the compiler emits an error on this type, it is because this file
// was generated by a version of the `protoc` Swift plug-in that is
// incompatible with the version of SwiftProtobuf to which you are linking.
// Please ensure that your are building against the same version of the API
// that was used to generate this file.
fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
  struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
  typealias Version = _2
}

public struct SyftProto_Execution_V1_Operation {
  // SwiftProtobuf.Message conformance is added in an extension below. See the
  // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  // methods supported on all messages.

  public var command: String {
    get {return _storage._command}
    set {_uniqueStorage()._command = newValue}
  }

  public var owner: OneOf_Owner? {
    get {return _storage._owner}
    set {_uniqueStorage()._owner = newValue}
  }

  public var ownerPointer: SyftProto_Generic_Pointers_V1_PointerTensor {
    get {
      if case .ownerPointer(let v)? = _storage._owner {return v}
      return SyftProto_Generic_Pointers_V1_PointerTensor()
    }
    set {_uniqueStorage()._owner = .ownerPointer(newValue)}
  }

  public var ownerPlaceholder: SyftProto_Frameworks_Torch_Tensors_Interpreters_V1_Placeholder {
    get {
      if case .ownerPlaceholder(let v)? = _storage._owner {return v}
      return SyftProto_Frameworks_Torch_Tensors_Interpreters_V1_Placeholder()
    }
    set {_uniqueStorage()._owner = .ownerPlaceholder(newValue)}
  }

  public var ownerTensor: SyftProto_Types_Torch_V1_TorchTensor {
    get {
      if case .ownerTensor(let v)? = _storage._owner {return v}
      return SyftProto_Types_Torch_V1_TorchTensor()
    }
    set {_uniqueStorage()._owner = .ownerTensor(newValue)}
  }

  public var args: [SyftProto_Types_Syft_V1_Arg] {
    get {return _storage._args}
    set {_uniqueStorage()._args = newValue}
  }

  public var kwargs: Dictionary<String,SyftProto_Types_Syft_V1_Arg> {
    get {return _storage._kwargs}
    set {_uniqueStorage()._kwargs = newValue}
  }

  public var returnIds: [SyftProto_Types_Syft_V1_Id] {
    get {return _storage._returnIds}
    set {_uniqueStorage()._returnIds = newValue}
  }

  public var returnPlaceholders: [SyftProto_Frameworks_Torch_Tensors_Interpreters_V1_Placeholder] {
    get {return _storage._returnPlaceholders}
    set {_uniqueStorage()._returnPlaceholders = newValue}
  }

  public var unknownFields = SwiftProtobuf.UnknownStorage()

  public enum OneOf_Owner: Equatable {
    case ownerPointer(SyftProto_Generic_Pointers_V1_PointerTensor)
    case ownerPlaceholder(SyftProto_Frameworks_Torch_Tensors_Interpreters_V1_Placeholder)
    case ownerTensor(SyftProto_Types_Torch_V1_TorchTensor)

  #if !swift(>=4.1)
    public static func ==(lhs: SyftProto_Execution_V1_Operation.OneOf_Owner, rhs: SyftProto_Execution_V1_Operation.OneOf_Owner) -> Bool {
      switch (lhs, rhs) {
      case (.ownerPointer(let l), .ownerPointer(let r)): return l == r
      case (.ownerPlaceholder(let l), .ownerPlaceholder(let r)): return l == r
      case (.ownerTensor(let l), .ownerTensor(let r)): return l == r
      default: return false
      }
    }
  #endif
  }

  public init() {}

  fileprivate var _storage = _StorageClass.defaultInstance
}

// MARK: - Code below here is support for the SwiftProtobuf runtime.

fileprivate let _protobuf_package = "syft_proto.execution.v1"

extension SyftProto_Execution_V1_Operation: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  public static let protoMessageName: String = _protobuf_package + ".Operation"
  public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .same(proto: "command"),
    2: .standard(proto: "owner_pointer"),
    3: .standard(proto: "owner_placeholder"),
    4: .standard(proto: "owner_tensor"),
    5: .same(proto: "args"),
    6: .same(proto: "kwargs"),
    7: .standard(proto: "return_ids"),
    8: .standard(proto: "return_placeholders"),
  ]

  fileprivate class _StorageClass {
    var _command: String = String()
    var _owner: SyftProto_Execution_V1_Operation.OneOf_Owner?
    var _args: [SyftProto_Types_Syft_V1_Arg] = []
    var _kwargs: Dictionary<String,SyftProto_Types_Syft_V1_Arg> = [:]
    var _returnIds: [SyftProto_Types_Syft_V1_Id] = []
    var _returnPlaceholders: [SyftProto_Frameworks_Torch_Tensors_Interpreters_V1_Placeholder] = []

    static let defaultInstance = _StorageClass()

    private init() {}

    init(copying source: _StorageClass) {
      _command = source._command
      _owner = source._owner
      _args = source._args
      _kwargs = source._kwargs
      _returnIds = source._returnIds
      _returnPlaceholders = source._returnPlaceholders
    }
  }

  fileprivate mutating func _uniqueStorage() -> _StorageClass {
    if !isKnownUniquelyReferenced(&_storage) {
      _storage = _StorageClass(copying: _storage)
    }
    return _storage
  }

  public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    _ = _uniqueStorage()
    try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
      while let fieldNumber = try decoder.nextFieldNumber() {
        switch fieldNumber {
        case 1: try decoder.decodeSingularStringField(value: &_storage._command)
        case 2:
          var v: SyftProto_Generic_Pointers_V1_PointerTensor?
          if let current = _storage._owner {
            try decoder.handleConflictingOneOf()
            if case .ownerPointer(let m) = current {v = m}
          }
          try decoder.decodeSingularMessageField(value: &v)
          if let v = v {_storage._owner = .ownerPointer(v)}
        case 3:
          var v: SyftProto_Frameworks_Torch_Tensors_Interpreters_V1_Placeholder?
          if let current = _storage._owner {
            try decoder.handleConflictingOneOf()
            if case .ownerPlaceholder(let m) = current {v = m}
          }
          try decoder.decodeSingularMessageField(value: &v)
          if let v = v {_storage._owner = .ownerPlaceholder(v)}
        case 4:
          var v: SyftProto_Types_Torch_V1_TorchTensor?
          if let current = _storage._owner {
            try decoder.handleConflictingOneOf()
            if case .ownerTensor(let m) = current {v = m}
          }
          try decoder.decodeSingularMessageField(value: &v)
          if let v = v {_storage._owner = .ownerTensor(v)}
        case 5: try decoder.decodeRepeatedMessageField(value: &_storage._args)
        case 6: try decoder.decodeMapField(fieldType: SwiftProtobuf._ProtobufMessageMap<SwiftProtobuf.ProtobufString,SyftProto_Types_Syft_V1_Arg>.self, value: &_storage._kwargs)
        case 7: try decoder.decodeRepeatedMessageField(value: &_storage._returnIds)
        case 8: try decoder.decodeRepeatedMessageField(value: &_storage._returnPlaceholders)
        default: break
        }
      }
    }
  }

  public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
      if !_storage._command.isEmpty {
        try visitor.visitSingularStringField(value: _storage._command, fieldNumber: 1)
      }
      switch _storage._owner {
      case .ownerPointer(let v)?:
        try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
      case .ownerPlaceholder(let v)?:
        try visitor.visitSingularMessageField(value: v, fieldNumber: 3)
      case .ownerTensor(let v)?:
        try visitor.visitSingularMessageField(value: v, fieldNumber: 4)
      case nil: break
      }
      if !_storage._args.isEmpty {
        try visitor.visitRepeatedMessageField(value: _storage._args, fieldNumber: 5)
      }
      if !_storage._kwargs.isEmpty {
        try visitor.visitMapField(fieldType: SwiftProtobuf._ProtobufMessageMap<SwiftProtobuf.ProtobufString,SyftProto_Types_Syft_V1_Arg>.self, value: _storage._kwargs, fieldNumber: 6)
      }
      if !_storage._returnIds.isEmpty {
        try visitor.visitRepeatedMessageField(value: _storage._returnIds, fieldNumber: 7)
      }
      if !_storage._returnPlaceholders.isEmpty {
        try visitor.visitRepeatedMessageField(value: _storage._returnPlaceholders, fieldNumber: 8)
      }
    }
    try unknownFields.traverse(visitor: &visitor)
  }

  public static func ==(lhs: SyftProto_Execution_V1_Operation, rhs: SyftProto_Execution_V1_Operation) -> Bool {
    if lhs._storage !== rhs._storage {
      let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in
        let _storage = _args.0
        let rhs_storage = _args.1
        if _storage._command != rhs_storage._command {return false}
        if _storage._owner != rhs_storage._owner {return false}
        if _storage._args != rhs_storage._args {return false}
        if _storage._kwargs != rhs_storage._kwargs {return false}
        if _storage._returnIds != rhs_storage._returnIds {return false}
        if _storage._returnPlaceholders != rhs_storage._returnPlaceholders {return false}
        return true
      }
      if !storagesAreEqual {return false}
    }
    if lhs.unknownFields != rhs.unknownFields {return false}
    return true
  }
}
