mirror of
https://lab.forgefriends.org/friendlyforgeformat/gof3.git
synced 2025-10-06 04:52:41 +02:00
the practical use case is to convert a name into an ID rather than a more general conversion from an arbitrary example
98 lines
2.0 KiB
Go
98 lines
2.0 KiB
Go
// Copyright Earl Warren <contact@earl-warren.org>
|
|
// Copyright Loïc Dachary <loic@dachary.org>
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package generic
|
|
|
|
import (
|
|
"context"
|
|
|
|
"lab.forgefriends.org/friendlyforgeformat/gof3/f3"
|
|
"lab.forgefriends.org/friendlyforgeformat/gof3/logger"
|
|
)
|
|
|
|
type NodeID string
|
|
|
|
var NilID = NodeID("")
|
|
|
|
type NodeAccessorsInterface interface {
|
|
SetIsNil(bool)
|
|
GetIsNil() bool
|
|
|
|
SetIsSync(bool)
|
|
GetIsSync() bool
|
|
|
|
GetParent() NodeInterface
|
|
SetParent(NodeInterface)
|
|
|
|
GetKind() Kind
|
|
SetKind(Kind)
|
|
|
|
GetID() NodeID
|
|
SetID(NodeID)
|
|
|
|
GetTree() TreeInterface
|
|
SetTree(TreeInterface)
|
|
|
|
GetNodeChildren() NodeChildren
|
|
GetChildren() ChildrenSlice
|
|
SetChildren(NodeChildren)
|
|
|
|
GetDriver() NodeDriverInterface
|
|
SetDriver(NodeDriverInterface)
|
|
}
|
|
|
|
type NodeTreeInterface interface {
|
|
GetChild(NodeID) NodeInterface
|
|
GetIDFromName(context.Context, string) NodeID
|
|
SetChild(NodeInterface) NodeInterface
|
|
DeleteChild(NodeID) NodeInterface
|
|
|
|
Find(context.Context, Path) NodeInterface
|
|
|
|
GetCurrentPath() Path
|
|
|
|
Walk(ctx context.Context, parent Path, options *WalkOptions)
|
|
WalkAndGet(ctx context.Context, parent Path, options *WalkOptions)
|
|
Apply(ctx context.Context, parent, path Path, options *ApplyOptions) bool
|
|
|
|
List(context.Context) ChildrenSlice
|
|
}
|
|
|
|
type NodeDriverProxyInterface interface {
|
|
MapIDInterface
|
|
ListPage(context.Context, int) ChildrenSlice
|
|
GetIDFromName(context.Context, string) NodeID
|
|
|
|
Equals(context.Context, NodeInterface) bool
|
|
|
|
Get(context.Context) NodeInterface
|
|
Upsert(context.Context) NodeInterface
|
|
Delete(context.Context) NodeInterface
|
|
|
|
NewFormat() f3.Interface
|
|
FromFormat(f3.Interface) NodeInterface
|
|
ToFormat() f3.Interface
|
|
|
|
LookupMappedID(NodeID) NodeID
|
|
}
|
|
|
|
type MapIDInterface interface {
|
|
GetMappedID() NodeID
|
|
SetMappedID(NodeID)
|
|
}
|
|
|
|
type NodeInterface interface {
|
|
logger.MessageInterface
|
|
NodeAccessorsInterface
|
|
NodeTreeInterface
|
|
NodeDriverProxyInterface
|
|
|
|
Init(NodeInterface) NodeInterface
|
|
|
|
GetSelf() NodeInterface
|
|
SetSelf(NodeInterface)
|
|
|
|
String() string
|
|
}
|