// LinkItems - This function is the main entry point into linking. It takes a // list of LinkItem which indicates the order the files should be linked and // how each file should be treated (plain file or with library search). The // function only links bitcode and produces a result list of items that are // native objects. bool Linker::LinkInItems(const ItemList& Items, ItemList& NativeItems) { // Clear the NativeItems just in case NativeItems.clear(); // For each linkage item ... for (ItemList::const_iterator I = Items.begin(), E = Items.end(); I != E; ++I) { if (I->second) { // Link in the library suggested. bool is_native = false; if (LinkInLibrary(I->first, is_native)) return true; if (is_native) NativeItems.push_back(*I); } else { // Link in the file suggested bool is_native = false; if (LinkInFile(sys::Path(I->first), is_native)) return true; if (is_native) NativeItems.push_back(*I); } } return false; }
void SimulationBar::forEachSimulator(boost::function<void(SimulatorItem* simulator)> callback, bool doSelect) { MessageView* mv = MessageView::instance(); /* ItemList<SimulatorItem> simulators = ItemTreeView::mainInstance()->selectedItems<SimulatorItem>(); */ ItemList<SimulatorItem> simulators = ItemTreeView::mainInstance()->selectedItems<SimulatorItem>(); if(simulators.empty()){ simulators.extractChildItems(RootItem::instance()); if(simulators.empty()){ mv->notify(_("There is no simulator item.")); } else if(simulators.size() > 1){ simulators.clear(); mv->notify(_("Please select a simulator item to simulate.")); } else { if(doSelect){ ItemTreeView::instance()->selectItem(simulators.front()); } } } typedef map<WorldItem*, SimulatorItem*> WorldToSimulatorMap; WorldToSimulatorMap worldToSimulator; for(int i=0; i < simulators.size(); ++i){ SimulatorItem* simulator = simulators.get(i); WorldItem* world = simulator->findOwnerItem<WorldItem>(); if(world){ WorldToSimulatorMap::iterator p = worldToSimulator.find(world); if(p == worldToSimulator.end()){ worldToSimulator[world] = simulator; } else { p->second = 0; // skip if multiple simulators are selected } } } for(int i=0; i < simulators.size(); ++i){ SimulatorItem* simulator = simulators.get(i); WorldItem* world = simulator->findOwnerItem<WorldItem>(); if(!world){ mv->notify(format(_("%1% cannot be processed because it is not related with a world.")) % simulator->name()); } else { WorldToSimulatorMap::iterator p = worldToSimulator.find(world); if(p != worldToSimulator.end()){ if(!p->second){ mv->notify(format(_("%1% cannot be processed because another simulator" "in the same world is also selected.")) % simulator->name()); } else { callback(simulator); } } } } }
/** * Calculate prefix paths that end with a node that has the given ItemID. * These nodes can be retrieved very quickly using the FPTree's itemPaths. * A prefix path is a list of Items that reflects a path from the bottom * of the tree to the root (but excluding the root), following along the * path of an FPNode that has the ItemID itemID. Because it is a list of * Items, it also includes both the ItemID and the SupportCount. The * original SupportCount of the Item encapsulated by the FPNode is erased * and replaced by the SupportCount of the FPNode we started from, i.e. a * node that has the ItemID itemID, because we're looking at only the * paths that include this node. * Exclude the leaf node itself, as it will no longer be needed. */ QList<ItemList> FPTree::calculatePrefixPaths(ItemID itemID) const { QList<ItemList> prefixPaths; ItemList prefixPath; FPNode<SupportCount> * node; SupportCount supportCount; Item item; QList<FPNode<SupportCount> *> leafNodes = this->getItemPath(itemID); foreach (FPNode<SupportCount> * leafNode, leafNodes) { // Build the prefix path starting from the given leaf node, by // traversing up the tree (but do not include the leaf node's item // in the prefix path). // Don't copy the item's original count, but the count of the leaf // node instead, because we're looking at only the paths that // include this leaf node. node = leafNode; supportCount = leafNode->getValue(); while ((node = node->getParent()) != NULL && node->getItemID() != ROOT_ITEMID) { item.id = node->getItemID(); item.supportCount = supportCount; prefixPath.prepend(item); } // Store the built prefix path & clear it, so we can calculate the // next. Of course only if there *is* a prefix path, which is not // the case if the given itemID is at the root level. if (prefixPath.size() > 0) { prefixPaths.append(prefixPath); prefixPath.clear(); } }
void TrafficListWidget::UpdateList() { assert(filter_widget != nullptr); items.clear(); last_update.Clear(); const TCHAR *callsign = filter_widget->GetValueString(CALLSIGN); if (!StringIsEmpty(callsign)) { FlarmId ids[30]; unsigned count = FlarmDetails::FindIdsByCallSign(callsign, ids, 30); for (unsigned i = 0; i < count; ++i) AddItem(ids[i]); } else { /* if no filter was set, show a list of current traffic and known traffic */ /* add live FLARM traffic */ for (const auto &i : CommonInterface::Basic().flarm.traffic.list) { AddItem(i.id); } /* add FLARM peers that have a user-defined color */ for (const auto &i : traffic_databases->flarm_colors) { Item &item = AddItem(i.first); item.color = i.second; } /* add FLARM peers that have a user-defined name */ for (const auto &i : traffic_databases->flarm_names) { AddItem(i.id); } #ifdef HAVE_SKYLINES_TRACKING_HANDLER /* show SkyLines traffic unless this is a FLARM traffic picker dialog (from dlgTeamCode) */ if (action_listener == nullptr) { const auto &data = tracking->GetSkyLinesData(); const ScopeLock protect(data.mutex); for (const auto &i : data.traffic) { items.emplace_back(i.first, i.second.location); Item &item = items.back(); if (i.second.location.IsValid() && CommonInterface::Basic().location_available) item.vector = GeoVector(CommonInterface::Basic().location, i.second.location); } } #endif } GetList().SetLength(items.size()); UpdateVolatile(); UpdateButtons(); }
void CLxItemSelection::GetList ( ItemList &list) { CLxUser_Item item; LXtScanInfoID scan; void *pkt; list.clear (); scan = 0; while (scan = srv_sel.ScanLoop (scan, sel_ID, &pkt)) { pkt_trans.GetItem (pkt, item); if (Include (item)) list.push_back (item); } }
// LinkItems - This function is the main entry point into linking. It takes a // list of LinkItem which indicates the order the files should be linked and // how each file should be treated (plain file or with library search). The // function only links bitcode and produces a result list of items that are // native objects. bool Linker::LinkInItems(const ItemList& Items, ItemList& NativeItems) { // Clear the NativeItems just in case NativeItems.clear(); // For each linkage item ... for (ItemList::const_iterator I = Items.begin(), E = Items.end(); I != E; ++I) { if (I->second) { // Link in the library suggested. bool is_native = false; if (LinkInLibrary(I->first, is_native)) return true; if (is_native) NativeItems.push_back(*I); } else { // Link in the file suggested bool is_native = false; if (LinkInFile(sys::Path(I->first), is_native)) return true; if (is_native) NativeItems.push_back(*I); } } // At this point we have processed all the link items provided to us. Since // we have an aggregated module at this point, the dependent libraries in // that module should also be aggregated with duplicates eliminated. This is // now the time to process the dependent libraries to resolve any remaining // symbols. bool is_native; for (Module::lib_iterator I = Composite->lib_begin(), E = Composite->lib_end(); I != E; ++I) { if(LinkInLibrary(*I, is_native)) return true; if (is_native) NativeItems.push_back(std::make_pair(*I, true)); } return false; }
bool PictureAspectRatioBox::list( MP4FileHandle file, ItemList& itemList ) { itemList.clear(); MP4File& mp4 = *((MP4File*)file); const uint16_t trackc = mp4.GetNumberOfTracks(); for( uint16_t i = 0; i < trackc; i++) { MP4TrackId id = mp4.FindTrackId( i ); if( id == MP4_INVALID_TRACK_ID ) continue; const char* type = mp4.GetTrackType( id ); if( !type ) continue; itemList.resize( itemList.size() + 1 ); IndexedItem& xitem = itemList[itemList.size()-1]; xitem.trackIndex = i; xitem.trackId = id; bool success = false; try { success = !get( file, i, xitem.item ); } catch( MP4Exception* x ) { delete x; } if( !success ) { itemList.resize( itemList.size() - 1 ); continue; } } return false; }