//
// Copyright 2019 AT&T Intellectual Property
// Copyright 2019 Nokia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).

// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// 	protoc-gen-go v1.26.0
// 	protoc        v3.15.8
// source: cells.proto

package entities

import (
	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
	reflect "reflect"
	sync "sync"
)

const (
	// Verify that this generated code is sufficiently up-to-date.
	_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
	// Verify that runtime/protoimpl is sufficiently up-to-date.
	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)

type Cells struct {
	state         protoimpl.MessageState
	sizeCache     protoimpl.SizeCache
	unknownFields protoimpl.UnknownFields

	Type Cell_Type `protobuf:"varint,1,opt,name=type,proto3,enum=entities.Cell_Type" json:"type,omitempty"`
	// Types that are assignable to List:
	//	*Cells_ServedCellInfos
	//	*Cells_ServedNrCells
	List isCells_List `protobuf_oneof:"list"`
}

func (x *Cells) Reset() {
	*x = Cells{}
	if protoimpl.UnsafeEnabled {
		mi := &file_cells_proto_msgTypes[0]
		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
		ms.StoreMessageInfo(mi)
	}
}

func (x *Cells) String() string {
	return protoimpl.X.MessageStringOf(x)
}

func (*Cells) ProtoMessage() {}

func (x *Cells) ProtoReflect() protoreflect.Message {
	mi := &file_cells_proto_msgTypes[0]
	if protoimpl.UnsafeEnabled && x != nil {
		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
		if ms.LoadMessageInfo() == nil {
			ms.StoreMessageInfo(mi)
		}
		return ms
	}
	return mi.MessageOf(x)
}

// Deprecated: Use Cells.ProtoReflect.Descriptor instead.
func (*Cells) Descriptor() ([]byte, []int) {
	return file_cells_proto_rawDescGZIP(), []int{0}
}

func (x *Cells) GetType() Cell_Type {
	if x != nil {
		return x.Type
	}
	return Cell_UNKNOWN_CELL
}

func (m *Cells) GetList() isCells_List {
	if m != nil {
		return m.List
	}
	return nil
}

func (x *Cells) GetServedCellInfos() *ServedCellInfoList {
	if x, ok := x.GetList().(*Cells_ServedCellInfos); ok {
		return x.ServedCellInfos
	}
	return nil
}

func (x *Cells) GetServedNrCells() *ServedNRCellList {
	if x, ok := x.GetList().(*Cells_ServedNrCells); ok {
		return x.ServedNrCells
	}
	return nil
}

type isCells_List interface {
	isCells_List()
}

type Cells_ServedCellInfos struct {
	ServedCellInfos *ServedCellInfoList `protobuf:"bytes,2,opt,name=served_cell_infos,json=servedCellInfos,proto3,oneof"`
}

type Cells_ServedNrCells struct {
	ServedNrCells *ServedNRCellList `protobuf:"bytes,3,opt,name=served_nr_cells,json=servedNrCells,proto3,oneof"`
}

func (*Cells_ServedCellInfos) isCells_List() {}

func (*Cells_ServedNrCells) isCells_List() {}

type ServedCellInfoList struct {
	state         protoimpl.MessageState
	sizeCache     protoimpl.SizeCache
	unknownFields protoimpl.UnknownFields

	ServedCells []*ServedCellInfo `protobuf:"bytes,1,rep,name=served_cells,json=servedCells,proto3" json:"served_cells,omitempty"`
}

func (x *ServedCellInfoList) Reset() {
	*x = ServedCellInfoList{}
	if protoimpl.UnsafeEnabled {
		mi := &file_cells_proto_msgTypes[1]
		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
		ms.StoreMessageInfo(mi)
	}
}

func (x *ServedCellInfoList) String() string {
	return protoimpl.X.MessageStringOf(x)
}

func (*ServedCellInfoList) ProtoMessage() {}

func (x *ServedCellInfoList) ProtoReflect() protoreflect.Message {
	mi := &file_cells_proto_msgTypes[1]
	if protoimpl.UnsafeEnabled && x != nil {
		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
		if ms.LoadMessageInfo() == nil {
			ms.StoreMessageInfo(mi)
		}
		return ms
	}
	return mi.MessageOf(x)
}

// Deprecated: Use ServedCellInfoList.ProtoReflect.Descriptor instead.
func (*ServedCellInfoList) Descriptor() ([]byte, []int) {
	return file_cells_proto_rawDescGZIP(), []int{1}
}

func (x *ServedCellInfoList) GetServedCells() []*ServedCellInfo {
	if x != nil {
		return x.ServedCells
	}
	return nil
}

type ServedNRCellList struct {
	state         protoimpl.MessageState
	sizeCache     protoimpl.SizeCache
	unknownFields protoimpl.UnknownFields

	ServedCells []*ServedNRCell `protobuf:"bytes,1,rep,name=served_cells,json=servedCells,proto3" json:"served_cells,omitempty"`
}

func (x *ServedNRCellList) Reset() {
	*x = ServedNRCellList{}
	if protoimpl.UnsafeEnabled {
		mi := &file_cells_proto_msgTypes[2]
		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
		ms.StoreMessageInfo(mi)
	}
}

func (x *ServedNRCellList) String() string {
	return protoimpl.X.MessageStringOf(x)
}

func (*ServedNRCellList) ProtoMessage() {}

func (x *ServedNRCellList) ProtoReflect() protoreflect.Message {
	mi := &file_cells_proto_msgTypes[2]
	if protoimpl.UnsafeEnabled && x != nil {
		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
		if ms.LoadMessageInfo() == nil {
			ms.StoreMessageInfo(mi)
		}
		return ms
	}
	return mi.MessageOf(x)
}

// Deprecated: Use ServedNRCellList.ProtoReflect.Descriptor instead.
func (*ServedNRCellList) Descriptor() ([]byte, []int) {
	return file_cells_proto_rawDescGZIP(), []int{2}
}

func (x *ServedNRCellList) GetServedCells() []*ServedNRCell {
	if x != nil {
		return x.ServedCells
	}
	return nil
}

var File_cells_proto protoreflect.FileDescriptor

var file_cells_proto_rawDesc = []byte{
	0x0a, 0x0b, 0x63, 0x65, 0x6c, 0x6c, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x65,
	0x6e, 0x74, 0x69, 0x74, 0x69, 0x65, 0x73, 0x1a, 0x0a, 0x63, 0x65, 0x6c, 0x6c, 0x2e, 0x70, 0x72,
	0x6f, 0x74, 0x6f, 0x1a, 0x09, 0x67, 0x6e, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x09,
	0x65, 0x6e, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xca, 0x01, 0x0a, 0x05, 0x43, 0x65,
	0x6c, 0x6c, 0x73, 0x12, 0x27, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
	0x0e, 0x32, 0x13, 0x2e, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x69, 0x65, 0x73, 0x2e, 0x43, 0x65, 0x6c,
	0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x4a, 0x0a, 0x11,
	0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x5f, 0x63, 0x65, 0x6c, 0x6c, 0x5f, 0x69, 0x6e, 0x66, 0x6f,
	0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x69,
	0x65, 0x73, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x64, 0x43, 0x65, 0x6c, 0x6c, 0x49, 0x6e, 0x66,
	0x6f, 0x4c, 0x69, 0x73, 0x74, 0x48, 0x00, 0x52, 0x0f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x43,
	0x65, 0x6c, 0x6c, 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x12, 0x44, 0x0a, 0x0f, 0x73, 0x65, 0x72, 0x76,
	0x65, 0x64, 0x5f, 0x6e, 0x72, 0x5f, 0x63, 0x65, 0x6c, 0x6c, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28,
	0x0b, 0x32, 0x1a, 0x2e, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x69, 0x65, 0x73, 0x2e, 0x53, 0x65, 0x72,
	0x76, 0x65, 0x64, 0x4e, 0x52, 0x43, 0x65, 0x6c, 0x6c, 0x4c, 0x69, 0x73, 0x74, 0x48, 0x00, 0x52,
	0x0d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x4e, 0x72, 0x43, 0x65, 0x6c, 0x6c, 0x73, 0x42, 0x06,
	0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x22, 0x51, 0x0a, 0x12, 0x53, 0x65, 0x72, 0x76, 0x65, 0x64,
	0x43, 0x65, 0x6c, 0x6c, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x3b, 0x0a, 0x0c,
	0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x5f, 0x63, 0x65, 0x6c, 0x6c, 0x73, 0x18, 0x01, 0x20, 0x03,
	0x28, 0x0b, 0x32, 0x18, 0x2e, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x69, 0x65, 0x73, 0x2e, 0x53, 0x65,
	0x72, 0x76, 0x65, 0x64, 0x43, 0x65, 0x6c, 0x6c, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0b, 0x73, 0x65,
	0x72, 0x76, 0x65, 0x64, 0x43, 0x65, 0x6c, 0x6c, 0x73, 0x22, 0x4d, 0x0a, 0x10, 0x53, 0x65, 0x72,
	0x76, 0x65, 0x64, 0x4e, 0x52, 0x43, 0x65, 0x6c, 0x6c, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x39, 0x0a,
	0x0c, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x5f, 0x63, 0x65, 0x6c, 0x6c, 0x73, 0x18, 0x01, 0x20,
	0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x69, 0x65, 0x73, 0x2e, 0x53,
	0x65, 0x72, 0x76, 0x65, 0x64, 0x4e, 0x52, 0x43, 0x65, 0x6c, 0x6c, 0x52, 0x0b, 0x73, 0x65, 0x72,
	0x76, 0x65, 0x64, 0x43, 0x65, 0x6c, 0x6c, 0x73, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x65, 0x72, 0x72,
	0x69, 0x74, 0x2e, 0x6f, 0x2d, 0x72, 0x61, 0x6e, 0x2d, 0x73, 0x63, 0x2e, 0x6f, 0x72, 0x67, 0x2f,
	0x72, 0x2f, 0x72, 0x69, 0x63, 0x2d, 0x70, 0x6c, 0x74, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x62, 0x2d,
	0x72, 0x6e, 0x69, 0x62, 0x2f, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x69, 0x65, 0x73, 0x62, 0x06, 0x70,
	0x72, 0x6f, 0x74, 0x6f, 0x33,
}

var (
	file_cells_proto_rawDescOnce sync.Once
	file_cells_proto_rawDescData = file_cells_proto_rawDesc
)

func file_cells_proto_rawDescGZIP() []byte {
	file_cells_proto_rawDescOnce.Do(func() {
		file_cells_proto_rawDescData = protoimpl.X.CompressGZIP(file_cells_proto_rawDescData)
	})
	return file_cells_proto_rawDescData
}

var file_cells_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_cells_proto_goTypes = []interface{}{
	(*Cells)(nil),              // 0: entities.Cells
	(*ServedCellInfoList)(nil), // 1: entities.ServedCellInfoList
	(*ServedNRCellList)(nil),   // 2: entities.ServedNRCellList
	(Cell_Type)(0),             // 3: entities.Cell.Type
	(*ServedCellInfo)(nil),     // 4: entities.ServedCellInfo
	(*ServedNRCell)(nil),       // 5: entities.ServedNRCell
}
var file_cells_proto_depIdxs = []int32{
	3, // 0: entities.Cells.type:type_name -> entities.Cell.Type
	1, // 1: entities.Cells.served_cell_infos:type_name -> entities.ServedCellInfoList
	2, // 2: entities.Cells.served_nr_cells:type_name -> entities.ServedNRCellList
	4, // 3: entities.ServedCellInfoList.served_cells:type_name -> entities.ServedCellInfo
	5, // 4: entities.ServedNRCellList.served_cells:type_name -> entities.ServedNRCell
	5, // [5:5] is the sub-list for method output_type
	5, // [5:5] is the sub-list for method input_type
	5, // [5:5] is the sub-list for extension type_name
	5, // [5:5] is the sub-list for extension extendee
	0, // [0:5] is the sub-list for field type_name
}

func init() { file_cells_proto_init() }
func file_cells_proto_init() {
	if File_cells_proto != nil {
		return
	}
	file_cell_proto_init()
	file_gnb_proto_init()
	file_enb_proto_init()
	if !protoimpl.UnsafeEnabled {
		file_cells_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
			switch v := v.(*Cells); i {
			case 0:
				return &v.state
			case 1:
				return &v.sizeCache
			case 2:
				return &v.unknownFields
			default:
				return nil
			}
		}
		file_cells_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
			switch v := v.(*ServedCellInfoList); i {
			case 0:
				return &v.state
			case 1:
				return &v.sizeCache
			case 2:
				return &v.unknownFields
			default:
				return nil
			}
		}
		file_cells_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
			switch v := v.(*ServedNRCellList); i {
			case 0:
				return &v.state
			case 1:
				return &v.sizeCache
			case 2:
				return &v.unknownFields
			default:
				return nil
			}
		}
	}
	file_cells_proto_msgTypes[0].OneofWrappers = []interface{}{
		(*Cells_ServedCellInfos)(nil),
		(*Cells_ServedNrCells)(nil),
	}
	type x struct{}
	out := protoimpl.TypeBuilder{
		File: protoimpl.DescBuilder{
			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
			RawDescriptor: file_cells_proto_rawDesc,
			NumEnums:      0,
			NumMessages:   3,
			NumExtensions: 0,
			NumServices:   0,
		},
		GoTypes:           file_cells_proto_goTypes,
		DependencyIndexes: file_cells_proto_depIdxs,
		MessageInfos:      file_cells_proto_msgTypes,
	}.Build()
	File_cells_proto = out.File
	file_cells_proto_rawDesc = nil
	file_cells_proto_goTypes = nil
	file_cells_proto_depIdxs = nil
}
