From 679ac7ab0d960044c8c6719cd800130fa900b95b Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Fri, 26 Jul 2002 20:00:15 +0000 Subject: [PATCH] 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 --- src/servers/registrar/AppInfoList.cpp | 36 +++++++++++++++++++++++++++ src/servers/registrar/AppInfoList.h | 6 +++++ 2 files changed, 42 insertions(+) diff --git a/src/servers/registrar/AppInfoList.cpp b/src/servers/registrar/AppInfoList.cpp index c3689bd15e..ca9895552d 100644 --- a/src/servers/registrar/AppInfoList.cpp +++ b/src/servers/registrar/AppInfoList.cpp @@ -98,6 +98,28 @@ AppInfoList::IndexOf(team_id team) const 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 RosterAppInfo * AppInfoList::InfoAt(int32 index) const @@ -119,6 +141,20 @@ AppInfoList::InfoFor(team_id team) const 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 int32 AppInfoList::CountInfos() const diff --git a/src/servers/registrar/AppInfoList.h b/src/servers/registrar/AppInfoList.h index 90d53577f9..56dde2fa52 100644 --- a/src/servers/registrar/AppInfoList.h +++ b/src/servers/registrar/AppInfoList.h @@ -30,6 +30,8 @@ #include #include +class entry_ref; + class RosterAppInfo; class AppInfoList { @@ -45,10 +47,14 @@ public: int32 IndexOf(RosterAppInfo *info) const; int32 IndexOf(const char *signature) 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 *InfoFor(const char *signature) const; RosterAppInfo *InfoFor(team_id team) const; + RosterAppInfo *InfoFor(const entry_ref *ref) const; + RosterAppInfo *InfoForToken(uint32 token) const; int32 CountInfos() const;