source: Sophya/trunk/ArchTOIPipe/Kernel/toiprocessor.h@ 1721

Last change on this file since 1721 was 1689, checked in by aubourg, 24 years ago

segmented buffers...

File size: 3.8 KB
RevLine 
[1365]1// This may look like C code, but it is really -*- C++ -*-
2
3
4#ifndef TOIPROCESSOR_H
5#define TOIPROCESSOR_H
6
7#include "config.h"
8
9#include <pthread.h>
10
11#include <string>
12#include <map>
[1410]13#include <iostream.h>
[1365]14
15#ifndef NO_SOPHYA
16#include "tarray.h"
17using namespace SOPHYA;
18#endif
19
20#include "toi.h"
21
22
23class TOIProcessor {
24public:
25 virtual void init();
26 // Les methodes qui suivent peuvent etre appelees par init
27protected:
28 int declareInput(string toi);
29 int declareOutput(string toi);
30
31 // void declareMultInput(string toi);
32 // Question : multiple output ?
33
34 void chkinit() {
35 if (!inited) {init(); afterinit(); inited=true;}
36 }
37 bool inited;
38 virtual void afterinit();
39
40public:
41 virtual void run();
42 // Les methodes qui suivent peut etre appelees par run
43protected:
44#ifndef NO_SOPHYA
[1464]45 /* ---- l'interface va etre modifiee, NE PAS UTILISER
[1365]46 Array getData(int toiIndex, int iStart, int iEnd);
47 Array getError(int toiIndex, int iStart, int iEnd);
48 TArray<int_4> getFlag(int toiIndex, int iStart, int iEnd);
[1464]49 l'interface va etre modifiee, NE PAS UTILISER ---- */
[1365]50#endif
51 // si multiple input (indexed input), tableau 2D.
52
53 // Les methodes qui suivent ne peuvent etre
54 // utilisees que sur des entrees simples
55 double getData(int toiIndex, int i);
[1532]56 void getData(int toiIndex, int i, double &data, uint_8 &flag);
[1462]57
58 //RZCMV double getError(int toiIndex, int i);
59 //RZCMV int_4 getFlag(int toiIndex, int i);
[1365]60
61 void wontNeedBefore(int i);
62 int wontNeedValue;
63 void setNeededHistory(int nsamples); // -1 : disable
64
[1532]65 void putData(int toiIndex, int i, double value, uint_8 flag=0);
[1462]66 //RZCMV void putDataError(int toiIndex, int i, double value,
67 //RZCMV double error, int_4 flag=0);
[1365]68
69 // Gestion des bornes pour les transformations de TOIs...
70 virtual int calcMinOut();
71 virtual int calcMaxOut();
72
73 virtual int getMinOut();
74 virtual int getMaxOut();
75 int minOut;
76 int maxOut;
77
78 virtual int getMinIn();
79 virtual int getMaxIn();
80 // Implementation par defaut
81 int upExtra;
82 int lowExtra;
83
84 int neededHistory;
85
86protected:
87 int getInputTOIIndex(string toi);
88 int getOutputTOIIndex(string toi);
[1437]89
90 // Methodes rajoutees par Reza 11/3/2001
91 TOI* getInputTOI(int toiIndex);
92 TOI* getOutputTOI(int toiIndex);
93 bool checkInputTOIIndex(int toiIndex);
94 bool checkOutputTOIIndex(int toiIndex);
95
96 // Fin rajout Reza 11/3/2001
97
[1365]98 void autoWontNeed(int iCur);
99 int lastAWN;
100
101public:
102 // Appele par les assembleurs de pipeline
103 virtual void addInput(string name, TOI* toi);
104 virtual void addOutput(string name, TOI* toi);
105
[1367]106
107 int getNIn() {chkinit(); return inIx.size();}
108 int getNOut() {chkinit(); return outIx.size();}
109 string getOutName(int i);
110 string getInName(int i);
111
[1437]112 // Methodes rajoutees par Reza 11/3/2001
[1443]113 virtual void PrintStatus(ostream & os) ; // const plus tard
[1437]114 // Fin rajout Reza 11/3/2001
115
[1365]116 virtual void start();
117
118 TOIProcessor();
119 virtual ~TOIProcessor();
120
121protected:
122
123 map<string, int> inIx;
124 map<string, int> outIx;
125 TOI** inTOIs;
126 TOI** outTOIs;
127
128 string name;
129 // Thread handling
130 pthread_t thread;
131 pthread_cond_t dataReady;
132 pthread_mutex_t mutex;
133 pthread_mutexattr_t mutattr;
134
135 void lock() {
136 pthread_mutex_lock(&mutex);
137 }
138
139 void unlock() {
140 pthread_mutex_unlock(&mutex);
141 }
142
143 void wait() {
144 pthread_cond_wait(&dataReady, &mutex);
145 }
146
147 void notify();
148
149
150 friend class TOI;
151
152 static void* ThreadStart(void *);
[1689]153 void warnPutDone();
[1365]154};
155
[1437]156inline ostream & operator << (ostream & os, TOIProcessor /*const*/ & toip)
157{ toip.PrintStatus(os); return os; }
158
159
[1365]160#endif
[1437]161
Note: See TracBrowser for help on using the repository browser.