ROOT logo
#ifndef HLDGREPFILESOURCE_H
#define HLDGREPFILESOURCE_H

#include "hldfilesourcebase.h"
#include "TIterator.h"
#include "TString.h"
#include "TObjString.h"
#include "TList.h"
#include "TStopwatch.h"

#include <time.h>
#include <cstdlib>

class HldGrepFileSource : public HldFileSourceBase {

protected:

    static time_t lastfile;       //! last modification time of last used file
    static time_t timelimit;      //! time stamp for the search of new files (files should be newer)
    static time_t tcurrent;       //! current time
    static Int_t timeoffset;      //! offset in seconds required to t_current
    static TString fullname;      //! full filename: path/file
    static TString fullnamesort;  //! full filename for sorting: path/modtime_file
    static TString path;          //! path to directory used for grep of new hld files
    Int_t first;                  //! flag : 0 if no file has be selected
    Int_t mode;                   //! flag : 1 take newest file , 1: start from given file/time than take the next in list
    Int_t interval;               //! time interval in seconds for grep on dir
    TStopwatch timer;             //! timer for grep interval
    Int_t referenceId;            //! referrence ID for files
    Bool_t dostop;                //! flag to stop the source from file reading (ckecked each event)
    Int_t distanceToLast;         //! distance to last file : last - distanceToLast
    Int_t getNewFile();
    Int_t checkDir(TString dir);
    Int_t decodeOption(TString opt);
    static Int_t selectFiles(const struct dirent *entry);
    Int_t loopForNewFile();


public:
  HldGrepFileSource(TString dir="",TString opt="Grep",Int_t grepInterval=5,Int_t refId=-1,Int_t off=5,Int_t fileoffset=1);
  virtual ~HldGrepFileSource(void);
  EDsState getNextEvent(Bool_t doUnpack=kTRUE);
  Int_t getRunId(const Text_t *fileName);
  void setMaxEventPerFile(Int_t n)              {fEventLimit = n; }
  void setRefId(Int_t id=-1)                    {referenceId=id;}
  void stop()                                   {dostop=kTRUE;}
  void addFile(const Text_t *fileName, Int_t refId=-1){Error("addFile()","This function is not implemented!");exit(1);}
  Bool_t getNextFile()                          {Warning("getNextFile()","This function is a dummy implementation!");return kTRUE;}
  Bool_t rewind()                               {Error("rewind()","This function is not implemented!")     ;exit(1);return kTRUE;}

  ClassDef(HldGrepFileSource,0) //! Data source to read LMD files;
};
#endif /* !HLDGREPFILESOURCE_H */

 hldgrepfilesource.h:1
 hldgrepfilesource.h:2
 hldgrepfilesource.h:3
 hldgrepfilesource.h:4
 hldgrepfilesource.h:5
 hldgrepfilesource.h:6
 hldgrepfilesource.h:7
 hldgrepfilesource.h:8
 hldgrepfilesource.h:9
 hldgrepfilesource.h:10
 hldgrepfilesource.h:11
 hldgrepfilesource.h:12
 hldgrepfilesource.h:13
 hldgrepfilesource.h:14
 hldgrepfilesource.h:15
 hldgrepfilesource.h:16
 hldgrepfilesource.h:17
 hldgrepfilesource.h:18
 hldgrepfilesource.h:19
 hldgrepfilesource.h:20
 hldgrepfilesource.h:21
 hldgrepfilesource.h:22
 hldgrepfilesource.h:23
 hldgrepfilesource.h:24
 hldgrepfilesource.h:25
 hldgrepfilesource.h:26
 hldgrepfilesource.h:27
 hldgrepfilesource.h:28
 hldgrepfilesource.h:29
 hldgrepfilesource.h:30
 hldgrepfilesource.h:31
 hldgrepfilesource.h:32
 hldgrepfilesource.h:33
 hldgrepfilesource.h:34
 hldgrepfilesource.h:35
 hldgrepfilesource.h:36
 hldgrepfilesource.h:37
 hldgrepfilesource.h:38
 hldgrepfilesource.h:39
 hldgrepfilesource.h:40
 hldgrepfilesource.h:41
 hldgrepfilesource.h:42
 hldgrepfilesource.h:43
 hldgrepfilesource.h:44
 hldgrepfilesource.h:45
 hldgrepfilesource.h:46
 hldgrepfilesource.h:47
 hldgrepfilesource.h:48
 hldgrepfilesource.h:49
 hldgrepfilesource.h:50
 hldgrepfilesource.h:51
 hldgrepfilesource.h:52
 hldgrepfilesource.h:53
 hldgrepfilesource.h:54