Changeset 1437 in Sophya for trunk/ArchTOIPipe/Kernel/toiprocessor.cc
- Timestamp:
- Mar 12, 2001, 7:00:28 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ArchTOIPipe/Kernel/toiprocessor.cc
r1367 r1437 44 44 45 45 void TOIProcessor::afterinit() { 46 int i; 46 47 inTOIs = new (TOI*[inIx.size()]); 48 for(i=0; i<inIx.size(); i++) 49 inTOIs[i] = NULL; 47 50 outTOIs = new (TOI*[outIx.size()]); 51 for(i=0; i<outIx.size(); i++) 52 outTOIs[i] = NULL; 48 53 } 49 54 … … 123 128 } 124 129 130 // Methodes rajoutees par Reza 11/3/2001 131 TOI* TOIProcessor::getInputTOI(int toiIndex) { 132 // chkinit(); 133 if (toiIndex >= inIx.size()) 134 throw RangeCheckError("TOIProcessor::getInputTOI() out of bound toiIndex"); 135 TOI* toi = inTOIs[toiIndex]; 136 if (toi == NULL) 137 throw NullPtrError("TOIProcessor::getInputTOI() - Not assigned TOI !"); 138 return(toi); 139 } 140 141 TOI* TOIProcessor::getOutputTOI(int toiIndex) { 142 // chkinit(); 143 if (toiIndex >= outIx.size()) 144 throw RangeCheckError("TOIProcessor::getOutputTOI() out of bound toiIndex"); 145 TOI* toi = outTOIs[toiIndex]; 146 if (toi == NULL) 147 throw NullPtrError("TOIProcessor::getOutputTOI() - Not assigned TOI !"); 148 return(toi); 149 } 150 151 bool TOIProcessor::checkInputTOIIndex(int toiIndex) { 152 if (toiIndex >= inIx.size()) return false; 153 if (inTOIs[toiIndex] == NULL) return false; 154 return true; 155 } 156 157 bool TOIProcessor::checkOutputTOIIndex(int toiIndex) { 158 if (toiIndex >= outIx.size()) return false; 159 if (outTOIs[toiIndex] == NULL) return false; 160 return true; 161 } 162 163 void TOIProcessor::PrintStatus(ostream & os) 164 { 165 os << " TOIProcessor::PrintStatus() - Name= " << name 166 << " MinIn=" << getMinIn() << " MaxIn=" << getMaxIn() << endl; 167 os << " --- Inputs N= " << inIx.size() << endl; 168 int k; 169 for(k=0; k<inIx.size(); k++) { 170 os << "Input[" << k << "] : " << getInName(k) ; 171 if (inTOIs[k] != NULL) 172 os << " Connected TOI " << inTOIs[k]->getName() << endl; 173 else os << " NO TOI " << endl; 174 } 175 os << " --- Outputs N= " << outIx.size() << endl; 176 for(k=0; k<outIx.size(); k++) { 177 os << "Output[" << k << "] : " << getOutName(k) ; 178 if (outTOIs[k] != NULL) 179 os << " Connected TOI " << outTOIs[k]->getName() << endl; 180 else os << " NO TOI " << endl; 181 } 182 os << endl; 183 return; 184 } 185 186 // Fin rajout Reza 11/3/2001 187 125 188 void TOIProcessor::addInput(string name, TOI* toi) { 126 189 chkinit(); … … 143 206 if (i > outIx.size()) throw RangeCheckError("TOIProcessor::getOutName " 144 207 " out of bound"); 145 map<string, int>::iterator j = outIx.begin(); 146 while (i) {i--; j++;}; 147 return (*j).first; 208 map<string, int>::iterator j; 209 for(j=outIx.begin(); j!= outIx.end(); j++) 210 if ((*j).second == i) return (*j).first; 211 212 throw RangeCheckError("TOIProcessor::getOutName Not found index !"); 148 213 } 149 214 … … 151 216 if (i > inIx.size()) throw RangeCheckError("TOIProcessor::getInName " 152 217 " out of bound"); 153 map<string, int>::iterator j = inIx.begin(); 154 while (i) {i--; j++;}; 155 return (*j).first; 218 map<string, int>::iterator j; 219 for(j=inIx.begin(); j!= inIx.end(); j++) 220 if ((*j).second == i) return (*j).first; 221 222 throw RangeCheckError("TOIProcessor::getOutName Not found index !"); 156 223 } 157 224 … … 189 256 #ifndef NO_SOPHYA 190 257 Array TOIProcessor::getData(int toiIndex, int iStart, int iEnd) { 191 TOI* toi = inTOIs[toiIndex];258 TOI* toi = getInputTOI(toiIndex); 192 259 toi->waitForData(iStart, iEnd); 193 260 return toi->getData(iStart, iEnd); … … 195 262 196 263 Array TOIProcessor::getError(int toiIndex, int iStart, int iEnd) { 197 TOI* toi = inTOIs[toiIndex];264 TOI* toi = getInputTOI(toiIndex); 198 265 toi->waitForData(iStart, iEnd); 199 266 return toi->getError(iStart, iEnd); … … 201 268 202 269 TArray<int_4> TOIProcessor::getFlag(int toiIndex, int iStart, int iEnd) { 203 TOI* toi = inTOIs[toiIndex];270 TOI* toi = getInputTOI(toiIndex); 204 271 toi->waitForData(iStart, iEnd); 205 272 return toi->getFlag(iStart, iEnd); … … 208 275 209 276 double TOIProcessor::getData(int toiIndex, int i) { 210 TOI* toi = inTOIs[toiIndex];277 TOI* toi = getInputTOI(toiIndex); 211 278 toi->waitForData(i); 212 279 return toi->getData(i); … … 214 281 215 282 double TOIProcessor::getError(int toiIndex, int i) { 216 TOI* toi = inTOIs[toiIndex];283 TOI* toi = getInputTOI(toiIndex); 217 284 toi->waitForData(i); 218 285 return toi->getError(i); … … 220 287 221 288 int_4 TOIProcessor::getFlag(int toiIndex, int i) { 222 TOI* toi = inTOIs[toiIndex];289 TOI* toi = getInputTOI(toiIndex); 223 290 toi->waitForData(i); 224 291 return toi->getFlag(i); … … 257 324 258 325 void TOIProcessor::putData(int toiIndex, int i, double value, int_4 flg) { 259 TOI* toi = outTOIs[toiIndex];326 TOI* toi = getOutputTOI(toiIndex); 260 327 toi->putData(i, value, flg); 261 328 autoWontNeed(i); … … 266 333 void TOIProcessor::putDataError(int toiIndex, int i, double value, 267 334 double error, int_4 flg) { 268 TOI* toi = outTOIs[toiIndex]; 335 TOI* toi = getOutputTOI(toiIndex); 336 if (toi == NULL) 337 throw NullPtrError("TOIProcessor::putDataError() - Not assigned TOI !"); 269 338 toi->putDataError(i, value, error, flg); 270 339 autoWontNeed(i);
Note:
See TracChangeset
for help on using the changeset viewer.