Changeset 555 in Sophya for trunk/Poubelle/archTOI.old/toiderivproducer.cc
- Timestamp:
- Nov 9, 1999, 3:04:05 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Poubelle/archTOI.old/toiderivproducer.cc
r534 r555 6 6 #include "archexc.h" 7 7 #include "requesthandler.h" 8 #include "subsets.h" 8 9 9 10 set<TOI> TOIDerivProducer::reqTOIFor(TOI const&) { … … 61 62 } 62 63 64 set<string> unusedextra = extraopts; 65 63 66 // 4. Find producers, distribute remaining options 64 67 map<TOI, TOIProducer*> fullInputTOI; … … 66 69 for (set<TOI>::iterator i = inputTOIs.begin(); i != inputTOIs.end(); i++) { 67 70 TOI inTOI = *i; 68 TOIProducer* prod = TOIManager::findTOIProducer(inTOI); 71 //TOIProducer* prod0 = TOIManager::findTOIProducer(inTOI); 72 // Let's see if we get others with options, we have to do this because 73 // of required options, and we have to iterate over all subsets of the options. 74 // This algorithm is NOT correct, but should work for realistic cases... 75 int nmaxopt=-1; 76 TOIProducer* prod=NULL; 77 set<set<string> > optsets = getSetOfSubsets(extraopts); 78 for (set<set<string> >::iterator j = optsets.begin(); j != optsets.end(); j++) { 79 TOI toi2 = inTOI; 80 toi2.options.insert((*j).begin(), (*j).end()); 81 TOIProducer* prod0 = TOIManager::findTOIProducer(toi2); 82 if (prod0 == NULL) continue; 83 if ((long) toi2.options.size() > nmaxopt) { 84 prod = prod0; 85 nmaxopt = toi2.options.size(); 86 } 87 } 69 88 if (!prod) return false; 70 89 if (!extraopts.empty()) { … … 73 92 if (extraopts.find(*j) != extraopts.end()) { 74 93 inTOI.options.insert(*j); 75 extraopts.erase(*j);94 unusedextra.erase(*j); 76 95 } 77 96 } … … 80 99 } 81 100 82 if (! extraopts.empty()) return false;101 if (!unusedextra.empty()) return false; 83 102 84 103 neededTOIs[toi] = fullInputTOI; … … 91 110 // if (!canProduce(toi)) throw ArchExc("cannot produce " + toi.name); 92 111 set<string> s = getProperAvailOptions(toi); 93 map<TOI, TOIProducer*> need = neededTOIs[toi];112 map<TOI, TOIProducer*> & need = neededTOIs[toi]; 94 113 for (map<TOI, TOIProducer*>::iterator i = need.begin(); i != need.end(); i++) { 95 114 set<string> s1 = (*i).second->getAvailOptions((*i).first); … … 101 120 void TOIDerivProducer::addTOI(TOI& toi, TOIAbsorber* client) { 102 121 TOIProducer::addTOI(toi, client); 103 map<TOI, TOIProducer*> m = neededTOIs[toi];122 map<TOI, TOIProducer*> & m = neededTOIs[toi]; 104 123 for (map<TOI, TOIProducer*>::iterator i = m.begin(); i != m.end(); i++) { 105 124 TOI toi2 = (*i).first; … … 117 136 void TOIDerivProducer::propagateLowBound(TOI const& toi, long sampleNum) { 118 137 CHKPROD 119 map<TOI, TOIProducer*> need = neededTOIs[toi];138 map<TOI, TOIProducer*> & need = neededTOIs[toi]; 120 139 for (map<TOI, TOIProducer*>::iterator i = need.begin(); i != need.end(); i++) { 121 140 (*i).second->wontNeedEarlier((*i).first, this, sampleNum);
Note:
See TracChangeset
for help on using the changeset viewer.