Anonymous avatar Anonymous committed 3ed4d9d

cosmetics + change Object interface

Comments (0)

Files changed (10)

cmd/groot-ls/main.go

 )
 
 var fname = flag.String("f", "ntuple.root", "ROOT file to inspect")
+var detailed = flag.Bool("detailed", false, "enable detailed dump (of trees)")
 //var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
 
+var s_tee = "|--"
+var s_bot = "`--"
+
 func normpath(path []string) string {
 	name := strings.Join(path, "/")
 	if len(name) > 2 && name[:2] == "//" {
 	}
 	keys := dir.Keys()
 	nkeys := len(keys)
-	str := "|--"
+	str := s_tee
 	//fmt.Printf("%s%s -> #%d key(s)\n", indent, name, len(keys))
 	for i, k := range keys {
 		if i+1 >= nkeys {
-			str = "`--"
+			str = s_bot
 		}
 		switch v := k.Value().(type) {
 		default:
 			inspect(v, path, indent+"    ")
 
 		case *groot.Tree:
+			nbranches := len(v.Branches())
 			fmt.Printf("%s%s %s title='%s' entries=%v nbranches=%v type=%s\n",
 				indent, str, 
-				k.Name(), k.Title(), v.Entries(), len(v.Branches()), k.Class())
+				k.Name(), k.Title(), v.Entries(), nbranches, k.Class())
+			if *detailed {
+				strbr := s_tee
+				for i,branch := range v.Branches() {
+					if i+1 >= nbranches {
+						strbr = s_bot
+					}
+					fmt.Printf(" %s%s%s %s type=%s\n",
+						indent, "   ", strbr, branch.Name(), branch.Class())
+				}
+			}
 		}
 	}
 }

pkg/groot/branch.go

 	return branch
 }
 
-func (branch *Branch) Class() Class {
-	panic("not implemented")
+func (branch *Branch) Class() string {
+	return "TBranch"
 }
 
 func (branch *Branch) Name() string {

pkg/groot/branch_element.go

 	return &be.branch
 }
 
-func (be *BranchElement) Class() Class {
+func (be *BranchElement) Class() string {
 	panic("not implemented")
 }
 

pkg/groot/dummy_object.go

 type dummyObject struct {
 }
 
-func (d *dummyObject) Class() Class {
-	panic("not implemented")
+func (d *dummyObject) Class() string {
+	return "dummy-object-type"
 }
 
 func (d *dummyObject) Name() string {

pkg/groot/ifaces.go

 // Object represents a ROOT object
 type Object interface {
 	// Class returns the ROOT class of this object
-	Class() Class
+	Class() string
 
 	// Name returns the name of this ROOT object
 	Name() string

pkg/groot/leaf.go

 	return &leaf.base
 }
 
-func (leaf *LeafB) Class() Class {
-	panic("not implemented")
+func (leaf *LeafB) Class() string {
+	return "TLeafB"
 }
 
 func (leaf *LeafB) Name() string {
 	return &leaf.base
 }
 
-func (leaf *LeafS) Class() Class {
-	panic("not implemented")
+func (leaf *LeafS) Class() string {
+	return "TLeafS"
 }
 
 func (leaf *LeafS) Name() string {
 	return &leaf.base
 }
 
-func (leaf *LeafI) Class() Class {
-	panic("not implemented")
+func (leaf *LeafI) Class() string {
+	return "TLeafI"
 }
 
 func (leaf *LeafI) Name() string {
 	return &leaf.base
 }
 
-func (leaf *LeafL) Class() Class {
-	panic("not implemented")
+func (leaf *LeafL) Class() string {
+	return "TLeafL"
 }
 
 func (leaf *LeafL) Name() string {
 	return &leaf.base
 }
 
-func (leaf *LeafF) Class() Class {
-	panic("not implemented")
+func (leaf *LeafF) Class() string {
+	return "TLeafF"
 }
 
 func (leaf *LeafF) Name() string {
 	return &leaf.base
 }
 
-func (leaf *LeafD) Class() Class {
-	panic("not implemented")
+func (leaf *LeafD) Class() string {
+	return "TLeafD"
 }
 
 func (leaf *LeafD) Name() string {
 	return &leaf.base
 }
 
-func (leaf *LeafC) Class() Class {
-	panic("not implemented")
+func (leaf *LeafC) Class() string {
+	return "TLeafC"
 }
 
 func (leaf *LeafC) Name() string {
 	return &leaf.base
 }
 
-func (leaf *LeafO) Class() Class {
-	panic("not implemented")
+func (leaf *LeafO) Class() string {
+	return "TLeafO"
 }
 
 func (leaf *LeafO) Name() string {

pkg/groot/leaf_element.go

 	return &le.base
 }
 
-func (le *LeafElement) Class() Class {
-	panic("not implemented")
+func (le *LeafElement) Class() string {
+	return "TLeafElement"
 }
 
 func (le *LeafElement) Name() string {

pkg/groot/list.go

 
 type List []Object
 
-func (lst *List) Class() Class {
-	panic("not implemented")
+func (lst *List) Class() string {
+	return "TList"
 }
 
 func (lst *List) Name() string {

pkg/groot/streamerinfo.go

 	elmts     []Object
 }
 
-func (si *StreamerInfo) Class() Class {
-	panic("not implemented")
+func (si *StreamerInfo) Class() string {
+	return "TStreamerInfo"
 }
 
 func (si *StreamerInfo) Name() string {

pkg/groot/tree.go

 	return
 }
 
-func (tree *Tree) Class() Class {
-	panic("not implemented")
+func (tree *Tree) Class() string {
+	return "TTree"
 }
 
 func (tree *Tree) Name() string {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.