Notes added by 'git notes append'
This commit is contained in:
parent
15a85ff6e3
commit
20176100a7
|
@ -354,3 +354,173 @@ func file_toolkitConfig_proto_init() {
|
|||
}
|
||||
|
||||
// `autogen:toolkitConfig.sort.pb.go`
|
||||
|
||||
// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT.
|
||||
// This file was autogenerated with autogenpb v0.0.52-1-g4fdcc99 2025.02.12_1512
|
||||
// go install go.wit.com/apps/autogenpb@latest
|
||||
//
|
||||
// define which structs (messages) you want to use in the .proto file
|
||||
// Then sort.pb.go and marshal.pb.go files are autogenerated
|
||||
//
|
||||
// autogenpb uses it and has an example .proto file with instructions
|
||||
//
|
||||
|
||||
package tree
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// a simple global lock
|
||||
var toolkitConfigMu sync.RWMutex
|
||||
|
||||
func (x *ToolkitConfigs) fixUuid() {
|
||||
if x == nil {
|
||||
return
|
||||
}
|
||||
if x.Uuid == "d7886d47-a3b9-43b9-b0f6-17074a9844e6" {
|
||||
return
|
||||
}
|
||||
x.Uuid = "d7886d47-a3b9-43b9-b0f6-17074a9844e6"
|
||||
x.Version = "v0.0.1 go.wit.com/toolkits/tree"
|
||||
}
|
||||
|
||||
func NewToolkitConfigs() *ToolkitConfigs {
|
||||
x := new(ToolkitConfigs)
|
||||
x.Uuid = "d7886d47-a3b9-43b9-b0f6-17074a9844e6"
|
||||
x.Version = "v0.0.1 go.wit.com/toolkits/tree"
|
||||
return x
|
||||
}
|
||||
|
||||
// START SORT
|
||||
|
||||
// DEFINE THE ToolkitConfigs ITERATOR.
|
||||
// itializes a new iterator.
|
||||
func newToolkitConfigsIterator(things []*ToolkitConfigs) *ToolkitConfigsIterator {
|
||||
return &ToolkitConfigsIterator{things: things}
|
||||
}
|
||||
|
||||
type ToolkitConfigsIterator struct {
|
||||
sync.RWMutex // this isn't getting used properly yet?
|
||||
|
||||
things []*ToolkitConfigs
|
||||
index int
|
||||
}
|
||||
|
||||
func (it *ToolkitConfigsIterator) Scan() bool {
|
||||
if it.index >= len(it.things) {
|
||||
return false
|
||||
}
|
||||
it.index++
|
||||
return true
|
||||
}
|
||||
|
||||
// Next() returns the next thing in the array
|
||||
func (it *ToolkitConfigsIterator) Next() *ToolkitConfigs {
|
||||
if it.things[it.index-1] == nil {
|
||||
fmt.Println("Next() error in ToolkitConfigsIterator", it.index)
|
||||
}
|
||||
return it.things[it.index-1]
|
||||
}
|
||||
|
||||
// END DEFINE THE ITERATOR
|
||||
|
||||
// DEFINE THE ToolkitConfig ITERATOR.
|
||||
// itializes a new iterator.
|
||||
func newToolkitConfigIterator(things []*ToolkitConfig) *ToolkitConfigIterator {
|
||||
return &ToolkitConfigIterator{things: things}
|
||||
}
|
||||
|
||||
type ToolkitConfigIterator struct {
|
||||
sync.RWMutex // this isn't getting used properly yet?
|
||||
|
||||
things []*ToolkitConfig
|
||||
index int
|
||||
}
|
||||
|
||||
func (it *ToolkitConfigIterator) Scan() bool {
|
||||
if it.index >= len(it.things) {
|
||||
return false
|
||||
}
|
||||
it.index++
|
||||
return true
|
||||
}
|
||||
|
||||
// Next() returns the next thing in the array
|
||||
func (it *ToolkitConfigIterator) Next() *ToolkitConfig {
|
||||
if it.things[it.index-1] == nil {
|
||||
fmt.Println("Next() error in ToolkitConfigIterator", it.index)
|
||||
}
|
||||
return it.things[it.index-1]
|
||||
}
|
||||
|
||||
// END DEFINE THE ITERATOR
|
||||
|
||||
// safely returns a slice of pointers to the FRUIT protobufs
|
||||
func (x *ToolkitConfigs) allToolkitConfigs() []*ToolkitConfig {
|
||||
toolkitConfigMu.RLock()
|
||||
defer toolkitConfigMu.RUnlock()
|
||||
|
||||
// Create a new slice to hold pointers to each FRUIT
|
||||
var tmp []*ToolkitConfig
|
||||
tmp = make([]*ToolkitConfig, len(x.ToolkitConfigs))
|
||||
for i, p := range x.ToolkitConfigs {
|
||||
tmp[i] = p // Copy pointers for safe iteration
|
||||
}
|
||||
|
||||
return tmp
|
||||
}
|
||||
|
||||
// safely returns a slice of pointers to the ToolkitConfig protobufs
|
||||
func (x *ToolkitConfigs) selectAllToolkitConfigs() []*ToolkitConfig {
|
||||
toolkitConfigMu.RLock()
|
||||
defer toolkitConfigMu.RUnlock()
|
||||
|
||||
// Create a new slice to hold pointers to each ToolkitConfig
|
||||
var tmp []*ToolkitConfig
|
||||
tmp = make([]*ToolkitConfig, len(x.ToolkitConfigs))
|
||||
for i, p := range x.ToolkitConfigs {
|
||||
tmp[i] = p // Copy pointers for safe iteration
|
||||
}
|
||||
|
||||
return tmp
|
||||
}
|
||||
|
||||
// END SORT
|
||||
|
||||
func (x *ToolkitConfigs) Len() int {
|
||||
toolkitConfigMu.RLock()
|
||||
defer toolkitConfigMu.RUnlock()
|
||||
|
||||
return len(x.ToolkitConfigs)
|
||||
}
|
||||
|
||||
// just a simple Append() shortcut (but still uses the mutex lock)
|
||||
func (x *ToolkitConfigs) Append(y *ToolkitConfig) {
|
||||
toolkitConfigMu.Lock()
|
||||
defer toolkitConfigMu.Unlock()
|
||||
|
||||
x.ToolkitConfigs = append(x.ToolkitConfigs, y)
|
||||
}
|
||||
|
||||
func (x *ToolkitConfigs) All() *ToolkitConfigIterator {
|
||||
ToolkitConfigPointers := x.selectAllToolkitConfigs()
|
||||
|
||||
iterator := newToolkitConfigIterator(ToolkitConfigPointers)
|
||||
return iterator
|
||||
}
|
||||
|
||||
func (x *ToolkitConfigs) Delete(y *ToolkitConfig) bool {
|
||||
toolkitConfigMu.Lock()
|
||||
defer toolkitConfigMu.Unlock()
|
||||
|
||||
for i, _ := range x.ToolkitConfigs {
|
||||
if x.ToolkitConfigs[i] == y {
|
||||
x.ToolkitConfigs[i] = x.ToolkitConfigs[len(x.ToolkitConfigs)-1]
|
||||
x.ToolkitConfigs = x.ToolkitConfigs[:len(x.ToolkitConfigs)-1]
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue