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

Last change on this file since 1462 was 1462, checked in by cmv, 24 years ago

changement getData... intermediaire NE COMPILE PAS cmv+rz 10/4/2001

File size: 3.6 KB
Line 
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>
13#include <iostream.h>
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
45 Array getData(int toiIndex, int iStart, int iEnd);
46 Array getError(int toiIndex, int iStart, int iEnd);
47 TArray<int_4> getFlag(int toiIndex, int iStart, int iEnd);
48#endif
49 // si multiple input (indexed input), tableau 2D.
50
51 // Les methodes qui suivent ne peuvent etre
52 // utilisees que sur des entrees simples
53 double getData(int toiIndex, int i);
54 void getData(int toiIndex, int i, double &data,int_4 &flag);
55
56 //RZCMV double getError(int toiIndex, int i);
57 //RZCMV int_4 getFlag(int toiIndex, int i);
58
59 void wontNeedBefore(int i);
60 int wontNeedValue;
61 void setNeededHistory(int nsamples); // -1 : disable
62
63 void putData(int toiIndex, int i, double value, int_4 flag=0);
64 //RZCMV void putDataError(int toiIndex, int i, double value,
65 //RZCMV double error, int_4 flag=0);
66
67 // Gestion des bornes pour les transformations de TOIs...
68 virtual int calcMinOut();
69 virtual int calcMaxOut();
70
71 virtual int getMinOut();
72 virtual int getMaxOut();
73 int minOut;
74 int maxOut;
75
76 virtual int getMinIn();
77 virtual int getMaxIn();
78 // Implementation par defaut
79 int upExtra;
80 int lowExtra;
81
82 int neededHistory;
83
84protected:
85 int getInputTOIIndex(string toi);
86 int getOutputTOIIndex(string toi);
87
88 // Methodes rajoutees par Reza 11/3/2001
89 TOI* getInputTOI(int toiIndex);
90 TOI* getOutputTOI(int toiIndex);
91 bool checkInputTOIIndex(int toiIndex);
92 bool checkOutputTOIIndex(int toiIndex);
93
94 // Fin rajout Reza 11/3/2001
95
96 void autoWontNeed(int iCur);
97 int lastAWN;
98
99public:
100 // Appele par les assembleurs de pipeline
101 virtual void addInput(string name, TOI* toi);
102 virtual void addOutput(string name, TOI* toi);
103
104
105 int getNIn() {chkinit(); return inIx.size();}
106 int getNOut() {chkinit(); return outIx.size();}
107 string getOutName(int i);
108 string getInName(int i);
109
110 // Methodes rajoutees par Reza 11/3/2001
111 virtual void PrintStatus(ostream & os) ; // const plus tard
112 // Fin rajout Reza 11/3/2001
113
114 virtual void start();
115
116 TOIProcessor();
117 virtual ~TOIProcessor();
118
119protected:
120
121 map<string, int> inIx;
122 map<string, int> outIx;
123 TOI** inTOIs;
124 TOI** outTOIs;
125
126 string name;
127 // Thread handling
128 pthread_t thread;
129 pthread_cond_t dataReady;
130 pthread_mutex_t mutex;
131 pthread_mutexattr_t mutattr;
132
133 void lock() {
134 pthread_mutex_lock(&mutex);
135 }
136
137 void unlock() {
138 pthread_mutex_unlock(&mutex);
139 }
140
141 void wait() {
142 pthread_cond_wait(&dataReady, &mutex);
143 }
144
145 void notify();
146
147
148 friend class TOI;
149
150 static void* ThreadStart(void *);
151};
152
153inline ostream & operator << (ostream & os, TOIProcessor /*const*/ & toip)
154{ toip.PrintStatus(os); return os; }
155
156
157#endif
158
Note: See TracBrowser for help on using the repository browser.