#ifndef ROOT_TTVSession
#define ROOT_TTVSession
#ifndef ROOT_TGFrame
#include "TGFrame.h"
#endif
class TTreeViewer;
class TClonesArray;
class TGVButtonGroup;
class TTVRecord : public TObject {
public:
TString fName;
TString fX, fXAlias;
TString fY, fYAlias;
TString fZ, fZAlias;
TString fCut, fCutAlias;
TString fOption;
Bool_t fScanRedirected;
Bool_t fCutEnabled;
TString fUserCode;
Bool_t fAutoexec;
public:
TTVRecord();
~TTVRecord() {}
void ExecuteUserCode();
void FormFrom(TTreeViewer *tv);
void PlugIn(TTreeViewer *tv);
const char *GetX() const {return fX;}
const char *GetY() const {return fY;}
const char *GetZ() const {return fZ;}
virtual const char *GetName() const {return fName;}
const char *GetUserCode() const {return fUserCode;}
Bool_t HasUserCode() const {return fUserCode.Length() != 0 ? kTRUE : kFALSE;}
Bool_t MustExecuteCode() const {return fAutoexec;}
void SetAutoexec(Bool_t autoexec=kTRUE) {fAutoexec=autoexec;}
void SetName(const char* name = "") {fName = name;}
void SetX(const char *x = "", const char *xal = "-empty-") {fX = x; fXAlias = xal;}
void SetY(const char *y = "", const char *yal = "-empty-") {fY = y; fYAlias = yal;}
void SetZ(const char *z = "", const char *zal = "-empty-") {fZ = z; fZAlias = zal;}
void SetCut(const char *cut = "", const char *cal = "-empty-") {fCut = cut; fCutAlias = cal;}
void SetOption(const char *option = "") {fOption = option;}
void SetRC(Bool_t redirect = kFALSE, Bool_t cut = kTRUE) {fScanRedirected = redirect; fCutEnabled = cut;}
void SetUserCode(const char *code, Bool_t autoexec=kTRUE) {fUserCode = code; fAutoexec=autoexec;}
void SaveSource(ofstream &out);
ClassDef(TTVRecord, 0)
};
class TTVSession : public TObject {
private:
TClonesArray *fList;
TString fName;
TTreeViewer *fViewer;
Int_t fCurrent;
Int_t fRecords;
public:
TTVSession(TTreeViewer *tv);
~TTVSession();
virtual const char *GetName() const {return fName;}
void SetName(const char *name) {fName = name;}
void SetRecordName(const char* name);
TTVRecord *AddRecord(Bool_t fromFile = kFALSE);
Int_t GetEntries() {return fRecords;}
TTVRecord *GetCurrent() {return GetRecord(fCurrent);}
TTVRecord *GetRecord(Int_t i);
TTVRecord *First() {return GetRecord(0);}
TTVRecord *Last() {return GetRecord(fRecords-1);}
TTVRecord *Next() {return GetRecord(fCurrent+1);}
TTVRecord *Previous() {return GetRecord(fCurrent-1);}
void RemoveLastRecord();
void Show(TTVRecord *rec);
void SaveSource(ofstream &out);
void UpdateRecord(const char *name);
ClassDef(TTVSession, 0)
};
#endif