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