// -*- mode: C++ -*-
#ifndef DATA_H
#define DATA_H 

#include <TObject.h>
#include <TClass.h>
#include <TBuffer.h>
#include <TFile.h>
#include <iostream>

// Data class 
struct Data : public TObject 
{
  Data() : fData(0) { }
  Data(Int_t v ) : fData(v) {}
  void Print(Option_t* option="") const;
#if @version@ > 1
  enum {
    kNeedBugFix = 18 // Bit to set if reading version 1 
  };
#endif
private:
  Int_t fData;
  ClassDef(Data,@version@)
};

// Print information 
inline void
Data::Print(Option_t* ) const
{
  std::cout << "Data: " << fData << " (code: @version@)" << std::endl;
#if @version@ > 1
  if (TestBit(kNeedBugFix)) 
    std::cout << "I need the bug fix" << std::endl;
#endif
}


#if @version@ == 2
// Specialised streamer that will detect if we're reading version 1 of
// the class.  If so, we set a flag in the bits so that we can recover
// probably
inline
void Data::Streamer(TBuffer &R__b)
{
  // Stream an object of class AliESDFMD.
  if (R__b.IsReading()) {
    // read the class version from the buffer
    UInt_t R__s, R__c;
    Version_t version = R__b.ReadVersion(&R__s, &R__c, this->Class());
    TFile *file = (TFile*)R__b.GetParent();
    if (file && file->GetVersion() < 30000) version = -1; 
    Data::Class()->ReadBuffer(R__b, this, version, R__s, R__c);
    // Set the bit if we need to. 
    if (version == 1) SetBit(kNeedBugFix);
  } else {
    Data::Class()->WriteBuffer(R__b, this);
  }
}
#endif

#endif
//
// EOF
//


