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
17typedef enum
18{
25
26
27//-----------------------------------------------------------------------------
28//-----------------------------------------------------------------------------
29
33void Mediator_ClearAll(void);
34
35
46MediatorErrorCode Mediator_AddUser(const char* userName);
47
58MediatorErrorCode Mediator_RemoveUser(const char* userName);
59
70MediatorErrorCode Mediator_AddGroup(const char* groupName);
71
82MediatorErrorCode Mediator_RemoveGroup(const char* groupName);
83
97MediatorErrorCode Mediator_AddUserToGroup(const char* userName, const char* groupName);
98
110MediatorErrorCode Mediator_RemoveUserFromGroup(const char* userName, const char* groupName);
111
122
133
144
151bool Mediator_IsUserInGroup(const char* userName, const char* groupName);
152
164MediatorErrorCode Mediator_GetUsersInGroup(const char* groupName, StringList* users);
165
177MediatorErrorCode Mediator_GetGroupsWithUser(const char* userName, StringList* groups);
178
179
180#endif // __MEDIATOR_FUNCTIONS_H__
MediatorErrorCode Mediator_GetAllGroups(StringList *groups)
Retrieve a list of all known groups.
bool Mediator_IsUserInGroup(const char *userName, const char *groupName)
Determine if the specified user is in the specified group.
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...
void Mediator_ClearAll(void)
Clear all memory associated with groups and users.
MediatorErrorCode Mediator_GetAllUsers(StringList *users)
Retrieve a list of all known users.
MediatorErrorCode Mediator_RemoveUserFromGroup(const char *userName, const char *groupName)
Remove the specified user from the specified group.
MediatorErrorCode
Represents error codes that can be returned from the Mediator functions used in the Mediator Pattern.
@ MediatorErrorCode_Null_Argument
One of the arguments was null or empty.
@ MediatorErrorCode_No_Memory
Indicates an out of memory condition.
@ MediatorErrorCode_Group_Does_Not_Exist
The specified group does not exist.
@ MediatorErrorCode_No_Error
No error occurred.
@ MediatorErrorCode_User_Does_Not_Exist
The specified user does not exist.
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,...
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,...
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...
MediatorErrorCode Mediator_GetUsersInGroup(const char *groupName, StringList *users)
Retrieve a list of users in the specified group.
MediatorErrorCode Mediator_RemoveUserFromAllGroups(const char *userName)
Remove the specified user from all existing groups. The user still exists.
MediatorErrorCode Mediator_RemoveGroup(const char *groupName)
Remove the specified group from the list of known groups if the group exists.
MediatorErrorCode Mediator_GetGroupsWithUser(const char *userName, StringList *groups)
Retrieve a list of all groups that contain the specified user.
std::vector< std::string > StringList
Typedef for a vector of std::string.