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

Last change on this file since 1991 was 1800, checked in by aubourg, 24 years ago

GPH 424.1

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