//go:build !ignore_autogenerated
// +build !ignore_autogenerated

// Code generated by iocli, run 'iocli gen' to re-generate

package protocol_impl

import (
	"dubbo.apache.org/dubbo-go/v3/protocol"

	"github.com/alibaba/ioc-golang/autowire"
	normal "github.com/alibaba/ioc-golang/autowire/normal"
	util "github.com/alibaba/ioc-golang/autowire/util"
)

func init() {
	normal.RegisterStructDescriptor(&autowire.StructDescriptor{
		Factory: func() interface{} {
			return &iOCProtocol_{}
		},
	})
	iOCProtocolStructDescriptor := &autowire.StructDescriptor{
		Factory: func() interface{} {
			return &IOCProtocol{}
		},
		ParamFactory: func() interface{} {
			var _ paramInterface = &Param{}
			return &Param{}
		},
		ConstructFunc: func(i interface{}, p interface{}) (interface{}, error) {
			param := p.(paramInterface)
			impl := i.(*IOCProtocol)
			return param.Init(impl)
		},
		Metadata: map[string]interface{}{
			"aop":      map[string]interface{}{},
			"autowire": map[string]interface{}{},
		},
	}
	normal.RegisterStructDescriptor(iOCProtocolStructDescriptor)
}

type paramInterface interface {
	Init(impl *IOCProtocol) (*IOCProtocol, error)
}
type iOCProtocol_ struct {
	Invoke_ func(invocation protocol.Invocation) protocol.Result
	Export_ func(invoker protocol.Invoker) protocol.Exporter
}

func (i *iOCProtocol_) Invoke(invocation protocol.Invocation) protocol.Result {
	return i.Invoke_(invocation)
}

func (i *iOCProtocol_) Export(invoker protocol.Invoker) protocol.Exporter {
	return i.Export_(invoker)
}

type IOCProtocolIOCInterface interface {
	Invoke(invocation protocol.Invocation) protocol.Result
	Export(invoker protocol.Invoker) protocol.Exporter
}

var _iOCProtocolSDID string

func GetIOCProtocol(p *Param) (*IOCProtocol, error) {
	if _iOCProtocolSDID == "" {
		_iOCProtocolSDID = util.GetSDIDByStructPtr(new(IOCProtocol))
	}
	i, err := normal.GetImpl(_iOCProtocolSDID, p)
	if err != nil {
		return nil, err
	}
	impl := i.(*IOCProtocol)
	return impl, nil
}

func GetIOCProtocolIOCInterface(p *Param) (IOCProtocolIOCInterface, error) {
	if _iOCProtocolSDID == "" {
		_iOCProtocolSDID = util.GetSDIDByStructPtr(new(IOCProtocol))
	}
	i, err := normal.GetImplWithProxy(_iOCProtocolSDID, p)
	if err != nil {
		return nil, err
	}
	impl := i.(IOCProtocolIOCInterface)
	return impl, nil
}
