Ignore:
Timestamp:
Nov 9, 1999, 3:04:05 PM (26 years ago)
Author:
ansari
Message:

portage cxx en cours

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Poubelle/archTOI.old/toiderivproducer.cc

    r534 r555  
    66#include "archexc.h"
    77#include "requesthandler.h"
     8#include "subsets.h"
    89
    910set<TOI> TOIDerivProducer::reqTOIFor(TOI const&) {
     
    6162  }
    6263 
     64  set<string> unusedextra = extraopts;
     65 
    6366  // 4. Find producers, distribute remaining options
    6467  map<TOI, TOIProducer*> fullInputTOI;
     
    6669  for (set<TOI>::iterator i = inputTOIs.begin(); i != inputTOIs.end(); i++) {
    6770    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    }
    6988    if (!prod) return false;
    7089    if (!extraopts.empty()) {
     
    7392        if (extraopts.find(*j) != extraopts.end()) {
    7493          inTOI.options.insert(*j);
    75           extraopts.erase(*j);
     94          unusedextra.erase(*j);
    7695        }
    7796      }
     
    8099  }
    81100 
    82   if (!extraopts.empty()) return false;
     101  if (!unusedextra.empty()) return false;
    83102 
    84103  neededTOIs[toi] = fullInputTOI;
     
    91110 // if (!canProduce(toi)) throw ArchExc("cannot produce " + toi.name);
    92111  set<string> s = getProperAvailOptions(toi);
    93   map<TOI, TOIProducer*> need = neededTOIs[toi];
     112  map<TOI, TOIProducer*> & need = neededTOIs[toi];
    94113  for (map<TOI, TOIProducer*>::iterator i = need.begin(); i != need.end(); i++) {
    95114    set<string> s1 = (*i).second->getAvailOptions((*i).first);
     
    101120void TOIDerivProducer::addTOI(TOI& toi, TOIAbsorber* client) {
    102121  TOIProducer::addTOI(toi, client);
    103   map<TOI, TOIProducer*> m = neededTOIs[toi];
     122  map<TOI, TOIProducer*> & m = neededTOIs[toi];
    104123  for (map<TOI, TOIProducer*>::iterator i = m.begin(); i != m.end(); i++) {
    105124    TOI toi2 = (*i).first;
     
    117136void TOIDerivProducer::propagateLowBound(TOI const& toi, long sampleNum) {
    118137  CHKPROD
    119   map<TOI, TOIProducer*> need = neededTOIs[toi];
     138  map<TOI, TOIProducer*> & need = neededTOIs[toi];
    120139  for (map<TOI, TOIProducer*>::iterator i = need.begin(); i != need.end(); i++) {
    121140    (*i).second->wontNeedEarlier((*i).first, this, sampleNum);
Note: See TracChangeset for help on using the changeset viewer.