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

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

package service1

import (
	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() {
	normal.RegisterStructDescriptor(&autowire.StructDescriptor{
		Factory: func() interface{} {
			return &service1_{}
		},
	})
	service1StructDescriptor := &autowire.StructDescriptor{
		Factory: func() interface{} {
			return &Service1{}
		},
		ConstructFunc: func(i interface{}, _ interface{}) (interface{}, error) {
			impl := i.(*Service1)
			var constructFunc Service1ConstructFunc = constructFunc
			return constructFunc(impl)
		},
		Metadata: map[string]interface{}{
			"aop":      map[string]interface{}{},
			"autowire": map[string]interface{}{},
		},
	}
	singleton.RegisterStructDescriptor(service1StructDescriptor)
	normal.RegisterStructDescriptor(service1StructDescriptor)
}

type Service1ConstructFunc func(impl *Service1) (*Service1, error)
type service1_ struct {
	SetName_ func(name string)
	GetName_ func() string
}

func (s *service1_) SetName(name string) {
	s.SetName_(name)
}

func (s *service1_) GetName() string {
	return s.GetName_()
}

type Service1IOCInterface interface {
	SetName(name string)
	GetName() string
}

var _service1SDID string

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

func GetService1IOCInterfaceSingleton() (Service1IOCInterface, error) {
	if _service1SDID == "" {
		_service1SDID = util.GetSDIDByStructPtr(new(Service1))
	}
	i, err := singleton.GetImplWithProxy(_service1SDID, nil)
	if err != nil {
		return nil, err
	}
	impl := i.(Service1IOCInterface)
	return impl, nil
}

type ThisService1 struct {
}

func (t *ThisService1) This() Service1IOCInterface {
	thisPtr, _ := GetService1IOCInterfaceSingleton()
	return thisPtr
}

func GetService1() (*Service1, error) {
	if _service1SDID == "" {
		_service1SDID = util.GetSDIDByStructPtr(new(Service1))
	}
	i, err := normal.GetImpl(_service1SDID, nil)
	if err != nil {
		return nil, err
	}
	impl := i.(*Service1)
	return impl, nil
}

func GetService1IOCInterface() (Service1IOCInterface, error) {
	if _service1SDID == "" {
		_service1SDID = util.GetSDIDByStructPtr(new(Service1))
	}
	i, err := normal.GetImplWithProxy(_service1SDID, nil)
	if err != nil {
		return nil, err
	}
	impl := i.(Service1IOCInterface)
	return impl, nil
}
