Re: Persistency of custom container

From: Roel Aaij <Roel.Aaij_at_cern.ch>
Date: Sun, 3 Jan 2010 21:27:54 +0100


Hi Axel,

I've continued my exercise and have created a new container that is essentially a thin wrapper around an std::vector< TYPE* >. I've called my class DataStdVector and generated a reflex dictionary for it. DataStdVector inherits from DataObject. I also have a class Track, which inherits from DataObject. I want to store these in my DataStdVector and write the collection to a file.

I would like to write my vector to the file using a pointer to DataObject, so is the following supposed to work?

DataStdVector< Track >* v = new DataStdVector; Track* t = new Track( 1, 1000 );
v->push_back( t );
DataObject* d = v;

TFile f( "test.root" )
f.WriteObjectAny( d, "DataStdVector<Track>", "Tracks" );

If I load and enable Cintex and open the file, I can read the object, but there are no tracks in the container. If I replace the last line by:

f.WriteObjectAny( v, "DataStdVector<Track>", "Tracks" );

It works.

As a sidenote, DataObject contains a pointer to the container that contains it. I've declared this data member transient in my selection.xml file.

Greetings, Roel Received on Sun Jan 03 2010 - 21:28:05 CET

This archive was generated by hypermail 2.2.0 : Mon Jan 04 2010 - 11:50:01 CET