Added a couple of methods for app_info finding.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@460 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2002-07-26 20:00:15 +00:00
parent 2a2585c598
commit 679ac7ab0d
2 changed files with 42 additions and 0 deletions

View File

@ -98,6 +98,28 @@ AppInfoList::IndexOf(team_id team) const
return -1; return -1;
} }
// IndexOf
int32
AppInfoList::IndexOf(const entry_ref *ref) const
{
for (int32 i = 0; RosterAppInfo *info = InfoAt(i); i++) {
if (info->ref == *ref)
return i;
}
return -1;
}
// IndexOfToken
int32
AppInfoList::IndexOfToken(uint32 token) const
{
for (int32 i = 0; RosterAppInfo *info = InfoAt(i); i++) {
if (info->token == token)
return i;
}
return -1;
}
// InfoAt // InfoAt
RosterAppInfo * RosterAppInfo *
AppInfoList::InfoAt(int32 index) const AppInfoList::InfoAt(int32 index) const
@ -119,6 +141,20 @@ AppInfoList::InfoFor(team_id team) const
return InfoAt(IndexOf(team)); return InfoAt(IndexOf(team));
} }
// InfoFor
RosterAppInfo *
AppInfoList::InfoFor(const entry_ref *ref) const
{
return InfoAt(IndexOf(ref));
}
// InfoForToken
RosterAppInfo *
AppInfoList::InfoForToken(uint32 token) const
{
return InfoAt(IndexOfToken(token));
}
// CountInfos // CountInfos
int32 int32
AppInfoList::CountInfos() const AppInfoList::CountInfos() const

View File

@ -30,6 +30,8 @@
#include <List.h> #include <List.h>
#include <OS.h> #include <OS.h>
class entry_ref;
class RosterAppInfo; class RosterAppInfo;
class AppInfoList { class AppInfoList {
@ -45,10 +47,14 @@ public:
int32 IndexOf(RosterAppInfo *info) const; int32 IndexOf(RosterAppInfo *info) const;
int32 IndexOf(const char *signature) const; int32 IndexOf(const char *signature) const;
int32 IndexOf(team_id team) const; int32 IndexOf(team_id team) const;
int32 IndexOf(const entry_ref *ref) const;
int32 IndexOfToken(uint32 token) const;
RosterAppInfo *InfoAt(int32 index) const; RosterAppInfo *InfoAt(int32 index) const;
RosterAppInfo *InfoFor(const char *signature) const; RosterAppInfo *InfoFor(const char *signature) const;
RosterAppInfo *InfoFor(team_id team) const; RosterAppInfo *InfoFor(team_id team) const;
RosterAppInfo *InfoFor(const entry_ref *ref) const;
RosterAppInfo *InfoForToken(uint32 token) const;
int32 CountInfos() const; int32 CountInfos() const;