forked from ezrec/uv3dp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
machines.go
59 lines (47 loc) · 989 Bytes
/
machines.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//
// Copyright (c) 2020 Jason S. McMullan <[email protected]>
//
package uv3dp
import (
"fmt"
)
type MachineSize struct {
X, Y int
Xmm, Ymm float32
}
type Machine struct {
Vendor string
Model string
Size MachineSize
}
type MachineFormat struct {
Machine
Extension string
Args []string
}
var (
MachineFormats = map[string](*MachineFormat){}
)
func RegisterMachine(name string, machine Machine, extension string, args ...string) (err error) {
_, ok := MachineFormats[name]
if ok {
err = fmt.Errorf("name already exists in Machine list")
return
}
machineFormat := &MachineFormat{
Machine: machine,
Extension: extension,
Args: args,
}
MachineFormats[name] = machineFormat
return
}
func RegisterMachines(machineMap map[string]Machine, extension string, args ...string) (err error) {
for name, machine := range machineMap {
err = RegisterMachine(name, machine, extension, args...)
if err != nil {
return
}
}
return
}