本文整理汇总了C++中BObjectList::EachElement方法的典型用法代码示例。如果您正苦于以下问题:C++ BObjectList::EachElement方法的具体用法?C++ BObjectList::EachElement怎么用?C++ BObjectList::EachElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BObjectList
的用法示例。
在下文中一共展示了BObjectList::EachElement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MediaFilePlayer
void
PlayMediaFile(const char* media_type, const char* media_name)
{
entry_ref ref;
if (BMediaFiles().GetRefFor(media_type, media_name, &ref) != B_OK
|| !BEntry(&ref).Exists())
return;
MediaFilePlayer* player = list.EachElement(FindMediaFilePlayer,
(void*)media_name);
if (player != NULL) {
if (*(player->Ref()) == ref) {
player->Restart();
return;
}
list.RemoveItem(player);
delete player;
player = NULL;
}
if (player == NULL) {
player = new MediaFilePlayer(media_type, media_name, &ref);
if (player->InitCheck() == B_OK)
list.AddItem(player);
else
delete player;
}
}
示例2: entry
static const entry_ref*
AddOneUniqueDocumentType(const entry_ref* ref, void* castToList)
{
BObjectList<BString>* list = (BObjectList<BString>*)castToList;
BEntry entry(ref, true);
// traverse symlinks
// get this documents type
char type[B_MIME_TYPE_LENGTH];
BFile file(&entry, O_RDONLY);
if (file.InitCheck() != B_OK)
return 0;
BNodeInfo info(&file);
if (info.GetType(type) != B_OK)
return 0;
if (list->EachElement(FindOne, &type))
// type already in list, bail
return 0;
// add type to list
list->AddItem(new BString(type));
return 0;
}