go-hep.org/x/hep@v0.38.1/groot/riofs/dobj.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 riofs
     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  )
    14  
    15  // dobject is a dummy placeholder object
    16  type dobject struct {
    17  	rvers int16
    18  	size  int32
    19  	class string
    20  }
    21  
    22  func (d dobject) Class() string {
    23  	return d.class
    24  }
    25  
    26  func (d *dobject) SetClass(n string) { d.class = n }
    27  
    28  func (d *dobject) UnmarshalROOT(r *rbytes.RBuffer) error {
    29  	if r.Err() != nil {
    30  		return r.Err()
    31  	}
    32  
    33  	hdr := r.ReadHeader(d.class, -1)
    34  	d.rvers = hdr.Vers
    35  	d.size = hdr.Len
    36  	r.SetPos(hdr.Pos + int64(hdr.Len) + 4)
    37  	r.CheckHeader(hdr)
    38  	return r.Err()
    39  }
    40  
    41  func init() {
    42  	{
    43  		f := func() reflect.Value {
    44  			o := &dobject{class: "*groot.dobject"}
    45  			return reflect.ValueOf(o)
    46  		}
    47  		rtypes.Factory.Add("*groot.dobject", f)
    48  	}
    49  }
    50  
    51  var (
    52  	_ root.Object        = (*dobject)(nil)
    53  	_ rbytes.Unmarshaler = (*dobject)(nil)
    54  )