Hi Sebastien,
The work need is similar to the work done by Cintex for Reflex. For example the answer to your direct question is somewhat in the file cint/cintex/src/ROOTClassEnhancer.cxx
Cheers,
Philippe.
On 5/4/11 12:00 PM, Sebastien Binet wrote:
> hi there,
>
> I am playing with Go (the language at golang.org) and trying to see if
> one could use ROOT as an I/O back-end.
>
> Go has built-in reflection capabilities so theoretically any Go struct
> can be described at runtime/compiletime and converted to a Reflex or
> CINT metadata.
> Moreover, Go-struct usually have the same layout than their C cousin
> (that's not true for Go-strings and Go-slices (which are views into
> arrays))
>
> the amount of work on my side to be able to support the below kind of
> code should be rather minimal:
>
> // ---
> type MyStruct struct {
> IntData [10]int32
> FloatData [20]float64
> }
>
> f := ROOT.NewFile("foo.root", "recreate")
> t := ROOT.NewTree("tree", "title")
> s := MyStruct{}
> t.Branch("mystruct",&s) //<---
> // ---
>
> From my end, I would need to create a ROOT::TClass instance for the
> Go-struct MyStruct leveraging Go's "reflect" package which knows the types
> and offsets of each data member.
>
> is this possible without reaching to automatically generated code ?
> (rootcint|genreflex)
> that would simplify the amount of infrastructure to provide...
>
> -s
>
> PS: right now, I am just unfolding the struct and register branches like
> so (in pseudo-code):
> for f := range typ.Fields() {
> s := "mystruct_"+f.Name()
> field_addr := obj.Address()+f.Offset()
> branch_typ := s+"/"+go2ctype[f.Type()].Name()
> tree.Branch(s, field_addr, branch_typ)
> }
>
Received on Wed May 04 2011 - 19:43:00 CEST
This archive was generated by hypermail 2.2.0 : Tue May 10 2011 - 23:50:01 CEST