/
attline.go
82 lines (67 loc) · 1.49 KB
/
attline.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Copyright ©2017 The go-hep Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package rbase
import (
"fmt"
"reflect"
"go-hep.org/x/hep/groot/rbytes"
"go-hep.org/x/hep/groot/rcolors"
"go-hep.org/x/hep/groot/root"
"go-hep.org/x/hep/groot/rtypes"
"go-hep.org/x/hep/groot/rvers"
)
type AttLine struct {
Color int16
Style int16
Width int16
}
func NewAttLine() *AttLine {
return &AttLine{
Color: rcolors.Blue + 2,
Style: 1,
Width: 1,
}
}
func (*AttLine) Class() string {
return "TAttLine"
}
func (*AttLine) RVersion() int16 {
return rvers.AttLine
}
func (a *AttLine) MarshalROOT(w *rbytes.WBuffer) (int, error) {
if w.Err() != nil {
return 0, w.Err()
}
hdr := w.WriteHeader(a.Class(), a.RVersion())
w.WriteI16(a.Color)
w.WriteI16(a.Style)
w.WriteI16(a.Width)
return w.SetHeader(hdr)
}
func (a *AttLine) UnmarshalROOT(r *rbytes.RBuffer) error {
if r.Err() != nil {
return r.Err()
}
hdr := r.ReadHeader(a.Class())
if hdr.Vers > rvers.AttLine {
panic(fmt.Errorf("rbase: invalid attline version=%d > %d", hdr.Vers, rvers.AttLine))
}
a.Color = r.ReadI16()
a.Style = r.ReadI16()
a.Width = r.ReadI16()
r.CheckHeader(hdr)
return r.Err()
}
func init() {
f := func() reflect.Value {
o := NewAttLine()
return reflect.ValueOf(o)
}
rtypes.Factory.Add("TAttLine", f)
}
var (
_ root.Object = (*AttLine)(nil)
_ rbytes.Marshaler = (*AttLine)(nil)
_ rbytes.Unmarshaler = (*AttLine)(nil)
)