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

Last change on this file since 1740 was 1738, checked in by aubourg, 24 years ago

copyright

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