The front end of the Mediator system that mediates between the Users and the Groups sub-systems. Contains the declarations of the Mediator functions as used in the Mediator Pattern. More...
#include "helpers/stringlist.h"
Go to the source code of this file.
Macros | |
#define | __MEDIATOR_FUNCTIONS_H__ |
Enumerations | |
enum | MediatorErrorCode { MediatorErrorCode_No_Error = 0 , MediatorErrorCode_Null_Argument = 1 , MediatorErrorCode_User_Does_Not_Exist = 2 , MediatorErrorCode_Group_Does_Not_Exist = 3 , MediatorErrorCode_No_Memory = 4 } |
Represents error codes that can be returned from the Mediator functions used in the Mediator Pattern. More... | |
Functions | |
void | Mediator_ClearAll (void) |
Clear all memory associated with groups and users. | |
MediatorErrorCode | Mediator_AddUser (const char *userName) |
Add a user to the list of known users. If the name is already in the list of users, the request to add is ignored. | |
MediatorErrorCode | Mediator_RemoveUser (const char *userName) |
Removes the specified user from the list of known users, if the user exists. Also removes the user from all groups. | |
MediatorErrorCode | Mediator_AddGroup (const char *groupName) |
Add a group to the list of known groups. If the group is already in the list, the request to add is ignored. | |
MediatorErrorCode | Mediator_RemoveGroup (const char *groupName) |
Remove the specified group from the list of known groups if the group exists. | |
MediatorErrorCode | Mediator_AddUserToGroup (const char *userName, const char *groupName) |
Add the specified user to the specified group. If the user is already in the group, do nothing. The user must exist. | |
MediatorErrorCode | Mediator_RemoveUserFromGroup (const char *userName, const char *groupName) |
Remove the specified user from the specified group. | |
MediatorErrorCode | Mediator_RemoveUserFromAllGroups (const char *userName) |
Remove the specified user from all existing groups. The user still exists. | |
MediatorErrorCode | Mediator_GetAllGroups (StringList *groups) |
Retrieve a list of all known groups. | |
MediatorErrorCode | Mediator_GetAllUsers (StringList *users) |
Retrieve a list of all known users. | |
bool | Mediator_IsUserInGroup (const char *userName, const char *groupName) |
Determine if the specified user is in the specified group. | |
MediatorErrorCode | Mediator_GetUsersInGroup (const char *groupName, StringList *users) |
Retrieve a list of users in the specified group. | |
MediatorErrorCode | Mediator_GetGroupsWithUser (const char *userName, StringList *groups) |
Retrieve a list of all groups that contain the specified user. | |
The front end of the Mediator system that mediates between the Users and the Groups sub-systems. Contains the declarations of the Mediator functions as used in the Mediator Pattern.
Definition in file Mediator_Functions.h.
#define __MEDIATOR_FUNCTIONS_H__ |
Definition at line 9 of file Mediator_Functions.h.
enum MediatorErrorCode |
Represents error codes that can be returned from the Mediator functions used in the Mediator Pattern.
Definition at line 17 of file Mediator_Functions.h.
MediatorErrorCode Mediator_AddGroup | ( | const char * | groupName | ) |
Add a group to the list of known groups. If the group is already in the list, the request to add is ignored.
groupName | Name of the group to add. Do nothing if null or empty. |
MediatorErrorCode_No_Error | indicates success. |
MediatorErrorCode_Null_Argument | indicates the group parameter is null. |
MediatorErrorCode_No_Memory | indicates an out of memory condition. |
Definition at line 77 of file Mediator_Functions.c.
References GroupErrorCode_No_Memory, Groups_AddGroup(), MediatorErrorCode_No_Error, MediatorErrorCode_No_Memory, and MediatorErrorCode_Null_Argument.
Referenced by Mediator_SetupGroups().
MediatorErrorCode Mediator_AddUser | ( | const char * | userName | ) |
Add a user to the list of known users. If the name is already in the list of users, the request to add is ignored.
userName | Name of the user to add. Do nothing if null or empty. |
MediatorErrorCode_No_Error | indicates success. |
MediatorErrorCode_Null_Argument | indicates the user parameter is null. |
MediatorErrorCode_No_Memory | indicates an out of memory condition. |
Definition at line 27 of file Mediator_Functions.c.
References MediatorErrorCode_No_Error, MediatorErrorCode_No_Memory, MediatorErrorCode_Null_Argument, UserErrorCode_No_Memory, and Users_AddUser().
Referenced by Mediator_SetupUsers().
MediatorErrorCode Mediator_AddUserToGroup | ( | const char * | userName, |
const char * | groupName | ||
) |
Add the specified user to the specified group. If the user is already in the group, do nothing. The user must exist.
userName | Name of user to add. Must be an existing user. |
groupName | Name of group to add user to. Must be an existing group. |
MediatorErrorCode_No_Error | indicates success. |
MediatorErrorCode_Null_Argument | indicates the user or group parameter is null. |
MediatorErrorCode_User_Does_Not_Exist | indicates the user does not exist. |
MediatorErrorCode_Group_Does_Not_Exist | indicates the group does not exist. |
MediatorErrorCode_No_Memory | indicates an out of memory condition. |
Definition at line 123 of file Mediator_Functions.c.
References GroupErrorCode_Group_Does_Not_Exist, GroupErrorCode_No_Memory, Groups_AddUserGroup(), Groups_UserInGroup(), MediatorErrorCode_Group_Does_Not_Exist, MediatorErrorCode_No_Error, MediatorErrorCode_No_Memory, MediatorErrorCode_Null_Argument, and MediatorErrorCode_User_Does_Not_Exist.
Referenced by _Mediator_Example_AddUserToGroup(), and Mediator_SetupGroups().
void Mediator_ClearAll | ( | void | ) |
Clear all memory associated with groups and users.
Definition at line 18 of file Mediator_Functions.c.
References Groups_Clear(), and Users_Clear().
Referenced by Mediator_Exercise().
MediatorErrorCode Mediator_GetAllGroups | ( | StringList * | groups | ) |
Retrieve a list of all known groups.
groups | A StringList object to be filled with the names of all known groups. |
MediatorErrorCode_No_Error | indicates success. |
MediatorErrorCode_No_Memory | indicates an out of memory condition. |
Definition at line 205 of file Mediator_Functions.c.
References GroupErrorCode_No_Memory, Groups_GetAllGroups(), MediatorErrorCode_No_Error, MediatorErrorCode_No_Memory, and MediatorErrorCode_Null_Argument.
Referenced by _Mediator_Example_RemoveUser(), and _Mediator_Example_ShowAllGroups().
MediatorErrorCode Mediator_GetAllUsers | ( | StringList * | users | ) |
Retrieve a list of all known users.
users | A StringList object to be filled with the names of all known users. |
MediatorErrorCode_No_Error | indicates success. |
MediatorErrorCode_No_Memory | indicates an out of memory condition. |
Definition at line 227 of file Mediator_Functions.c.
References MediatorErrorCode_No_Error, MediatorErrorCode_No_Memory, MediatorErrorCode_Null_Argument, UserErrorCode_No_Memory, and Users_GetAllUsers().
Referenced by _Mediator_Example_RemoveUser(), and _Mediator_Example_ShowAllUsers().
MediatorErrorCode Mediator_GetGroupsWithUser | ( | const char * | userName, |
StringList * | groups | ||
) |
Retrieve a list of all groups that contain the specified user.
userName | Name of the user to look for. Must be an existing user. |
groups | A StringList object to be filled with the names of the groups containing the user. Object is empty if the name is not in any group. |
MediatorErrorCode_No_Error | indicates success. |
MediatorErrorCode_Null_Argument | indicates the user or groups parameter is null. |
MediatorErrorCode_User_Does_Not_Exist | indicates the user does not exist. |
Definition at line 287 of file Mediator_Functions.c.
References GroupErrorCode_No_Memory, Groups_GetGroupsWithUser(), MediatorErrorCode_No_Error, MediatorErrorCode_No_Memory, and MediatorErrorCode_Null_Argument.
Referenced by _Mediator_Example_AddUserToGroup(), _Mediator_Example_RemoveUserFromAllGroups(), _Mediator_Example_RemoveUserFromGroup(), and _Mediator_Example_ShowAllGroupsContainingUser().
MediatorErrorCode Mediator_GetUsersInGroup | ( | const char * | groupName, |
StringList * | users | ||
) |
Retrieve a list of users in the specified group.
groupName | Name of the group to examine. Must be an existing group. |
users | A StringList object to be filled in with the names of users in the group. Object is empty if the group does not contain any users. |
MediatorErrorCode_No_Error | indicates success. |
MediatorErrorCode_Null_Argument | indicates the group or users parameter is null. |
MediatorErrorCode_Group_Does_Not_Exist | indicates the group does not exist. |
Definition at line 264 of file Mediator_Functions.c.
References GroupErrorCode_No_Memory, Groups_GetAllUsersInGroup(), MediatorErrorCode_No_Error, MediatorErrorCode_No_Memory, and MediatorErrorCode_Null_Argument.
Referenced by _Mediator_Example_RemoveUser(), and _Mediator_Example_ShowUsersInGroup().
bool Mediator_IsUserInGroup | ( | const char * | userName, |
const char * | groupName | ||
) |
Determine if the specified user is in the specified group.
userName | Name of user to find. Should be an existing user. |
groupName | Name of group to look in. Should be an existing group. |
Definition at line 249 of file Mediator_Functions.c.
References Groups_UserInGroup().
Referenced by _Mediator_Example_SeeIfUserInGroup().
MediatorErrorCode Mediator_RemoveGroup | ( | const char * | groupName | ) |
Remove the specified group from the list of known groups if the group exists.
groupName | Name of group to remove. |
MediatorErrorCode_No_Error | indicates success. |
MediatorErrorCode_Null_Argument | indicates the group parameter is null. |
MediatorErrorCode_Group_Does_Not_Exist | indicates the group does not exist. |
Definition at line 100 of file Mediator_Functions.c.
References GroupErrorCode_Group_Does_Not_Exist, Groups_RemoveGroup(), MediatorErrorCode_Group_Does_Not_Exist, MediatorErrorCode_No_Error, and MediatorErrorCode_Null_Argument.
MediatorErrorCode Mediator_RemoveUser | ( | const char * | userName | ) |
Removes the specified user from the list of known users, if the user exists. Also removes the user from all groups.
userName | Name of user to remove. |
MediatorErrorCode_No_Error | indicates success. |
MediatorErrorCode_Null_Argument | indicates the user parameter is null. |
MediatorErrorCode_User_Does_Not_Exist | indicates the user does not exist. |
Definition at line 50 of file Mediator_Functions.c.
References Mediator_RemoveUserFromAllGroups(), MediatorErrorCode_No_Error, MediatorErrorCode_Null_Argument, MediatorErrorCode_User_Does_Not_Exist, UserErrorCode_User_Does_Not_Exist, and Users_RemoveUser().
Referenced by _Mediator_Example_RemoveUser().
MediatorErrorCode Mediator_RemoveUserFromAllGroups | ( | const char * | userName | ) |
Remove the specified user from all existing groups. The user still exists.
userName | Name of user to remove. Must be an existing user. |
MediatorErrorCode_No_Error | indicates success. |
MediatorErrorCode_Null_Argument | indicates the user parameter is null. |
MediatorErrorCode_User_Does_Not_Exist | indicates the user does not exist. |
Definition at line 181 of file Mediator_Functions.c.
References GroupErrorCode_No_Error, Groups_RemoveUserFromAllGroups(), MediatorErrorCode_No_Error, MediatorErrorCode_Null_Argument, MediatorErrorCode_User_Does_Not_Exist, and Users_FindUser().
Referenced by _Mediator_Example_RemoveUserFromAllGroups(), and Mediator_RemoveUser().
MediatorErrorCode Mediator_RemoveUserFromGroup | ( | const char * | userName, |
const char * | groupName | ||
) |
Remove the specified user from the specified group.
userName | Name of user to remove. Must be an existing user. |
groupName | Name of group to remove user from. Must be an existing group. |
MediatorErrorCode_No_Error | indicates success. |
MediatorErrorCode_Null_Argument | indicates the user or group parameter is null. |
MediatorErrorCode_User_Does_Not_Exist | indicates the user does not exist. |
MediatorErrorCode_Group_Does_Not_Exist | indicates the group does not exist. |
Definition at line 154 of file Mediator_Functions.c.
References GroupErrorCode_Group_Does_Not_Exist, Groups_RemoveUserFromGroup(), Groups_UserInGroup(), MediatorErrorCode_Group_Does_Not_Exist, MediatorErrorCode_No_Error, MediatorErrorCode_Null_Argument, and MediatorErrorCode_User_Does_Not_Exist.
Referenced by _Mediator_Example_RemoveUserFromGroup().