source: Sophya/trunk/ArchTOIPipe/Kernel/toiseqbuff.h@ 1787

Last change on this file since 1787 was 1762, checked in by aubourg, 24 years ago

toujours et encore magique

File size: 2.5 KB
Line 
1// This may look like C code, but it is really -*- C++ -*-
2
3// ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL
4// Eric Aubourg
5// Christophe Magneville
6// Reza Ansari
7// $Id: toiseqbuff.h,v 1.9 2001-11-13 16:22:47 aubourg Exp $
8
9#ifndef TOISEQBUFF_H
10#define TOISEQBUFF_H
11
12#include "toi.h"
13
14// ------------------- TOISeqBuffered ---------------------------
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.
18// ---------------------------------------------------------------
19
20class TOISeqBuffered : public TOIRegular {
21public:
22 TOISeqBuffered(int wsz=8192);
23 TOISeqBuffered(string nm, int wsz=8192);
24 virtual ~TOISeqBuffered();
25
26
27 inline void SetBufferSize(int wsz) // ATTENTION - Ne doit pas etre appele
28 { AllocBuffer(wsz); } // apres le demarrage des threads
29
30 virtual void PrintStatus(::ostream & os) const;
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
44protected:
45 double* data;
46 uint_8* flags;
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
60 /* ---- l'interface va etre modifiee, NE PAS UTILISER
61 virtual Array doGetData(int iStart, int iEnd);
62 virtual TArray<int_4> doGetFlag(int iStart, int iEnd);
63 l'interface va etre modifiee, NE PAS UTILISER ---- */
64#endif
65 virtual void doGetData(int i, double & val, uint_8 & flg);
66
67 virtual void doPutData(int i, double value, uint_8 flag=0);
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]; }
74 inline uint_8 & flagRef(int i) { return flags[i%buffsize]; }
75 inline bool isDataDeleted(int i)
76 { return((i < next_in-buffsize-1) ? true : false); }
77};
78
79
80#endif
Note: See TracBrowser for help on using the repository browser.