Design Pattern Examples
Overview of object-oriented design patterns
Mediator_UserList.h
Go to the documentation of this file.
1
5
6#pragma once
7#ifndef __MEDIATOR_USERLIST_H__
8#define __MEDIATOR_USERLIST_H__
9
10#include <stdlib.h>
11#include <stdbool.h>
12
13#include "Mediator_User.h"
14
19typedef struct
20{
22 size_t users_count;
24} UserList;
25
26//-----------------------------------------------------------------------------
27
32void UserList_Initialize(UserList* userList);
33
41void UserList_Clear(UserList* userList);
42
50bool UserList_AddUser(UserList* userList, User* user);
51
61int UserList_FindUser(UserList* userList, const char* userName);
62
72void UserList_RemoveUser(UserList* userList, int removeIndex);
73
74#endif // __MEDIATOR_USERLIST_H__
Declaration of the User structure and the associated support functions as used in the Mediator Patter...
void UserList_RemoveUser(UserList *userList, int removeIndex)
Remove the user at the specified index in the given UserList object.
bool UserList_AddUser(UserList *userList, User *user)
Add the specified User object to the specified UserList object. The list takes ownership of the User ...
void UserList_Clear(UserList *userList)
Clear the given UserList object to release all associated resources.
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 f...
void UserList_Initialize(UserList *userList)
Initialize the given UserList object for initial use.
Represents a user with a name.
Definition: Mediator_User.h:14
Represents a list of users. Call UserList_Initialize() to start and UserList_Clear() to release all r...
User ** users
Array of pointers to User objects.
size_t users_count
Number of pointers in the users list.
size_t allocated_count
Size of the allocated users list.