go-hep.org/x/hep@v0.38.1/groot/rbase/attfill.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 AttFill struct { 17 Color int16 18 Style int16 19 } 20 21 func NewAttFill() *AttFill { 22 return &AttFill{ 23 Color: 0, 24 Style: 1001, // FIXME(sbinet) 25 } 26 } 27 28 func (*AttFill) Class() string { 29 return "TAttFill" 30 } 31 32 func (*AttFill) RVersion() int16 { 33 return rvers.AttFill 34 } 35 36 func (a *AttFill) MarshalROOT(w *rbytes.WBuffer) (int, error) { 37 if w.Err() != nil { 38 return 0, w.Err() 39 } 40 41 hdr := w.WriteHeader(a.Class(), a.RVersion()) 42 w.WriteI16(a.Color) 43 w.WriteI16(a.Style) 44 return w.SetHeader(hdr) 45 } 46 47 func (a *AttFill) UnmarshalROOT(r *rbytes.RBuffer) error { 48 if r.Err() != nil { 49 return r.Err() 50 } 51 52 hdr := r.ReadHeader(a.Class(), a.RVersion()) 53 54 a.Color = r.ReadI16() 55 a.Style = r.ReadI16() 56 57 r.CheckHeader(hdr) 58 return r.Err() 59 } 60 61 func (a *AttFill) RMembers() []rbytes.Member { 62 return []rbytes.Member{ 63 {Name: "fFillColor", Value: &a.Color}, 64 {Name: "fFillStyle", Value: &a.Style}, 65 } 66 } 67 68 func init() { 69 f := func() reflect.Value { 70 o := NewAttFill() 71 return reflect.ValueOf(o) 72 } 73 rtypes.Factory.Add("TAttFill", f) 74 } 75 76 var ( 77 _ root.Object = (*AttFill)(nil) 78 _ rbytes.Marshaler = (*AttFill)(nil) 79 _ rbytes.Unmarshaler = (*AttFill)(nil) 80 )