Changeset 8878

Show
Ignore:
Timestamp:
03/05/09 17:40:07 (4 years ago)
Author:
mcarrick
Message:

cleaning up unnecessary variables, improving readability

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • ossiedev/trunk/system/ossie/framework/ApplicationFactory_impl.cpp

    r8874 r8878  
    935935void ApplicationFactory_impl::matchDeviceToComponent(SPDParser*  spd, const std::vector<SPDImplementation*>& _devspdimpls) 
    936936{ 
    937         for(unsigned int m = 0; m < _devspdimpls.size(); m++) 
     937    // Go through devices, and search through the current component  
     938    // SPD file and collects paths for all binaries to be executed. 
     939 
     940    // check all device implemtations 
     941    for(unsigned int m = 0; m < _devspdimpls.size(); m++) 
     942    { 
     943        // get information on device OS and processor 
     944        OSAttributes _osattr = _devspdimpls[m]->getOperatingSystem(); 
     945        std::vector<std::string> _proclist = _devspdimpls[m]->getProcessors(); 
     946 
     947        // store implementation info from current SPD file 
     948        std::vector <SPDImplementation*> *compImpl = spd->getImplementations(); 
     949 
     950        // search compImpl for matching implementation details from device, 
     951        // stop once the first matching implementation is found 
     952        // (this checking section will need to be expanded if other 
     953        // options need to be verified: compiler, etc.) 
     954 
     955        // (it is currently assumed in SPDImplementation.h, 
     956        // DeviceManager.cpp, and other places that there is only 
     957        // a single OS. this is incorrect and needs to be fixed.) 
     958        DEBUG(4, AppFac, "Matching device implementation to candidate components."); 
     959 
     960        // flip through all component implementations 
     961        bool implFound = false; // flag to determine if an implementation has been found 
     962        int i = 0; // counter variable for looping through components 
     963 
     964        while(!implFound & i < compImpl->size()) 
    938965        { 
    939          OSAttributes _osattr = _devspdimpls[m]->getOperatingSystem(); 
    940          std::vector<std::string> _proclist = _devspdimpls[m]->getProcessors(); 
    941     // Given a current device, this function searches through the current 
    942     // component SPD file and collects paths for all binaries to be 
    943     // executed. 
    944  
    945     // store implementation info from current SPD file 
    946     std::vector <SPDImplementation*> *compImpl = spd->getImplementations(); 
    947  
    948     // ----------------- (DELETE THESE LINES) --------------------- 
    949     // ----------------- ( TEST VECTORS ) ------------------------- 
    950     std::string os = _osattr.getOSName(); 
    951     std::string proc = _proclist[0]; 
    952     std::string version = _osattr.getOSVersion(); 
    953  
    954     // the if () statements will need to be changes once the real 
    955     // variable name is given. 
    956     // ------------------------------------------------------------ 
    957  
    958     // search compImpl for matching implementation details from device, 
    959     // stop once the first matching implementation is found 
    960     // (this checking section will need to be expanded if other 
    961     // options need to be verified: compiler, etc.) 
    962  
    963     // (it is currently assumed in SPDImplementation.h, 
    964     // DeviceManager.cpp, and other places that there is only 
    965     // a single OS. this is incorrect and needs to be fixed.) 
    966     DEBUG(4, AppFac, "Matching device implementation to candidate components."); 
    967  
    968     bool implFound = false; // flag to determine if an implementation has been found 
    969     int i = 0; // counter variable for looping through components 
    970  
    971     // flip through all component implementations 
    972     while(!implFound & i < compImpl->size()) 
    973     { 
    974         // match OS name and version 
    975         if ((*compImpl)[i]->getOperatingSystem().getOSName() == os & (*compImpl)[i]->getOperatingSystem().getOSVersion() == version) 
     966            // match OS name and version 
     967            std::string compImplOSName = (*compImpl)[i]->getOperatingSystem().getOSName(); 
     968            std::string compImplOSVersion = (*compImpl)[i]->getOperatingSystem().getOSVersion(); 
     969 
     970            if ( compImplOSName == string(_osattr.getOSName()) & compImplOSVersion == string(_osattr.getOSVersion()) ) 
     971            { 
     972                // get list of compatable processors in component impl 
     973                std::vector <std::string> compatibleProcs = (*compImpl)[i]->getProcessors(); 
     974 
     975                // loop through candidate procs, match to device 
     976                int k = 0; // counter variable  
     977                while (!implFound & k < compatibleProcs.size()) 
     978                { 
     979                    // match processor 
     980                    int p = 0; 
     981                    while (!implFound & p < _proclist.size()) 
     982                    { 
     983                        if (compatibleProcs[k] == _proclist[p]) 
     984                        { 
     985                            implFound = true; // implementation has been matched, break out of loops 
     986 
     987                            DEBUG(4, AppFac, "Found operating system match: " 
     988                                << _osattr.getOSName() << ", " << _osattr.getOSVersion() ); 
     989 
     990                            DEBUG(4, AppFac, "Found processor match: " << _proclist[p]); 
     991 
     992                            // return path to executable 
     993                            std::string path = (*compImpl)[i]->getCodeFile(); 
     994                            implsToExecute.push_back(path); 
     995                        } 
     996 
     997                        k++; 
     998                    } 
     999                } 
     1000            } 
     1001 
     1002            i++; 
     1003        } 
     1004 
     1005        // if a component implementation cannot be matched to the device, error out 
     1006        if (!implFound) 
    9761007        { 
    977             // get list of compatable processors in component impl 
    978             std::vector <std::string> procs = (*compImpl)[i]->getProcessors(); 
    979  
    980             // loop through candidate procs, match to device 
    981             int k = 0; // counter variable  
    982             while (!implFound & k < procs.size()) 
    983             { 
    984                 // match processor 
    985                 if (procs[k] == proc) 
    986                 { 
    987                     implFound = true; // implementation has been matched, break out of loops 
    988  
    989                     DEBUG(4, AppFac, "Found operating system match: " 
    990                         << (*compImpl)[i]->getOperatingSystem().getOSName() 
    991                         << ", " << (*compImpl)[i]->getOperatingSystem().getOSVersion() ); 
    992  
    993                     DEBUG(4, AppFac, "Found processor match: " << procs[k]); 
    994  
    995                     // return path to executable 
    996                     std::string path = (*compImpl)[i]->getCodeFile(); 
    997                     implsToExecute.push_back(path); 
    998                 } 
    999  
    1000                 k++; 
    1001             } 
     1008            std::cout <<  "[ApplicationFactory::matchDeviceToComponents] Could not match an implementation of " << spd->getSoftPkgName() << " to the current device\n"; 
     1009            exit(EXIT_FAILURE); 
    10021010        } 
    1003  
    1004         i++; 
    10051011    } 
    1006  
    1007     // if a component implementation cannot be matched to the device, error out 
    1008     if (!implFound) 
    1009     { 
    1010         std::cout <<  "[ApplicationFactory::matchDeviceToComponents] Could not match an implementation of " << spd->getSoftPkgName() << " to the current device\n"; 
    1011         exit(EXIT_FAILURE); 
    1012     } 
    1013         } 
    10141012} 
    10151013