//
// Script to check reading one version of Data, and then read it back
// with another version, and making sure that we detect that we're
// reading and old version. 
// 
void TestData() 
{
  std::cout << "Please do one of `ReadIt()' or `WriteIt()'" << std::endl;
}

void Compile(Int_t i) 
{
  gSystem->Exec(Form("sed 's/@version@/%d/' < Data.C.in > Data.C", i));
  gSystem->Exec(Form("rootcint -f Dict.cxx  -c Data.C%s", 
		     (i == 1 ? "+" : "-")));
  gSystem->Exec("g++ -I/usr/include/root -c Dict.cxx");
  gSystem->Exec("g++ -I/usr/include/root -c Data.C");
  gSystem->Exec("g++ -shared -o Data.so Data.o Dict.o");
  gSystem->Load("Data.so");
  gSystem->Exec("rm -f *.o Dict.cxx Dict.h");
}


void WriteIt() 
{
  Compile(1);
  TFile file("foo.root", "RECREATE");
  Data d(42);
  d.Print();
  d.Write("data");
  file.Close();
  gApplication->Terminate();
}

void ReadIt()
{
  Compile(2);
  TFile file("foo.root", "READ");
  Data* d = static_cast<Data*>(file.Get("data"));
  d->Print();
  file.Close();
  gApplication->Terminate();
}
//
// EOF
//

