/* -------------------------------------------------------------------------- */ tVecStr* ImageManager::GetUpdatedList( IMMode mode ) { tVecStr* updatedList = new tVecStr(); tVecStr tmpList; if ( !imgTree.empty() ) { BppTree* localTree = new BppTree(512,KeyStrFactory(), ValueNullFactory(),PATH_TREE_TMP); // Se obtiene una lista de todos los paths del B Tree. tVecStr allDirs = GetAllDirectories(); // Se carga un B Tree temprarl con las imagenes a actualizar. for ( unsigned int j = 0; j < allDirs.size() ; j++ ) { std::string path = allDirs[j] + "/"; tVecStr imgList = FileSystem::GetFiles( path.c_str() , File); if ( imgList.size() != 0 ) { for ( unsigned int i = 0; i < imgList.size() ; i++ ) { KeyStr ktmp ( path + imgList[i] ); ValueInt vtmp (i); localTree->insert(ktmp,vtmp); } } imgList.clear(); } switch ( mode ) { case Erased: tmpList = GetMergedList( imgTree , *localTree); break; case Added: tmpList = GetMergedList( *localTree , imgTree ); break; default: break; } tmpList = filterByDate ( tmpList , *localTree ); /* * Se le agregan a updatedList las imagenes que faltan, obtenidas * previamente de la sublista tmpList. */ for ( unsigned int i = 0; i < tmpList.size() ; i++ ) updatedList->push_back( tmpList[i] ); // Se liberan recursos temporales. tmpList.clear(); delete localTree; remove (PATH_TREE_TMP); remove (PATH_TREE_TMP_BIG_REGS); allDirs.clear(); } return updatedList; }
void filterMenu() { char user_input[2]; strcpy(user_input, "a"); printf("%s", "\n [1] By manufacturer\n [2] By price\n [3] By date\n"); scanf("%s", user_input); Products result; result.size = 0; if (!strcmp(user_input, "1")){ char manufacturer[30]; printf("%s", "Manufacturer: "); scanf("%s", manufacturer); filterByManufacturer(&result, manufacturer); } if (!strcmp(user_input, "2")){ int price; printf("%s", "Price: "); scanf("%d", &price); filterByPrice(&result, price); } if (!strcmp(user_input, "3")){ int date; printf("%s", "Date: "); scanf("%d", &date); filterByDate(&result, date); } int i; for (i=0; i<result.size; i++){ printf("%d | ", result.products[i].id); printf("%s | ", result.products[i].type); printf("%s | ", result.products[i].model); printf("%s | ", result.products[i].manufacturer); printf("%d | ", result.products[i].price); printf("%d | ", result.products[i].date); printf("%d\n", result.products[i].quantity); } }