model

package
v0.0.0-...-db00685 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ModelConfig = TerradimConfigMap{
	"dim1": &TerradimConfig{Config: nodeConfig{}},
	"dim2": &TerradimConfig{Config: nodeConfig{}},
}

ModelConfig list enumerable dirs

Functions

func Copy

func Copy(src, dst string) (err error)

Copy file or dir from src to dst

func Create

func Create(srcpath, dstpath string) (*Tree, *BuildConfig)

Create tree model

func WalkSubtree

func WalkSubtree(node *Node, walkFn WalkFunc, data interface{}) error

WalkSubtree visits children of a node and runs WalkFunc

func Write

func Write(t *Tree, config *BuildConfig) error

Write model to file

Types

type BuildConfig

type BuildConfig struct {
	ConfigMap      TerradimConfigMap
	FileRootPrefix string
	FileOutPrefix  string
	PathSeparator  string
}

BuildConfig contains all build congig details

type Node

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

Node is used to represent edge and leaf nodes

func (*Node) Children

func (n *Node) Children() []*Node

Children returns children stored in node

func (*Node) IsLeaf

func (n *Node) IsLeaf() bool

IsLeaf returns true if node has no children

func (*Node) IsRoot

func (n *Node) IsRoot() bool

IsRoot returns true if node has no parent

func (*Node) Key

func (n *Node) Key() string

Key returns node key

func (*Node) Meta

func (n *Node) Meta() interface{}

Meta returns data stored in node

func (*Node) Path

func (n *Node) Path() string

Path returns full node path

func (*Node) Sep

func (n *Node) Sep() string

Sep returns node sep

type NodeMeta

type NodeMeta struct {
	Dirname  string
	Basename string
	Size     int64
	IsDir    bool
	IsEnum   bool
	IsConfig bool
}

NodeMeta comment

type TerradimConfig

type TerradimConfig struct {
	Path   string
	Config nodeConfig
}

TerradimConfig is the marshalled config for a terrdim file (ex. n1.yaml)

type TerradimConfigMap

type TerradimConfigMap map[string]*TerradimConfig

TerradimConfigMap hold paths for terradim enum dirs

type Tree

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

Tree implements a directory trie using substrings between separator strings

func NewFromMap

func NewFromMap(treeMap map[string]interface{}) *Tree

NewFromMap returns a new tree from a map with paths as keys and meta as values

func NewTree

func NewTree() *Tree

NewTree returns a new tree

func (*Tree) Find

func (t *Tree) Find(path string) (*Node, bool)

Find node in tree by path

func (*Tree) Insert

func (t *Tree) Insert(path string, meta interface{}) (node *Node, isNew bool)

Insert or update tree node at given path

func (*Tree) Root

func (t *Tree) Root() *Node

Root returns root node in tree

func (*Tree) Separator

func (t *Tree) Separator() string

Separator for tree

func (*Tree) SetSeparator

func (t *Tree) SetSeparator(separator string)

SetSeparator for tree

func (*Tree) Size

func (t *Tree) Size() int

Size return number of nodes in tree

type WalkFunc

type WalkFunc func(node *Node, data interface{}) (bool, error)

WalkFunc is func signature for WalkSubtree

Jump to

Keyboard shortcuts

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