Declaration of the UserList structure and the associated support functions as used in the Mediator Pattern. More...


Go to the source code of this file.
Classes | |
| struct | UserList |
| Represents a list of users. Call UserList_Initialize() to start and UserList_Clear() to release all resources and restore to empty state. More... | |
Macros | |
| #define | __MEDIATOR_USERLIST_H__ |
Functions | |
| void | UserList_Initialize (UserList *userList) |
| Initialize the given UserList object for initial use. | |
| void | UserList_Clear (UserList *userList) |
| Clear the given UserList object to release all associated resources. | |
| bool | UserList_AddUser (UserList *userList, User *user) |
| Add the specified User object to the specified UserList object. The list takes ownership of the User object and is responsible for releasing the memory associated with the User object. | |
| int | UserList_FindUser (UserList *userList, const char *userName) |
| Search the given UserList object for the specified user by name and return the index of the user if found. | |
| void | UserList_RemoveUser (UserList *userList, int removeIndex) |
| Remove the user at the specified index in the given UserList object. | |
Declaration of the UserList structure and the associated support functions as used in the Mediator Pattern.
Definition in file Mediator_UserList.h.
| #define __MEDIATOR_USERLIST_H__ |
Definition at line 8 of file Mediator_UserList.h.
Add the specified User object to the specified UserList object. The list takes ownership of the User object and is responsible for releasing the memory associated with the User object.
| userList | The UserList object to which to add the user. |
| user | The User object to add to the list. |
Definition at line 43 of file Mediator_UserList.c.
References UserList::allocated_count, UserList::users, and UserList::users_count.
Referenced by Users_AddUser().
| void UserList_Clear | ( | UserList * | userList | ) |
Clear the given UserList object to release all associated resources.
After this function returns, the object is an empty list ready to be used again.
| userList | The UserList object to clear. |
Definition at line 27 of file Mediator_UserList.c.
References User_Destroy(), UserList_Initialize(), UserList::users, and UserList::users_count.
Referenced by Users_Clear().
| int UserList_FindUser | ( | UserList * | userList, |
| const char * | userName | ||
| ) |
Search the given UserList object for the specified user by name and return the index of the user if found.
| userList | The UserList object to search. |
| userName | The name of the user to look for. This is a case- sensitive search. |
Definition at line 79 of file Mediator_UserList.c.
References User::Name, UserList::users, and UserList::users_count.
Referenced by Users_FindUser(), and Users_RemoveUser().
| void UserList_Initialize | ( | UserList * | userList | ) |
Initialize the given UserList object for initial use.
| userList | The UserList object to initialize. |
Definition at line 14 of file Mediator_UserList.c.
References UserList::allocated_count, UserList::users, and UserList::users_count.
Referenced by UserList_Clear().
| void UserList_RemoveUser | ( | UserList * | userList, |
| int | removeIndex | ||
| ) |
Remove the user at the specified index in the given UserList object.
Since this changes the list of users, all index values after the given index are no longer valid.
| userList | The UserList object to remove from. |
| removeIndex | Index of the user to remove. Use UserList_FindUser() to get this index. |
Definition at line 101 of file Mediator_UserList.c.
References UserList::allocated_count, User_Destroy(), UserList::users, and UserList::users_count.
Referenced by Users_RemoveUser().