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

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

package goroutine_trace

import (
	"github.com/alibaba/ioc-golang/aop"
	autowire "github.com/alibaba/ioc-golang/autowire"
	normal "github.com/alibaba/ioc-golang/autowire/normal"
	singleton "github.com/alibaba/ioc-golang/autowire/singleton"
	util "github.com/alibaba/ioc-golang/autowire/util"
)

func init() {
	goRoutineTracingContextStructDescriptor := &autowire.StructDescriptor{
		Factory: func() interface{} {
			return &GoRoutineTracingContext{}
		},
		ParamFactory: func() interface{} {
			var _ goRoutineTracingContextParamsInterface = &GoRoutineTracingContextParams{}
			return &GoRoutineTracingContextParams{}
		},
		ConstructFunc: func(i interface{}, p interface{}) (interface{}, error) {
			param := p.(goRoutineTracingContextParamsInterface)
			impl := i.(*GoRoutineTracingContext)
			return param.initGoRoutineTracingContext(impl)
		},
		Metadata: map[string]interface{}{
			"aop":      map[string]interface{}{},
			"autowire": map[string]interface{}{},
		},
		DisableProxy: true,
	}
	normal.RegisterStructDescriptor(goRoutineTracingContextStructDescriptor)
	normal.RegisterStructDescriptor(&autowire.StructDescriptor{
		Factory: func() interface{} {
			return &goRoutineTraceInterceptor_{}
		},
	})
	goRoutineTraceInterceptorStructDescriptor := &autowire.StructDescriptor{
		Factory: func() interface{} {
			return &GoRoutineTraceInterceptor{}
		},
		Metadata: map[string]interface{}{
			"aop":      map[string]interface{}{},
			"autowire": map[string]interface{}{},
		},
		DisableProxy: true,
	}
	singleton.RegisterStructDescriptor(goRoutineTraceInterceptorStructDescriptor)
}

type goRoutineTracingContextParamsInterface interface {
	initGoRoutineTracingContext(impl *GoRoutineTracingContext) (*GoRoutineTracingContext, error)
}
type goRoutineTraceInterceptor_ struct {
	BeforeInvoke_                  func(ctx *aop.InvocationContext, facadeCtxType string)
	AfterInvoke_                   func(ctx *aop.InvocationContext, facadeCtxType string)
	AddCurrentGRTracingContext_    func(ctx *GoRoutineTracingContext)
	DeleteCurrentGRTracingContext_ func()
	GetCurrentGRTracingContext_    func(ctxType string) *GoRoutineTracingContext
}

func (g *goRoutineTraceInterceptor_) BeforeInvoke(ctx *aop.InvocationContext, facadeCtxType string) {
	g.BeforeInvoke_(ctx, facadeCtxType)
}

func (g *goRoutineTraceInterceptor_) AfterInvoke(ctx *aop.InvocationContext, facadeCtxType string) {
	g.AfterInvoke_(ctx, facadeCtxType)
}

func (g *goRoutineTraceInterceptor_) AddCurrentGRTracingContext(ctx *GoRoutineTracingContext) {
	g.AddCurrentGRTracingContext_(ctx)
}

func (g *goRoutineTraceInterceptor_) DeleteCurrentGRTracingContext() {
	g.DeleteCurrentGRTracingContext_()
}

func (g *goRoutineTraceInterceptor_) GetCurrentGRTracingContext(ctxType string) *GoRoutineTracingContext {
	return g.GetCurrentGRTracingContext_(ctxType)
}

type GoRoutineTraceInterceptorIOCInterface interface {
	BeforeInvoke(ctx *aop.InvocationContext, facadeCtxType string)
	AfterInvoke(ctx *aop.InvocationContext, facadeCtxType string)
	AddCurrentGRTracingContext(ctx *GoRoutineTracingContext)
	DeleteCurrentGRTracingContext()
	GetCurrentGRTracingContext(ctxType string) *GoRoutineTracingContext
}

var _goRoutineTracingContextSDID string

func GetGoRoutineTracingContext(p *GoRoutineTracingContextParams) (*GoRoutineTracingContext, error) {
	if _goRoutineTracingContextSDID == "" {
		_goRoutineTracingContextSDID = util.GetSDIDByStructPtr(new(GoRoutineTracingContext))
	}
	i, err := normal.GetImpl(_goRoutineTracingContextSDID, p)
	if err != nil {
		return nil, err
	}
	impl := i.(*GoRoutineTracingContext)
	return impl, nil
}

var _goRoutineTraceInterceptorSDID string

func GetGoRoutineTraceInterceptorSingleton() (*GoRoutineTraceInterceptor, error) {
	if _goRoutineTraceInterceptorSDID == "" {
		_goRoutineTraceInterceptorSDID = util.GetSDIDByStructPtr(new(GoRoutineTraceInterceptor))
	}
	i, err := singleton.GetImpl(_goRoutineTraceInterceptorSDID, nil)
	if err != nil {
		return nil, err
	}
	impl := i.(*GoRoutineTraceInterceptor)
	return impl, nil
}

func GetGoRoutineTraceInterceptorIOCInterfaceSingleton() (GoRoutineTraceInterceptorIOCInterface, error) {
	if _goRoutineTraceInterceptorSDID == "" {
		_goRoutineTraceInterceptorSDID = util.GetSDIDByStructPtr(new(GoRoutineTraceInterceptor))
	}
	i, err := singleton.GetImplWithProxy(_goRoutineTraceInterceptorSDID, nil)
	if err != nil {
		return nil, err
	}
	impl := i.(GoRoutineTraceInterceptorIOCInterface)
	return impl, nil
}

type ThisGoRoutineTraceInterceptor struct {
}

func (t *ThisGoRoutineTraceInterceptor) This() GoRoutineTraceInterceptorIOCInterface {
	thisPtr, _ := GetGoRoutineTraceInterceptorIOCInterfaceSingleton()
	return thisPtr
}
