// DO NOT EDIT.
// swift-format-ignore-file
//
// Generated by the Swift generator plugin for the protocol buffer compiler.
// Source: tensorboardX/proto/event.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 you 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
}

/// Protocol buffer representing an event that happened during
/// the execution of a Brain model.
struct TensorboardX_Event {
  // 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.

  /// Timestamp of the event.
  var wallTime: Double = 0

  /// Global step of the event.
  var step: Int64 = 0

  var what: TensorboardX_Event.OneOf_What? = nil

  /// An event file was started, with the specified version.
  /// This is use to identify the contents of the record IO files
  /// easily.  Current version is "brain.Event:2".  All versions
  /// start with "brain.Event:".
  var fileVersion: String {
    get {
      if case .fileVersion(let v)? = what {return v}
      return String()
    }
    set {what = .fileVersion(newValue)}
  }

  /// An encoded version of a GraphDef.
  var graphDef: Data {
    get {
      if case .graphDef(let v)? = what {return v}
      return Data()
    }
    set {what = .graphDef(newValue)}
  }

  /// A summary was generated.
  var summary: TensorboardX_Summary {
    get {
      if case .summary(let v)? = what {return v}
      return TensorboardX_Summary()
    }
    set {what = .summary(newValue)}
  }

  /// The user output a log message. Not all messages are logged, only ones
  /// generated via the Python tensorboard_logging module.
  var logMessage: TensorboardX_LogMessage {
    get {
      if case .logMessage(let v)? = what {return v}
      return TensorboardX_LogMessage()
    }
    set {what = .logMessage(newValue)}
  }

  /// The state of the session which can be used for restarting after crashes.
  var sessionLog: TensorboardX_SessionLog {
    get {
      if case .sessionLog(let v)? = what {return v}
      return TensorboardX_SessionLog()
    }
    set {what = .sessionLog(newValue)}
  }

  /// The metadata returned by running a session.run() call.
  var taggedRunMetadata: TensorboardX_TaggedRunMetadata {
    get {
      if case .taggedRunMetadata(let v)? = what {return v}
      return TensorboardX_TaggedRunMetadata()
    }
    set {what = .taggedRunMetadata(newValue)}
  }

  /// An encoded version of a MetaGraphDef.
  var metaGraphDef: Data {
    get {
      if case .metaGraphDef(let v)? = what {return v}
      return Data()
    }
    set {what = .metaGraphDef(newValue)}
  }

  var unknownFields = SwiftProtobuf.UnknownStorage()

  enum OneOf_What: Equatable {
    /// An event file was started, with the specified version.
    /// This is use to identify the contents of the record IO files
    /// easily.  Current version is "brain.Event:2".  All versions
    /// start with "brain.Event:".
    case fileVersion(String)
    /// An encoded version of a GraphDef.
    case graphDef(Data)
    /// A summary was generated.
    case summary(TensorboardX_Summary)
    /// The user output a log message. Not all messages are logged, only ones
    /// generated via the Python tensorboard_logging module.
    case logMessage(TensorboardX_LogMessage)
    /// The state of the session which can be used for restarting after crashes.
    case sessionLog(TensorboardX_SessionLog)
    /// The metadata returned by running a session.run() call.
    case taggedRunMetadata(TensorboardX_TaggedRunMetadata)
    /// An encoded version of a MetaGraphDef.
    case metaGraphDef(Data)

  #if !swift(>=4.1)
    static func ==(lhs: TensorboardX_Event.OneOf_What, rhs: TensorboardX_Event.OneOf_What) -> Bool {
      // The use of inline closures is to circumvent an issue where the compiler
      // allocates stack space for every case branch when no optimizations are
      // enabled. https://github.com/apple/swift-protobuf/issues/1034
      switch (lhs, rhs) {
      case (.fileVersion, .fileVersion): return {
        guard case .fileVersion(let l) = lhs, case .fileVersion(let r) = rhs else { preconditionFailure() }
        return l == r
      }()
      case (.graphDef, .graphDef): return {
        guard case .graphDef(let l) = lhs, case .graphDef(let r) = rhs else { preconditionFailure() }
        return l == r
      }()
      case (.summary, .summary): return {
        guard case .summary(let l) = lhs, case .summary(let r) = rhs else { preconditionFailure() }
        return l == r
      }()
      case (.logMessage, .logMessage): return {
        guard case .logMessage(let l) = lhs, case .logMessage(let r) = rhs else { preconditionFailure() }
        return l == r
      }()
      case (.sessionLog, .sessionLog): return {
        guard case .sessionLog(let l) = lhs, case .sessionLog(let r) = rhs else { preconditionFailure() }
        return l == r
      }()
      case (.taggedRunMetadata, .taggedRunMetadata): return {
        guard case .taggedRunMetadata(let l) = lhs, case .taggedRunMetadata(let r) = rhs else { preconditionFailure() }
        return l == r
      }()
      case (.metaGraphDef, .metaGraphDef): return {
        guard case .metaGraphDef(let l) = lhs, case .metaGraphDef(let r) = rhs else { preconditionFailure() }
        return l == r
      }()
      default: return false
      }
    }
  #endif
  }

  init() {}
}

/// Protocol buffer used for logging messages to the events file.
struct TensorboardX_LogMessage {
  // 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.

  var level: TensorboardX_LogMessage.Level = .unknown

  var message: String = String()

  var unknownFields = SwiftProtobuf.UnknownStorage()

  enum Level: SwiftProtobuf.Enum {
    typealias RawValue = Int
    case unknown // = 0
    case debug // = 10
    case info // = 20
    case warn // = 30
    case error // = 40
    case fatal // = 50
    case UNRECOGNIZED(Int)

    init() {
      self = .unknown
    }

    init?(rawValue: Int) {
      switch rawValue {
      case 0: self = .unknown
      case 10: self = .debug
      case 20: self = .info
      case 30: self = .warn
      case 40: self = .error
      case 50: self = .fatal
      default: self = .UNRECOGNIZED(rawValue)
      }
    }

    var rawValue: Int {
      switch self {
      case .unknown: return 0
      case .debug: return 10
      case .info: return 20
      case .warn: return 30
      case .error: return 40
      case .fatal: return 50
      case .UNRECOGNIZED(let i): return i
      }
    }

  }

  init() {}
}

#if swift(>=4.2)

extension TensorboardX_LogMessage.Level: CaseIterable {
  // The compiler won't synthesize support with the UNRECOGNIZED case.
  static var allCases: [TensorboardX_LogMessage.Level] = [
    .unknown,
    .debug,
    .info,
    .warn,
    .error,
    .fatal,
  ]
}

#endif  // swift(>=4.2)

/// Protocol buffer used for logging session state.
struct TensorboardX_SessionLog {
  // 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.

  var status: TensorboardX_SessionLog.SessionStatus = .statusUnspecified

  /// This checkpoint_path contains both the path and filename.
  var checkpointPath: String = String()

  var msg: String = String()

  var unknownFields = SwiftProtobuf.UnknownStorage()

  enum SessionStatus: SwiftProtobuf.Enum {
    typealias RawValue = Int
    case statusUnspecified // = 0
    case start // = 1
    case stop // = 2
    case checkpoint // = 3
    case UNRECOGNIZED(Int)

    init() {
      self = .statusUnspecified
    }

    init?(rawValue: Int) {
      switch rawValue {
      case 0: self = .statusUnspecified
      case 1: self = .start
      case 2: self = .stop
      case 3: self = .checkpoint
      default: self = .UNRECOGNIZED(rawValue)
      }
    }

    var rawValue: Int {
      switch self {
      case .statusUnspecified: return 0
      case .start: return 1
      case .stop: return 2
      case .checkpoint: return 3
      case .UNRECOGNIZED(let i): return i
      }
    }

  }

  init() {}
}

#if swift(>=4.2)

extension TensorboardX_SessionLog.SessionStatus: CaseIterable {
  // The compiler won't synthesize support with the UNRECOGNIZED case.
  static var allCases: [TensorboardX_SessionLog.SessionStatus] = [
    .statusUnspecified,
    .start,
    .stop,
    .checkpoint,
  ]
}

#endif  // swift(>=4.2)

/// For logging the metadata output for a single session.run() call.
struct TensorboardX_TaggedRunMetadata {
  // 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.

  /// Tag name associated with this metadata.
  var tag: String = String()

  /// Byte-encoded version of the `RunMetadata` proto in order to allow lazy
  /// deserialization.
  var runMetadata: Data = Data()

  var unknownFields = SwiftProtobuf.UnknownStorage()

  init() {}
}

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

fileprivate let _protobuf_package = "tensorboardX"

extension TensorboardX_Event: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  static let protoMessageName: String = _protobuf_package + ".Event"
  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .standard(proto: "wall_time"),
    2: .same(proto: "step"),
    3: .standard(proto: "file_version"),
    4: .standard(proto: "graph_def"),
    5: .same(proto: "summary"),
    6: .standard(proto: "log_message"),
    7: .standard(proto: "session_log"),
    8: .standard(proto: "tagged_run_metadata"),
    9: .standard(proto: "meta_graph_def"),
  ]

  mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    while let fieldNumber = try decoder.nextFieldNumber() {
      // The use of inline closures is to circumvent an issue where the compiler
      // allocates stack space for every case branch when no optimizations are
      // enabled. https://github.com/apple/swift-protobuf/issues/1034
      switch fieldNumber {
      case 1: try { try decoder.decodeSingularDoubleField(value: &self.wallTime) }()
      case 2: try { try decoder.decodeSingularInt64Field(value: &self.step) }()
      case 3: try {
        if self.what != nil {try decoder.handleConflictingOneOf()}
        var v: String?
        try decoder.decodeSingularStringField(value: &v)
        if let v = v {self.what = .fileVersion(v)}
      }()
      case 4: try {
        if self.what != nil {try decoder.handleConflictingOneOf()}
        var v: Data?
        try decoder.decodeSingularBytesField(value: &v)
        if let v = v {self.what = .graphDef(v)}
      }()
      case 5: try {
        var v: TensorboardX_Summary?
        if let current = self.what {
          try decoder.handleConflictingOneOf()
          if case .summary(let m) = current {v = m}
        }
        try decoder.decodeSingularMessageField(value: &v)
        if let v = v {self.what = .summary(v)}
      }()
      case 6: try {
        var v: TensorboardX_LogMessage?
        if let current = self.what {
          try decoder.handleConflictingOneOf()
          if case .logMessage(let m) = current {v = m}
        }
        try decoder.decodeSingularMessageField(value: &v)
        if let v = v {self.what = .logMessage(v)}
      }()
      case 7: try {
        var v: TensorboardX_SessionLog?
        if let current = self.what {
          try decoder.handleConflictingOneOf()
          if case .sessionLog(let m) = current {v = m}
        }
        try decoder.decodeSingularMessageField(value: &v)
        if let v = v {self.what = .sessionLog(v)}
      }()
      case 8: try {
        var v: TensorboardX_TaggedRunMetadata?
        if let current = self.what {
          try decoder.handleConflictingOneOf()
          if case .taggedRunMetadata(let m) = current {v = m}
        }
        try decoder.decodeSingularMessageField(value: &v)
        if let v = v {self.what = .taggedRunMetadata(v)}
      }()
      case 9: try {
        if self.what != nil {try decoder.handleConflictingOneOf()}
        var v: Data?
        try decoder.decodeSingularBytesField(value: &v)
        if let v = v {self.what = .metaGraphDef(v)}
      }()
      default: break
      }
    }
  }

  func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    if self.wallTime != 0 {
      try visitor.visitSingularDoubleField(value: self.wallTime, fieldNumber: 1)
    }
    if self.step != 0 {
      try visitor.visitSingularInt64Field(value: self.step, fieldNumber: 2)
    }
    // The use of inline closures is to circumvent an issue where the compiler
    // allocates stack space for every case branch when no optimizations are
    // enabled. https://github.com/apple/swift-protobuf/issues/1034
    switch self.what {
    case .fileVersion?: try {
      guard case .fileVersion(let v)? = self.what else { preconditionFailure() }
      try visitor.visitSingularStringField(value: v, fieldNumber: 3)
    }()
    case .graphDef?: try {
      guard case .graphDef(let v)? = self.what else { preconditionFailure() }
      try visitor.visitSingularBytesField(value: v, fieldNumber: 4)
    }()
    case .summary?: try {
      guard case .summary(let v)? = self.what else { preconditionFailure() }
      try visitor.visitSingularMessageField(value: v, fieldNumber: 5)
    }()
    case .logMessage?: try {
      guard case .logMessage(let v)? = self.what else { preconditionFailure() }
      try visitor.visitSingularMessageField(value: v, fieldNumber: 6)
    }()
    case .sessionLog?: try {
      guard case .sessionLog(let v)? = self.what else { preconditionFailure() }
      try visitor.visitSingularMessageField(value: v, fieldNumber: 7)
    }()
    case .taggedRunMetadata?: try {
      guard case .taggedRunMetadata(let v)? = self.what else { preconditionFailure() }
      try visitor.visitSingularMessageField(value: v, fieldNumber: 8)
    }()
    case .metaGraphDef?: try {
      guard case .metaGraphDef(let v)? = self.what else { preconditionFailure() }
      try visitor.visitSingularBytesField(value: v, fieldNumber: 9)
    }()
    case nil: break
    }
    try unknownFields.traverse(visitor: &visitor)
  }

  static func ==(lhs: TensorboardX_Event, rhs: TensorboardX_Event) -> Bool {
    if lhs.wallTime != rhs.wallTime {return false}
    if lhs.step != rhs.step {return false}
    if lhs.what != rhs.what {return false}
    if lhs.unknownFields != rhs.unknownFields {return false}
    return true
  }
}

extension TensorboardX_LogMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  static let protoMessageName: String = _protobuf_package + ".LogMessage"
  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .same(proto: "level"),
    2: .same(proto: "message"),
  ]

  mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    while let fieldNumber = try decoder.nextFieldNumber() {
      // The use of inline closures is to circumvent an issue where the compiler
      // allocates stack space for every case branch when no optimizations are
      // enabled. https://github.com/apple/swift-protobuf/issues/1034
      switch fieldNumber {
      case 1: try { try decoder.decodeSingularEnumField(value: &self.level) }()
      case 2: try { try decoder.decodeSingularStringField(value: &self.message) }()
      default: break
      }
    }
  }

  func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    if self.level != .unknown {
      try visitor.visitSingularEnumField(value: self.level, fieldNumber: 1)
    }
    if !self.message.isEmpty {
      try visitor.visitSingularStringField(value: self.message, fieldNumber: 2)
    }
    try unknownFields.traverse(visitor: &visitor)
  }

  static func ==(lhs: TensorboardX_LogMessage, rhs: TensorboardX_LogMessage) -> Bool {
    if lhs.level != rhs.level {return false}
    if lhs.message != rhs.message {return false}
    if lhs.unknownFields != rhs.unknownFields {return false}
    return true
  }
}

extension TensorboardX_LogMessage.Level: SwiftProtobuf._ProtoNameProviding {
  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    0: .same(proto: "UNKNOWN"),
    10: .same(proto: "DEBUG"),
    20: .same(proto: "INFO"),
    30: .same(proto: "WARN"),
    40: .same(proto: "ERROR"),
    50: .same(proto: "FATAL"),
  ]
}

extension TensorboardX_SessionLog: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  static let protoMessageName: String = _protobuf_package + ".SessionLog"
  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .same(proto: "status"),
    2: .standard(proto: "checkpoint_path"),
    3: .same(proto: "msg"),
  ]

  mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    while let fieldNumber = try decoder.nextFieldNumber() {
      // The use of inline closures is to circumvent an issue where the compiler
      // allocates stack space for every case branch when no optimizations are
      // enabled. https://github.com/apple/swift-protobuf/issues/1034
      switch fieldNumber {
      case 1: try { try decoder.decodeSingularEnumField(value: &self.status) }()
      case 2: try { try decoder.decodeSingularStringField(value: &self.checkpointPath) }()
      case 3: try { try decoder.decodeSingularStringField(value: &self.msg) }()
      default: break
      }
    }
  }

  func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    if self.status != .statusUnspecified {
      try visitor.visitSingularEnumField(value: self.status, fieldNumber: 1)
    }
    if !self.checkpointPath.isEmpty {
      try visitor.visitSingularStringField(value: self.checkpointPath, fieldNumber: 2)
    }
    if !self.msg.isEmpty {
      try visitor.visitSingularStringField(value: self.msg, fieldNumber: 3)
    }
    try unknownFields.traverse(visitor: &visitor)
  }

  static func ==(lhs: TensorboardX_SessionLog, rhs: TensorboardX_SessionLog) -> Bool {
    if lhs.status != rhs.status {return false}
    if lhs.checkpointPath != rhs.checkpointPath {return false}
    if lhs.msg != rhs.msg {return false}
    if lhs.unknownFields != rhs.unknownFields {return false}
    return true
  }
}

extension TensorboardX_SessionLog.SessionStatus: SwiftProtobuf._ProtoNameProviding {
  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    0: .same(proto: "STATUS_UNSPECIFIED"),
    1: .same(proto: "START"),
    2: .same(proto: "STOP"),
    3: .same(proto: "CHECKPOINT"),
  ]
}

extension TensorboardX_TaggedRunMetadata: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  static let protoMessageName: String = _protobuf_package + ".TaggedRunMetadata"
  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .same(proto: "tag"),
    2: .standard(proto: "run_metadata"),
  ]

  mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    while let fieldNumber = try decoder.nextFieldNumber() {
      // The use of inline closures is to circumvent an issue where the compiler
      // allocates stack space for every case branch when no optimizations are
      // enabled. https://github.com/apple/swift-protobuf/issues/1034
      switch fieldNumber {
      case 1: try { try decoder.decodeSingularStringField(value: &self.tag) }()
      case 2: try { try decoder.decodeSingularBytesField(value: &self.runMetadata) }()
      default: break
      }
    }
  }

  func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    if !self.tag.isEmpty {
      try visitor.visitSingularStringField(value: self.tag, fieldNumber: 1)
    }
    if !self.runMetadata.isEmpty {
      try visitor.visitSingularBytesField(value: self.runMetadata, fieldNumber: 2)
    }
    try unknownFields.traverse(visitor: &visitor)
  }

  static func ==(lhs: TensorboardX_TaggedRunMetadata, rhs: TensorboardX_TaggedRunMetadata) -> Bool {
    if lhs.tag != rhs.tag {return false}
    if lhs.runMetadata != rhs.runMetadata {return false}
    if lhs.unknownFields != rhs.unknownFields {return false}
    return true
  }
}
