[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
|
---|
[1761] | 7 | // $Id: toiseqbuff.h,v 1.8 2001-11-13 16:14:44 aubourg 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 |
|
---|
[1761] | 30 | virtual void PrintStatus(std::ostream & os) const;
|
---|
[1437] | 31 |
|
---|
| 32 | inline void setDebugLevel(int lev=0) { dbglev=lev; }
|
---|
| 33 | inline int getDebugLevel() const { return dbglev; }
|
---|
| 34 |
|
---|
| 35 | inline int getFirstIn() const { return first_in; }
|
---|
| 36 | inline int getFirstOut() const { return first_out; }
|
---|
| 37 | inline int getLastIn() const { return (next_in-1); }
|
---|
| 38 | inline int getLastOut() const { return (next_out-1); }
|
---|
| 39 |
|
---|
| 40 |
|
---|
| 41 | virtual DataStatus isDataAvailNL(int iStart, int iEnd);
|
---|
| 42 | virtual DataStatus isDataAvailNL(int i); // override required
|
---|
| 43 |
|
---|
| 44 | protected:
|
---|
| 45 | double* data;
|
---|
[1532] | 46 | uint_8* flags;
|
---|
[1437] | 47 | int wsize;
|
---|
| 48 | int buffsize;
|
---|
| 49 | int next_in;
|
---|
| 50 | int next_out;
|
---|
| 51 | int first_in;
|
---|
| 52 | int first_out;
|
---|
| 53 | bool started;
|
---|
| 54 | double defaultValue;
|
---|
| 55 | int dbglev;
|
---|
| 56 |
|
---|
| 57 | void AllocBuffer(int wsz);
|
---|
| 58 |
|
---|
| 59 | #ifdef WITH_SOPHYA
|
---|
[1464] | 60 | /* ---- l'interface va etre modifiee, NE PAS UTILISER
|
---|
[1437] | 61 | virtual Array doGetData(int iStart, int iEnd);
|
---|
| 62 | virtual TArray<int_4> doGetFlag(int iStart, int iEnd);
|
---|
[1464] | 63 | l'interface va etre modifiee, NE PAS UTILISER ---- */
|
---|
[1437] | 64 | #endif
|
---|
[1532] | 65 | virtual void doGetData(int i, double & val, uint_8 & flg);
|
---|
[1437] | 66 |
|
---|
[1532] | 67 | virtual void doPutData(int i, double value, uint_8 flag=0);
|
---|
[1437] | 68 | virtual void doWontNeedBefore(int i);
|
---|
| 69 |
|
---|
| 70 | virtual int nextDataAvail(int iAfter);
|
---|
| 71 | virtual bool hasSomeData();
|
---|
| 72 |
|
---|
| 73 | inline double & dataRef(int i) { return data[i%buffsize]; }
|
---|
[1532] | 74 | inline uint_8 & flagRef(int i) { return flags[i%buffsize]; }
|
---|
[1437] | 75 | inline bool isDataDeleted(int i)
|
---|
[1442] | 76 | { return((i < next_in-buffsize-1) ? true : false); }
|
---|
[1437] | 77 | };
|
---|
| 78 |
|
---|
| 79 |
|
---|
| 80 | #endif
|
---|