本文整理汇总了C++中BObjectList::ItemAt方法的典型用法代码示例。如果您正苦于以下问题:C++ BObjectList::ItemAt方法的具体用法?C++ BObjectList::ItemAt怎么用?C++ BObjectList::ItemAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BObjectList
的用法示例。
在下文中一共展示了BObjectList::ItemAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BMenu
BMenu*
MenuBuilder::BuildMenu(KeyBind* bind, MenuFilter* filter,
CustomMenuCreator* custom)
{
if (bind == NULL)
return NULL;
// The first item describe the menu
BMenu* menu = new BMenu(bind[0].label);
if (filter != NULL)
filter->FilterMenu(menu, bind[0].message);
BObjectList<BMenu> menuList;
menuList.AddItem(menu);
for (int i = 1; bind[i].itemType != FABER_EOF; i++) {
menu = menuList.ItemAt(menuList.CountItems()-1);
if (bind[i].itemType == FABER_ITEM_START) {
BMenu* subMenu = NULL;
subMenu = new BMenu(bind[i].label);
if (filter != NULL)
filter->FilterMenu(subMenu, bind[i].message);
menu->AddItem(subMenu);
menuList.AddItem(subMenu);
} else if (bind[i].itemType == FABER_ITEM_END) {
if (menuList.CountItems() > 1)
menuList.RemoveItemAt(menuList.CountItems()-1);
} else if (bind[i].itemType == FABER_CUSTOM_ITEM) {
if (custom == NULL)
continue;
BMenu* customMenu = custom->CreateCustomMenu(bind[i].message);
if (customMenu != NULL)
menu->AddItem(customMenu);
} else if (bind[i].itemType == FABER_SUBITEM) {
BMenuItem* item = BuildMenuItem(bind[i].message, bind[i].label);
if (filter != NULL)
filter->FilterItem(item, bind[i].message);
menu->AddItem(item);
} else if (bind[i].itemType == FABER_SPLITTER)
menu->AddItem(new BSeparatorItem());
}
return menuList.ItemAt(0);
}
示例2:
// TODO: move this to the KeyStore or the registrar backend if needed
static bool
CompareLists(BObjectList<BString> a, BObjectList<BString> b)
{
if (a.CountItems() != b.CountItems())
return false;
for (int32 i = 0; i < a.CountItems(); i++) {
if (*a.ItemAt(i) != *b.ItemAt(i))
return false;
}
return true;
}
示例3: symbols
status_t
ImageDebugInfo::FinishInit(DebuggerInterface* interface)
{
BObjectList<SymbolInfo> symbols(50, true);
status_t error = interface->GetSymbolInfos(fImageInfo.TeamID(),
fImageInfo.ImageID(), symbols);
if (error != B_OK)
return error;
symbols.SortItems(&_CompareSymbols);
// get functions -- get them from most expressive debug info first and add
// missing functions from less expressive debug infos
for (int32 i = 0; SpecificImageDebugInfo* specificInfo
= fSpecificInfos.ItemAt(i); i++) {
BObjectList<FunctionDebugInfo> functions;
error = specificInfo->GetFunctions(symbols, functions);
if (error != B_OK)
return error;
for (int32 k = 0; FunctionDebugInfo* function = functions.ItemAt(k);
k++) {
if (FunctionAtAddress(function->Address()) != NULL)
continue;
FunctionInstance* instance = new(std::nothrow) FunctionInstance(
this, function);
if (instance == NULL
|| !fFunctions.BinaryInsert(instance, &_CompareFunctions)) {
delete instance;
error = B_NO_MEMORY;
break;
}
if (function->IsMain())
fMainFunction = instance;
}
// Remove references returned by the specific debug info -- the
// FunctionInstance objects have references, now.
for (int32 k = 0; FunctionDebugInfo* function = functions.ItemAt(k);
k++) {
function->ReleaseReference();
}
if (error != B_OK)
return error;
}
return B_OK;
}
示例4: new
/*static*/ status_t
SpecificImageDebugInfo::GetFunctionsFromSymbols(
const BObjectList<SymbolInfo>& symbols,
BObjectList<FunctionDebugInfo>& functions, DebuggerInterface* interface,
const ImageInfo& imageInfo, SpecificImageDebugInfo* info)
{
// create the function infos
int32 functionsAdded = 0;
for (int32 i = 0; SymbolInfo* symbol = symbols.ItemAt(i); i++) {
if (symbol->Type() != B_SYMBOL_TYPE_TEXT)
continue;
FunctionDebugInfo* function = new(std::nothrow) BasicFunctionDebugInfo(
info, symbol->Address(), symbol->Size(), symbol->Name(),
Demangler::Demangle(symbol->Name()));
if (function == NULL || !functions.AddItem(function)) {
delete function;
int32 index = functions.CountItems() - 1;
for (; functionsAdded >= 0; functionsAdded--, index--) {
function = functions.RemoveItemAt(index);
delete function;
}
return B_NO_MEMORY;
}
functionsAdded++;
}
return B_OK;
}
示例5: if
BSolverPackage*
PackageManager::_GetSolverPackage(PackageInfoRef package)
{
int32 flags = BSolver::B_FIND_IN_NAME;
if (package->State() == ACTIVATED || package->State() == INSTALLED)
flags |= BSolver::B_FIND_INSTALLED_ONLY;
BObjectList<BSolverPackage> packages;
status_t result = Solver()->FindPackages(package->Title(),
flags, packages);
if (result == B_OK) {
for (int32 i = 0; i < packages.CountItems(); i++) {
BSolverPackage* solverPackage = packages.ItemAt(i);
if (solverPackage->Name() != package->Title())
continue;
else if (package->State() == NONE
&& dynamic_cast<BPackageManager::RemoteRepository*>(
solverPackage->Repository()) == NULL) {
continue;
}
return solverPackage;
}
}
return NULL;
}
示例6:
void
PairsView::Draw(BRect updateRect)
{
BObjectList<BBitmap>* bitmapsList;
switch (fIconSize) {
case kSmallIconSize:
bitmapsList = fSmallBitmapsList;
break;
case kLargeIconSize:
bitmapsList = fLargeBitmapsList;
break;
case kMediumIconSize:
default:
bitmapsList = fMediumBitmapsList;
}
for (int32 i = 0; i < fButtonsCount; i++) {
SetDrawingMode(B_OP_ALPHA);
DrawBitmap(bitmapsList->ItemAt(i % (fButtonsCount / 2)),
BPoint(fPositionX[i], fPositionY[i]));
SetDrawingMode(B_OP_COPY);
}
}
示例7: PackageAttribute
void
WriterImplBase::RegisterPackageResolvableExpressionList(
PackageAttributeList& attributeList,
const BObjectList<BPackageResolvableExpression>& expressionList, uint8 id)
{
for (int i = 0; i < expressionList.CountItems(); ++i) {
BPackageResolvableExpression* resolvableExpr = expressionList.ItemAt(i);
bool hasVersion = resolvableExpr->Version().InitCheck() == B_OK;
PackageAttribute* name = new PackageAttribute((BHPKGAttributeID)id,
B_HPKG_ATTRIBUTE_TYPE_STRING,
B_HPKG_ATTRIBUTE_ENCODING_STRING_TABLE);
name->string = fPackageStringCache.Get(resolvableExpr->Name().String());
attributeList.Add(name);
if (hasVersion) {
PackageAttribute* op = new PackageAttribute(
B_HPKG_ATTRIBUTE_ID_PACKAGE_RESOLVABLE_OPERATOR,
B_HPKG_ATTRIBUTE_TYPE_UINT,
B_HPKG_ATTRIBUTE_ENCODING_INT_8_BIT);
op->unsignedInt = resolvableExpr->Operator();
name->children.Add(op);
RegisterPackageVersion(name->children, resolvableExpr->Version());
}
}
}
示例8:
/** We share one global list for all BMediaFormats in the team - since the
* format data can change at any time, we have to update the list to ensure
* that we are working on the latest data set. The list is always sorted by
* description. The formats lock has to be held when you call this function.
*/
static status_t
update_media_formats()
{
if (!sLock.IsLocked())
return B_NOT_ALLOWED;
// We want the add-ons to register themselves with the format manager, so
// the list is up to date.
AddOnManager::GetInstance()->RegisterAddOns();
BMessage reply;
FormatManager::GetInstance()->GetFormats(sLastFormatsUpdate, reply);
// do we need an update at all?
bool needUpdate;
if (reply.FindBool("need_update", &needUpdate) < B_OK)
return B_ERROR;
if (!needUpdate)
return B_OK;
// update timestamp and check if the message is okay
type_code code;
int32 count;
if (reply.FindInt64("timestamp", &sLastFormatsUpdate) < B_OK
|| reply.GetInfo("formats", &code, &count) < B_OK)
return B_ERROR;
// overwrite already existing formats
int32 index = 0;
for (; index < sFormats.CountItems() && index < count; index++) {
meta_format* item = sFormats.ItemAt(index);
const meta_format* newItem;
ssize_t size;
if (reply.FindData("formats", MEDIA_META_FORMAT_TYPE, index,
(const void**)&newItem, &size) == B_OK)
*item = *newItem;
}
// allocate additional formats
for (; index < count; index++) {
const meta_format* newItem;
ssize_t size;
if (reply.FindData("formats", MEDIA_META_FORMAT_TYPE, index,
(const void**)&newItem, &size) == B_OK)
sFormats.AddItem(new meta_format(*newItem));
}
// remove no longer used formats
while (count < sFormats.CountItems())
delete sFormats.RemoveItemAt(count);
return B_OK;
}
示例9: _
void
reconnect_bitmaps_to_app_server()
{
BAutolock _(sBitmapListLock);
for (int32 i = 0; i < sBitmapList.CountItems(); i++) {
BBitmap::Private bitmap(sBitmapList.ItemAt(i));
bitmap.ReconnectToAppServer();
}
}
示例10: add_resolvables
static void add_resolvables(Repo *repo, Offset &dependencies,
const BObjectList<BPackageResolvable> &resolvables)
{
for (int32 i = 0; BPackageResolvable *resolvable = resolvables.ItemAt(i); i++)
{
add_dependency(repo, dependencies, resolvable->Name(),
resolvable->Version().ToString(), REL_EQ,
resolvable->CompatibleVersion().ToString());
}
}
示例11: RemoveNickFromList
void ChannelAgent::RemoveNickFromList(BObjectList<BString>& list, const char* data)
{
int32 count(list.CountItems());
for (int32 i = 0; i < count; i++) {
if (list.ItemAt(i)->ICompare(data) == 0) {
delete list.RemoveItemAt(i);
break;
}
}
}
示例12: MergeTasks
Task* TaskMerge::MergeTasks(Task* firstTask, Task *secondTask)
{
int32 i = 0;
BObjectList<TaskSync>* oldSyncs = NULL;
if ((*firstTask) == (*secondTask))
return firstTask;
if ((*firstTask)>(*secondTask)){
oldSyncs = secondTask->Source();
secondTask->SetTo(firstTask);
for (i=0;i<oldSyncs->CountItems();i++)
secondTask->AddSource(oldSyncs->ItemAt(i));
return secondTask;
}
else{
oldSyncs = firstTask->Source();
firstTask->SetTo(secondTask);
for (i=0;i<oldSyncs->CountItems();i++)
firstTask->AddSource(oldSyncs->ItemAt(i));
return firstTask;
}
}
示例13: new
status_t
ImageDebugInfo::FinishInit()
{
// get functions -- get them from most expressive debug info first and add
// missing functions from less expressive debug infos
for (int32 i = 0; SpecificImageDebugInfo* specificInfo
= fSpecificInfos.ItemAt(i); i++) {
BObjectList<FunctionDebugInfo> functions;
status_t error = specificInfo->GetFunctions(functions);
if (error != B_OK)
return error;
for (int32 k = 0; FunctionDebugInfo* function = functions.ItemAt(k);
k++) {
if (FunctionAtAddress(function->Address()) != NULL)
continue;
FunctionInstance* instance = new(std::nothrow) FunctionInstance(
this, function);
if (instance == NULL
|| !fFunctions.BinaryInsert(instance, &_CompareFunctions)) {
delete instance;
error = B_NO_MEMORY;
break;
}
}
// Remove references returned by the specific debug info -- the
// FunctionInstance objects have references, now.
for (int32 k = 0; FunctionDebugInfo* function = functions.ItemAt(k);
k++) {
function->ReleaseReference();
}
if (error != B_OK)
return error;
}
return B_OK;
}
示例14: data
status_t
DebugReportGenerator::_DumpRunningThreads(BFile& _output)
{
AutoLocker< ::Team> locker(fTeam);
BString data("\nActive Threads:\n");
WRITE_AND_CHECK(_output, data);
BObjectList< ::Thread> threads;
::Thread* thread;
for (ThreadList::ConstIterator it = fTeam->Threads().GetIterator();
(thread = it.Next());) {
threads.AddItem(thread);
}
threads.SortItems(&_CompareThreads);
for (int32 i = 0; (thread = threads.ItemAt(i)) != NULL; i++) {
try {
data.SetToFormat("\tthread %" B_PRId32 ": %s %s\n", thread->ID(),
thread->Name(), thread->IsMainThread()
? "(main)" : "");
WRITE_AND_CHECK(_output, data);
if (thread->State() == THREAD_STATE_STOPPED) {
data.SetToFormat("\t\tstate: %s",
UiUtils::ThreadStateToString(thread->State(),
thread->StoppedReason()));
const BString& stoppedInfo = thread->StoppedReasonInfo();
if (stoppedInfo.Length() != 0)
data << " (" << stoppedInfo << ")";
data << "\n\n";
WRITE_AND_CHECK(_output, data);
// we need to release our lock on the team here
// since we might need to block and wait
// on the stack trace.
BReference< ::Thread> threadRef(thread);
locker.Unlock();
status_t error = _DumpDebuggedThreadInfo(_output, thread);
if (error != B_OK)
return error;
locker.Lock();
}
} catch (...) {
return B_NO_MEMORY;
}
}
return B_OK;
}
示例15: addonName
status_t
ModuleManager::_GetAddOn(const char *name, ModuleAddOn **_addon)
{
// search list first
for (int32 i = 0; ModuleAddOn *addon = fAddOns.ItemAt(i); i++) {
BString addonName(addon->Name());
addonName << "/";
if (!strcmp(name, addon->Name())
|| !strncmp(addonName.String(), name, addonName.Length())) {
addon->Get();
*_addon = addon;
return B_OK;
}
}
// not in list yet, load from disk
// iterate through module dirs
for (int32 i = 0; gModuleDirs[i]; i++) {
BPath path;
if (path.SetTo(gModuleDirs[i]) == B_OK
&& path.SetTo(path.Path(), name) == B_OK) {
BEntry entry;
for (;;) {
if (entry.SetTo(path.Path()) == B_OK && entry.Exists()) {
// found an entry: if it is a file, try to load it
if (entry.IsFile()) {
ModuleAddOn *addon = new ModuleAddOn;
if (addon->Load(path.Path(), gModuleDirs[i]) == B_OK) {
status_t status = addon->Get();
if (status < B_OK) {
delete addon;
return status;
}
fAddOns.AddItem(addon);
*_addon = addon;
return B_OK;
}
delete addon;
}
break;
}
// chop off last path component
if (path.GetParent(&path) != B_OK)
break;
}
}
}
return B_ENTRY_NOT_FOUND;
}