sgc7plugin

package
v0.10.208 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidTag - invalid tag
	ErrInvalidTag = errors.New("invalid tag")
)

Functions

This section is empty.

Types

type BasicPlugin

type BasicPlugin struct {
	RngUsed []*sgc7utils.RngInfo
	Cache   []int
	Tag     int
}

BasicPlugin - basic plugin

func NewBasicPlugin

func NewBasicPlugin() *BasicPlugin

NewBasicPlugin - new a BasicPlugin

func (*BasicPlugin) AddRngUsed

func (bp *BasicPlugin) AddRngUsed(ri *sgc7utils.RngInfo)

AddRngUsed - added used rngs

func (*BasicPlugin) ClearCache

func (bp *BasicPlugin) ClearCache()

ClearCache - clear cached rngs

func (*BasicPlugin) ClearUsedRngs

func (bp *BasicPlugin) ClearUsedRngs()

ClearUsedRngs - clear used rngs

func (*BasicPlugin) GetUsedRngs

func (bp *BasicPlugin) GetUsedRngs() []*sgc7utils.RngInfo

GetUsedRngs - get used rngs

func (*BasicPlugin) Init

func (bp *BasicPlugin) Init()

Init - initial

func (*BasicPlugin) Random

func (bp *BasicPlugin) Random(ctx context.Context, r int) (int, error)

Random - return [0, r)

func (*BasicPlugin) RollbackUsedRngs

func (bp *BasicPlugin) RollbackUsedRngs() error

RollbackUsedRngs - rollback UsedRngs with a tag

func (*BasicPlugin) SetCache

func (bp *BasicPlugin) SetCache(arr []int)

SetCache - set cache

func (*BasicPlugin) TagUsedRngs

func (bp *BasicPlugin) TagUsedRngs()

TagUsedRngs - new a tag for current UsedRngs

type FuncNewPlugin

type FuncNewPlugin func() IPlugin

FuncNewPlugin - new a IPlugin

type IPlugin

type IPlugin interface {
	// Random - return [0, r)
	Random(ctx context.Context, r int) (int, error)
	// GetUsedRngs - get used rngs
	GetUsedRngs() []*sgc7utils.RngInfo
	// ClearUsedRngs - clear used rngs
	ClearUsedRngs()
	// TagUsedRngs - new a tag for current UsedRngs
	TagUsedRngs()
	// RollbackUsedRngs - rollback UsedRngs with the latest tag
	RollbackUsedRngs() error
	// SetCache - set cache
	SetCache(arr []int)
	// ClearCache - clear cached rngs
	ClearCache()
	// Init - initial
	Init()
}

IPlugin - plugin

type PluginsMgr

type PluginsMgr struct {
	// contains filtered or unexported fields
}

PluginsMgr - plugins manager

func NewPluginsMgr

func NewPluginsMgr(funcNewPlugin FuncNewPlugin) *PluginsMgr

NewPluginsMgr - new a PluginsMgr

func (*PluginsMgr) FreePlugin

func (mgr *PluginsMgr) FreePlugin(plugin IPlugin)

FreePlugin - free a Plugin

func (*PluginsMgr) NewPlugin

func (mgr *PluginsMgr) NewPlugin() IPlugin

NewPlugin - new a Plugin

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL