#ifndef runglue_h
#define runglue_h
//
#include <TSQLServer.h>
#include <TSQLRow.h>
#include <TSQLResult.h>
#include <TList.h>
#include <TString.h>
#include <TObject.h>
#include <TSQLServer.h>
#include <TSQLRow.h>
#include <TSQLResult.h>
#include <TString.h>
#include <TTimeStamp.h>
#include <TSQLServer.h>
#include <TFile.h>
#include <TSystem.h>
#include <TChain.h>
#include <TH1.h>
#include <TTree.h>
#include <TKey.h>
#include <Riostream.h>
#include <TObjString.h>
#include <TClass.h>
#include <THashList.h>
#include <PamLevel2.h>
//
/**
 * \brief Class to group runs day by day
 */
class RunGlue : public TObject {
 private:
    TSQLServer *dbc;
    PamLevel2 *li;
    UInt_t run;
    TString dir;
    TString outdir;
    TString fFilename;
    Bool_t fEnd;
    Bool_t RUN;
    TList *fDoneList;
    TList *fList;
    TList *lList;
    TFile *Target;
    TFile *Source;
    TString fDList;
    TString wd;
    Bool_t fastMethod;
    Bool_t fDBG;
    Bool_t fUpgrade;
    Bool_t fOpen;
    Bool_t runmode;
    Bool_t createlist;
    Bool_t merged;
    UInt_t fNlist;
    UInt_t fNlistdone;
    UInt_t nrun;
    UInt_t YY;
    UInt_t MM;
    UInt_t DD;

 public:
    //
    RunGlue();
    //
    RunGlue(TSQLServer *dbc,UInt_t run, TString dir, TString wrkdir);
    //
    // methods
    //
    void Clear();
    void Clean();
    TList *GetRunList();
    //    Long64_t Mergy(TChain *, TFile *, Int_t, Option_t *);
    void MergeRootfile(TList *);
    Bool_t OpenFile();
    void SetDebug(Bool_t);
    void SetDList(TString);
    void DeleteRunFiles(TList *);
    void UpdateDB(TList *);
    void SetUpgrade(Bool_t set){fUpgrade=set;};    
    //
    // inline methods
    //
    Bool_t End(){return(fEnd);};
    Bool_t FileIsOpen(){return(fOpen);};
    Bool_t DebugMode(){return(fDBG);};
    Bool_t GetUpgrade(){return(fUpgrade);};    
    TString GetFilename(){return(fFilename);};
    //
    //
    //
    //
    ClassDef(RunGlue,1);
    //
};

#endif
