| [1437] | 1 | // This may look like C code, but it is really -*- C++ -*- | 
|---|
| [1738] | 2 |  | 
|---|
|  | 3 | // ArchTOIPipe           (C)     CEA/DAPNIA/SPP IN2P3/LAL | 
|---|
|  | 4 | //                               Eric Aubourg | 
|---|
|  | 5 | //                               Christophe Magneville | 
|---|
|  | 6 | //                               Reza Ansari | 
|---|
| [1985] | 7 | // $Id: toiseqbuff.h,v 1.10 2002-05-07 16:38:03 ansari Exp $ | 
|---|
| [1738] | 8 |  | 
|---|
| [1437] | 9 | #ifndef TOISEQBUFF_H | 
|---|
|  | 10 | #define TOISEQBUFF_H | 
|---|
|  | 11 |  | 
|---|
|  | 12 | #include "toi.h" | 
|---|
|  | 13 |  | 
|---|
| [1484] | 14 | // -------------------  TOISeqBuffered --------------------------- | 
|---|
| [1437] | 15 | // Classe de TOI avec buffer, et echantillonnage regulier. | 
|---|
|  | 16 | // Pour le moment au moins, | 
|---|
|  | 17 | // il faut que les providers fassent arriver les donnees par samplenum croissant. | 
|---|
| [1484] | 18 | // --------------------------------------------------------------- | 
|---|
|  | 19 |  | 
|---|
| [1437] | 20 | class TOISeqBuffered : public TOIRegular { | 
|---|
|  | 21 | public: | 
|---|
|  | 22 | TOISeqBuffered(int wsz=8192); | 
|---|
|  | 23 | TOISeqBuffered(string nm, int wsz=8192); | 
|---|
|  | 24 | virtual ~TOISeqBuffered(); | 
|---|
|  | 25 |  | 
|---|
| [1484] | 26 |  | 
|---|
|  | 27 | inline  void SetBufferSize(int wsz)  // ATTENTION - Ne doit pas etre appele | 
|---|
|  | 28 | { AllocBuffer(wsz); }   // apres le demarrage des threads | 
|---|
|  | 29 |  | 
|---|
| [1762] | 30 | virtual void PrintStatus(::ostream & os) const; | 
|---|
| [1437] | 31 |  | 
|---|
|  | 32 | inline void setDebugLevel(int lev=0) { dbglev=lev; } | 
|---|
|  | 33 | inline int  getDebugLevel() const { return dbglev; } | 
|---|
|  | 34 |  | 
|---|
| [1985] | 35 | virtual double        getData(int i); | 
|---|
|  | 36 | virtual void          getData(int i, double& data,  uint_8& flag); | 
|---|
|  | 37 | virtual void          getData(int i, int n, double* data, uint_8* flg=0); | 
|---|
|  | 38 | virtual void          putData(int i, double  value, uint_8  flag=0); | 
|---|
|  | 39 | virtual void          putData(int i, int n, double const* val, uint_8 const* flg=0); | 
|---|
|  | 40 | virtual void          wontNeedBefore(int i); | 
|---|
|  | 41 |  | 
|---|
| [1437] | 42 | inline int getFirstIn() const { return first_in; } | 
|---|
|  | 43 | inline int getFirstOut() const { return first_out; } | 
|---|
|  | 44 | inline int getLastIn() const { return (next_in-1); } | 
|---|
|  | 45 | inline int getLastOut() const { return (next_out-1); } | 
|---|
|  | 46 |  | 
|---|
|  | 47 |  | 
|---|
|  | 48 | virtual DataStatus isDataAvailNL(int iStart, int iEnd); | 
|---|
|  | 49 | virtual DataStatus isDataAvailNL(int i); // override required | 
|---|
|  | 50 |  | 
|---|
|  | 51 | protected: | 
|---|
|  | 52 | double* data; | 
|---|
| [1532] | 53 | uint_8*  flags; | 
|---|
| [1437] | 54 | int wsize; | 
|---|
|  | 55 | int buffsize; | 
|---|
|  | 56 | int next_in; | 
|---|
|  | 57 | int next_out; | 
|---|
|  | 58 | int first_in; | 
|---|
|  | 59 | int first_out; | 
|---|
|  | 60 | bool started; | 
|---|
|  | 61 | double defaultValue; | 
|---|
|  | 62 | int dbglev; | 
|---|
|  | 63 |  | 
|---|
|  | 64 | void    AllocBuffer(int wsz); | 
|---|
|  | 65 |  | 
|---|
|  | 66 | #ifdef WITH_SOPHYA | 
|---|
| [1464] | 67 | /* ---- l'interface va etre modifiee, NE PAS UTILISER | 
|---|
| [1437] | 68 | virtual Array         doGetData(int iStart, int iEnd); | 
|---|
|  | 69 | virtual TArray<int_4> doGetFlag(int iStart, int iEnd); | 
|---|
| [1464] | 70 | l'interface va etre modifiee, NE PAS UTILISER ---- */ | 
|---|
| [1437] | 71 | #endif | 
|---|
| [1532] | 72 | virtual void          doGetData(int i, double & val, uint_8 & flg); | 
|---|
| [1437] | 73 |  | 
|---|
| [1532] | 74 | virtual void          doPutData(int i, double value, uint_8 flag=0); | 
|---|
| [1985] | 75 | //  virtual void          doWontNeedBefore(int i);  plus besoin ? - Reza Mai 2002 | 
|---|
| [1437] | 76 |  | 
|---|
|  | 77 | virtual int           nextDataAvail(int iAfter); | 
|---|
|  | 78 | virtual bool          hasSomeData(); | 
|---|
|  | 79 |  | 
|---|
|  | 80 | inline double &       dataRef(int i) { return data[i%buffsize]; } | 
|---|
| [1532] | 81 | inline uint_8 &        flagRef(int i) { return flags[i%buffsize]; } | 
|---|
| [1437] | 82 | inline bool           isDataDeleted(int i) | 
|---|
| [1442] | 83 | { return((i < next_in-buffsize-1) ? true : false); } | 
|---|
| [1437] | 84 | }; | 
|---|
|  | 85 |  | 
|---|
|  | 86 |  | 
|---|
|  | 87 | #endif | 
|---|