give modules the ability to iterate over the registered names and targets

for a particular client.
This commit is contained in:
darin%netscape.com 2002-11-04 20:30:54 +00:00
parent 040591c7ae
commit f98ae2ca80
4 changed files with 60 additions and 5 deletions

View File

@ -154,9 +154,12 @@ public:
DeleteFirst();
}
T *First() { return mHead; }
T *Last() { return mTail; }
PRBool IsEmpty() { return mHead == NULL; }
const T *First() const { return mHead; }
T *First() { return mHead; }
const T *Last() const { return mTail; }
T *Last() { return mTail; }
PRBool IsEmpty() const { return mHead == NULL; }
protected:
void AdvanceHead()

View File

@ -68,6 +68,10 @@ public:
void DelTarget(const nsID &target);
PRBool HasTarget(const nsID &target) const { return mTargets.Find(target) != NULL; }
// list iterators
const ipcStringNode *Names() const { return mNames.First(); }
const ipcIDNode *Targets() const { return mTargets.First(); }
//
// returns TRUE if successfully enqueued. will return FALSE if client
// does not have a registered message handler for this message's target.

View File

@ -413,6 +413,40 @@ ipcClient *IPC_GetClientByName(const char *name)
return NULL;
}
PRBool
IPC_ClientHasName(ipcClient *client, const char *name)
{
return client->HasName(name);
}
PRBool
IPC_ClientHasTarget(ipcClient *client, const nsID &target)
{
return client->HasTarget(target);
}
void
IPC_EnumerateClientNames(ipcClient *client, ipcClientNameEnumFunc func, void *closure)
{
const ipcStringNode *node = client->Names();
while (node) {
if (func(closure, client, node->Value()) == PR_FALSE)
break;
node = node->mNext;
}
}
void
IPC_EnumerateClientTargets(ipcClient *client, ipcClientTargetEnumFunc func, void *closure)
{
const ipcIDNode *node = client->Targets();
while (node) {
if (func(closure, client, node->Value()) == PR_FALSE)
break;
node = node->mNext;
}
}
ipcClient *IPC_GetClients(int *count)
{
*count = poll_fd_count - 1;

View File

@ -93,8 +93,22 @@ IPC_API const char *IPC_GetClientName(ipcClient *client);
//
// client lookup functions
//
IPC_API ipcClient *IPC_GetClientByID(int clientID);
IPC_API ipcClient *IPC_GetClientByName(const char *clientName);
IPC_API ipcClient *IPC_GetClientByID(int id);
IPC_API ipcClient *IPC_GetClientByName(const char *name);
//
// functions for inspecting the names and targets defined for a particular
// client instance.
//
IPC_API PRBool IPC_ClientHasName(ipcClient *client, const char *name);
IPC_API PRBool IPC_ClientHasTarget(ipcClient *client, const nsID &target);
// return PR_FALSE to end enumeration
typedef PRBool (* ipcClientNameEnumFunc)(void *closure, ipcClient *client, const char *name);
typedef PRBool (* ipcClientTargetEnumFunc)(void *closure, ipcClient *client, const nsID &target);
IPC_API void IPC_EnumerateClientNames(ipcClient *client, ipcClientNameEnumFunc func, void *closure);
IPC_API void IPC_EnumerateClientTargets(ipcClient *client, ipcClientTargetEnumFunc func, void *closure);
//
// return array of all clients, length equal to |count|.