Skip to content

Commit

Permalink
groot/rbytes: extend StreamerInfo interface, introduce Binder and Cou…
Browse files Browse the repository at this point in the history
…nter interfaces
  • Loading branch information
sbinet committed Sep 18, 2020
1 parent f50205a commit 1985569
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
13 changes: 13 additions & 0 deletions groot/rbytes/rbytes.go
Expand Up @@ -35,6 +35,9 @@ type StreamerInfo interface {

NewDecoder(kind StreamKind, r *RBuffer) (Decoder, error)
NewEncoder(kind StreamKind, w *WBuffer) (Encoder, error)

NewRStreamer(kind StreamKind) (RStreamer, error)
NewWStreamer(kind StreamKind) (WStreamer, error)
}

// StreamKind describes whether a composite ROOT value was encoded
Expand Down Expand Up @@ -122,6 +125,16 @@ type Streamer interface {
RStreamer
}

// Binder wraps the Bind method.
type Binder interface {
Bind(ptr interface{}) error
}

// Counter wraps the Count method.
type Counter interface {
Count(f func() int) error
}

const (
BypassStreamer uint32 = 1 << 12
CannotHandleMemberWiseStreaming uint32 = 1 << 17
Expand Down
34 changes: 34 additions & 0 deletions groot/rbytes/rbytes_test.go
@@ -0,0 +1,34 @@
// Copyright ©2020 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 rbytes

import "testing"

func TestStreamKind(t *testing.T) {
for _, tc := range []struct {
kind StreamKind
want string
}{
{
kind: ObjectWise,
want: "object-wise",
},
{
kind: MemberWise,
want: "member-wise",
},
{
kind: 255,
want: "0xff",
},
} {
t.Run(tc.want, func(t *testing.T) {
got := tc.kind.String()
if got != tc.want {
t.Fatalf("invalid kind: got=%q, want=%q", got, tc.want)
}
})
}
}

0 comments on commit 1985569

Please sign in to comment.