go-hep.org/x/hep@v0.38.1/groot/rbase/attmarker.go (about) 1 // Copyright ©2017 The go-hep Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package rbase 6 7 import ( 8 "reflect" 9 10 "go-hep.org/x/hep/groot/rbytes" 11 "go-hep.org/x/hep/groot/root" 12 "go-hep.org/x/hep/groot/rtypes" 13 "go-hep.org/x/hep/groot/rvers" 14 ) 15 16 type AttMarker struct { 17 Color int16 18 Style int16 19 Width float32 20 } 21 22 func NewAttMarker() *AttMarker { 23 return &AttMarker{ 24 Color: 1, 25 Style: 1, 26 Width: 1, 27 } 28 } 29 30 func (*AttMarker) Class() string { 31 return "TAttMarker" 32 } 33 34 func (*AttMarker) RVersion() int16 { 35 return rvers.AttMarker 36 } 37 38 func (a *AttMarker) MarshalROOT(w *rbytes.WBuffer) (int, error) { 39 if w.Err() != nil { 40 return 0, w.Err() 41 } 42 43 hdr := w.WriteHeader(a.Class(), a.RVersion()) 44 w.WriteI16(a.Color) 45 w.WriteI16(a.Style) 46 w.WriteF32(a.Width) 47 return w.SetHeader(hdr) 48 } 49 50 func (a *AttMarker) UnmarshalROOT(r *rbytes.RBuffer) error { 51 if r.Err() != nil { 52 return r.Err() 53 } 54 55 hdr := r.ReadHeader(a.Class(), a.RVersion()) 56 57 a.Color = r.ReadI16() 58 a.Style = r.ReadI16() 59 a.Width = r.ReadF32() 60 61 r.CheckHeader(hdr) 62 return r.Err() 63 } 64 65 func (a *AttMarker) RMembers() []rbytes.Member { 66 return []rbytes.Member{ 67 {Name: "fMarkerColor", Value: &a.Color}, 68 {Name: "fMarkerStyle", Value: &a.Style}, 69 {Name: "fMarkerSize", Value: &a.Width}, 70 } 71 } 72 73 func init() { 74 f := func() reflect.Value { 75 o := NewAttMarker() 76 return reflect.ValueOf(o) 77 } 78 rtypes.Factory.Add("TAttMarker", f) 79 } 80 81 var ( 82 _ root.Object = (*AttMarker)(nil) 83 _ rbytes.Marshaler = (*AttMarker)(nil) 84 _ rbytes.Unmarshaler = (*AttMarker)(nil) 85 )