Design Pattern Examples
Overview of object-oriented design patterns
Mediator_Functions.h
Go to the documentation of this file.
1
6
7
#pragma once
8
#ifndef __MEDIATOR_FUNCTIONS_H__
9
#define __MEDIATOR_FUNCTIONS_H__
10
11
#include "helpers/stringlist.h"
12
17
typedef
enum
18
{
19
MediatorErrorCode_No_Error
= 0,
20
MediatorErrorCode_Null_Argument
= 1,
21
MediatorErrorCode_User_Does_Not_Exist
= 2,
22
MediatorErrorCode_Group_Does_Not_Exist
= 3,
23
MediatorErrorCode_No_Memory
= 4,
24
}
MediatorErrorCode
;
25
26
27
//-----------------------------------------------------------------------------
28
//-----------------------------------------------------------------------------
29
33
void
Mediator_ClearAll
(
void
);
34
35
46
MediatorErrorCode
Mediator_AddUser
(
const
char
* userName);
47
58
MediatorErrorCode
Mediator_RemoveUser
(
const
char
* userName);
59
70
MediatorErrorCode
Mediator_AddGroup
(
const
char
* groupName);
71
82
MediatorErrorCode
Mediator_RemoveGroup
(
const
char
* groupName);
83
97
MediatorErrorCode
Mediator_AddUserToGroup
(
const
char
* userName,
const
char
* groupName);
98
110
MediatorErrorCode
Mediator_RemoveUserFromGroup
(
const
char
* userName,
const
char
* groupName);
111
121
MediatorErrorCode
Mediator_RemoveUserFromAllGroups
(
const
char
* userName);
122
132
MediatorErrorCode
Mediator_GetAllGroups
(
StringList
* groups);
133
143
MediatorErrorCode
Mediator_GetAllUsers
(
StringList
* users);
144
151
bool
Mediator_IsUserInGroup
(
const
char
* userName,
const
char
* groupName);
152
164
MediatorErrorCode
Mediator_GetUsersInGroup
(
const
char
* groupName,
StringList
* users);
165
177
MediatorErrorCode
Mediator_GetGroupsWithUser
(
const
char
* userName,
StringList
* groups);
178
179
180
#endif
// __MEDIATOR_FUNCTIONS_H__
Mediator_GetAllGroups
MediatorErrorCode Mediator_GetAllGroups(StringList *groups)
Retrieve a list of all known groups.
Definition:
Mediator_Functions.c:205
Mediator_IsUserInGroup
bool Mediator_IsUserInGroup(const char *userName, const char *groupName)
Determine if the specified user is in the specified group.
Definition:
Mediator_Functions.c:249
Mediator_AddGroup
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 i...
Definition:
Mediator_Functions.c:77
Mediator_ClearAll
void Mediator_ClearAll(void)
Clear all memory associated with groups and users.
Definition:
Mediator_Functions.c:18
Mediator_GetAllUsers
MediatorErrorCode Mediator_GetAllUsers(StringList *users)
Retrieve a list of all known users.
Definition:
Mediator_Functions.c:227
Mediator_RemoveUserFromGroup
MediatorErrorCode Mediator_RemoveUserFromGroup(const char *userName, const char *groupName)
Remove the specified user from the specified group.
Definition:
Mediator_Functions.c:154
MediatorErrorCode
MediatorErrorCode
Represents error codes that can be returned from the Mediator functions used in the Mediator Pattern.
Definition:
Mediator_Functions.h:18
MediatorErrorCode_Null_Argument
@ MediatorErrorCode_Null_Argument
One of the arguments was null or empty.
Definition:
Mediator_Functions.h:20
MediatorErrorCode_No_Memory
@ MediatorErrorCode_No_Memory
Indicates an out of memory condition.
Definition:
Mediator_Functions.h:23
MediatorErrorCode_Group_Does_Not_Exist
@ MediatorErrorCode_Group_Does_Not_Exist
The specified group does not exist.
Definition:
Mediator_Functions.h:22
MediatorErrorCode_No_Error
@ MediatorErrorCode_No_Error
No error occurred.
Definition:
Mediator_Functions.h:19
MediatorErrorCode_User_Does_Not_Exist
@ MediatorErrorCode_User_Does_Not_Exist
The specified user does not exist.
Definition:
Mediator_Functions.h:21
Mediator_AddUser
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,...
Definition:
Mediator_Functions.c:27
Mediator_AddUserToGroup
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,...
Definition:
Mediator_Functions.c:123
Mediator_RemoveUser
MediatorErrorCode Mediator_RemoveUser(const char *userName)
Removes the specified user from the list of known users, if the user exists. Also removes the user fr...
Definition:
Mediator_Functions.c:50
Mediator_GetUsersInGroup
MediatorErrorCode Mediator_GetUsersInGroup(const char *groupName, StringList *users)
Retrieve a list of users in the specified group.
Definition:
Mediator_Functions.c:264
Mediator_RemoveUserFromAllGroups
MediatorErrorCode Mediator_RemoveUserFromAllGroups(const char *userName)
Remove the specified user from all existing groups. The user still exists.
Definition:
Mediator_Functions.c:181
Mediator_RemoveGroup
MediatorErrorCode Mediator_RemoveGroup(const char *groupName)
Remove the specified group from the list of known groups if the group exists.
Definition:
Mediator_Functions.c:100
Mediator_GetGroupsWithUser
MediatorErrorCode Mediator_GetGroupsWithUser(const char *userName, StringList *groups)
Retrieve a list of all groups that contain the specified user.
Definition:
Mediator_Functions.c:287
StringList
std::vector< std::string > StringList
Typedef for a vector of std::string.
Definition:
lusplus/helpers/stringlist.h:16
c
Mediator_Functions.h
Generated on Tue Aug 29 2023 19:47:44 for Design Pattern Examples by
1.9.6