Re: [ROOT] Human readable/writeable I/O?

From: Valeri Fine (fine@bnl.gov)
Date: Wed Jan 23 2002 - 17:21:48 MET


Hello Brett,

We solved the similar problem for STAR 4 years ago.

To solve the problem like yours STAR / Atlas  "ROOT naive database"
is populated with  macros like:


TTable * CreateTable()
{
  St_tpc_track_Table *t = new St_tpc_track_Table("track");
  // Fill this object somehow
  return t;
}

You can load and execute this macro from within your code to get the pointer
to TTable. (TObject if you want). The only thing you should do you should adopt
some "pattern". Each your macro contains some known function and return
some "known" pointer *TTable, TObject , your own base class)

Macro itself can be kept in the real file system directory tree.
So you (your user) can create the hierarchy with "mkdir shell command".
You can keep this file tree with your SVC repository and you can convert this file tree
in  to the memory object with TFileSet class to navigate it.
Just you find the suitable node you know the file name and its directory, So you can
load it

See:  ATDataSet *RootDbModule::LoadTable(ATDataSet* left) from

http://atlassw1.phy.bnl.gov/cgi-bin/cvsweb.cgi/offline/Database/AthenaRoot/RootSvcModules/src/RootDbModule.cxx?rev=1.1.1.1&conte
nt-type=text/x-cvsweb-markup

for detail.

  Hope this helps
                               Valeri

-----
Dr.Valeri Fine
STAR/US Atlas                                    E-mail: fine@bnl.gov
Brookhaven National Lab                Phone: +1 631 344 7806
Upton, NY 11973-5000                       FAX:     +1 631 344 4206
USA



----- Original Message -----
From: "Brett Viren" <bv@bnl.gov>
To: "Rene Brun" <Rene.Brun@cern.ch>
Cc: <roottalk@pcroot.cern.ch>
Sent: Wednesday, January 23, 2002 10:33 AM
Subject: Re: [ROOT] Human readable/writeable I/O?


> Thanks Rene and Valeriy.
>
> Implementing SavePrimitive() seems like it should work, I'll give it a
> try.
>
> One thing:  Assuming I produce output which looks something like:
>
>     // output.C file:
>     Registry* reg = new Registry()
>     reg->Set("key1","val1");
>     reg->Set("key2",42);
>     reg->Set("key3",6.9);
>
>     Registry* reg2 = new Registry();
>     reg2->Set("key1","1lav");
>     reg2->Set("key2",24);
>     reg2->Set("key3",9.6);
>
>     reg->Set("reg2",*reg2);
>
>     // more state initializations ....
>
> After having CINT read this file back in, I am unsure how to get the
> pointer (reg) to the created Registry object from CINT into my
> compiled code.  Also, do I need to explictly tell CINT to delete the
> created pointers (reg and reg2 in the example above)?
>
> Thanks,
> -Brett.
>
>
> Rene Brun writes:
>  > Hi Brett,
>  >
>  > As already indicated by Valery, implementing MyClass::SavePrimitive
>  > is the solution to your problem if you want a readable version of the file.
>  > SavePrimitive is implemented for most ROOT classes that appear in a canvas:
>  > all graphics primitives, TGraph, TH1, TCanvas, TPad, etc.
>  > In SavePrimitive, you generate the C++ code to rebuild the objects with
>  > their attributes. This code can be edited and reexecuted by CINT again.
>  > I strongly encourage people to implement the SavePrimitive function
>  > for their classes.
>  >
>  > I am also considering the generation of ascii files via the TStreamerInfo
>  > class. XML is a likely choice. I agree with you that XML is NOT an input
>  > format. I have seen that most attempts to use XML as an input format have
>  > failed so far. But XML is a good candidate for an interchange format
>  > between different applications when the volume of data to be exchanged is small.
>  > The problem is not writing the XML file, but the choice of a good DTD.
>  >
>  > Rene Brun
>  >
>  > Brett Viren wrote:
>  > >
>  > > Hi,
>  > >
>  > > I have a container class: a heterogeneous map from string keys to
>  > > values of type char, int, double, string and itself (that is, it can
>  > > be used to form a hierarchical tree).  Currently it can be be
>  > > read/written via ROOT streamers.  It is typically used to hold
>  > > configuration data.
>  > >
>  > > I am looking for a way to write it out as plain text in a form that
>  > > can be edited in a text editor and subsequently read back in.
>  > >
>  > > Does anyone have any ideas?  (Please, no XML).
>  > >
>  > > Thanks,
>  > > -Brett.
>



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:39 MET