Represents the mediator between caller, users, and groups. All users and groups are identified by string name. The names are case-sensitive. More...
#include <Mediator_Class.h>
Public Member Functions | |
void | AddUser (std::string name) |
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. | |
void | RemoveUser (std::string name) |
Removes the specified user from the list of known users, if the user exists. Also removes the user from all groups. | |
void | AddGroup (std::string name) |
Add a group to the list of known groups. If the group is already in the list, the request to add is ignored. | |
void | RemoveGroup (std::string name) |
Remove the specified group from the list of known groups if the group exists. | |
void | AddUserToGroup (std::string userName, std::string groupName) |
Add the specified user to the specified group. If the user is already in the group, do nothing. The user must exist. | |
void | RemoveUserFromGroup (std::string userName, std::string groupName) |
Remove the specified user from the specified group. | |
void | RemoveUserFromAllGroups (std::string userName) |
Remove the specified user from all existing groups. | |
bool | IsUserInGroup (std::string userName, std::string groupName) |
Determine if the specified user is in the specified group. | |
StringList | GetGroupsWithUser (std::string userName) |
Retrieve a list of all groups that contain the specified user. | |
StringList | GetUsersInGroup (std::string groupName) |
Retrieve a list of users in the specified group. | |
StringList | GetAllGroups () |
Retrieve a list of all known groups. | |
StringList | GetAllUsers () |
Retrieve a list of all known users. | |
Private Attributes | |
UserGroupsContainer | _userGroupsContainer |
Represents the mediator between caller, users, and groups. All users and groups are identified by string name. The names are case-sensitive.
Definition at line 45 of file Mediator_Class.h.
|
inline |
Add a group to the list of known groups. If the group is already in the list, the request to add is ignored.
ArgumentNullException | The 'name' parameter cannot be null or empty. |
name | Name of the user to add. Must not be null or empty. |
Definition at line 83 of file Mediator_Class.h.
References UserGroupMediator::_userGroupsContainer, GroupList::AddGroup(), and UserGroupsContainer::Groups.
|
inline |
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.
name | Name of the user to add. Must not be null or empty. |
ArgumentNullException | The 'name' parameter cannot be null or empty. |
Definition at line 59 of file Mediator_Class.h.
References UserGroupMediator::_userGroupsContainer, UserList::AddUser(), and UserGroupsContainer::Users.
|
inline |
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. |
ArgumentException | User or group does not exist. |
Definition at line 107 of file Mediator_Class.h.
References UserGroupMediator::_userGroupsContainer, Group::AddUser(), GroupList::FindGroup(), UserList::FindUser(), Helpers::formatstring(), UserGroupsContainer::Groups, and UserGroupsContainer::Users.
Referenced by DesignPatternExamples_cpp::Mediator_Exercise().
|
inline |
Retrieve a list of all known groups.
Definition at line 280 of file Mediator_Class.h.
References UserGroupMediator::_userGroupsContainer, GroupList::GroupNames(), and UserGroupsContainer::Groups.
Referenced by DesignPatternExamples_cpp::Mediator_Exercise().
|
inline |
Retrieve a list of all known users.
Definition at line 290 of file Mediator_Class.h.
References UserGroupMediator::_userGroupsContainer, UserList::UserNames(), and UserGroupsContainer::Users.
Referenced by DesignPatternExamples_cpp::Mediator_Exercise().
|
inline |
Retrieve a list of all groups that contain the specified user.
userName | Name of the user to look for. Must be an existing user. |
ArgumentException | User or group does not exist. |
Definition at line 231 of file Mediator_Class.h.
References UserGroupMediator::_userGroupsContainer, Group::ContainsUser(), GroupList::FindGroup(), UserList::FindUser(), Helpers::formatstring(), GroupList::GroupNames(), UserGroupsContainer::Groups, and UserGroupsContainer::Users.
Referenced by DesignPatternExamples_cpp::Mediator_Exercise().
|
inline |
Retrieve a list of users in the specified group.
groupName | Name of the group to examine. Must be an existing group. |
ArgumentException | Group does not exist. |
Definition at line 263 of file Mediator_Class.h.
References UserGroupMediator::_userGroupsContainer, GroupList::FindGroup(), Helpers::formatstring(), UserGroupsContainer::Groups, and Group::Users().
Referenced by DesignPatternExamples_cpp::Mediator_Exercise().
|
inline |
Determine if the specified user is in the specified group.
userName | Name of user to find. Must be an existing user. |
groupName | Name of group to look in. Must be an existing group. |
ArgumentException | User or group does not exist. |
Definition at line 199 of file Mediator_Class.h.
References UserGroupMediator::_userGroupsContainer, Group::ContainsUser(), GroupList::FindGroup(), UserList::FindUser(), Helpers::formatstring(), UserGroupsContainer::Groups, and UserGroupsContainer::Users.
Referenced by DesignPatternExamples_cpp::Mediator_Exercise().
|
inline |
Remove the specified group from the list of known groups if the group exists.
name | Name of group to remove. |
Definition at line 94 of file Mediator_Class.h.
References UserGroupMediator::_userGroupsContainer, UserGroupsContainer::Groups, and GroupList::RemoveGroup().
|
inline |
Removes the specified user from the list of known users, if the user exists. Also removes the user from all groups.
name | Name of user to remove. |
Definition at line 70 of file Mediator_Class.h.
References UserGroupMediator::_userGroupsContainer, UserList::RemoveUser(), UserGroupMediator::RemoveUserFromAllGroups(), and UserGroupsContainer::Users.
Referenced by DesignPatternExamples_cpp::Mediator_Exercise().
|
inline |
Remove the specified user from all existing groups.
userName | Name of user to remove. Must be an existing user. |
ArgumentException | User does not exist. |
Definition at line 166 of file Mediator_Class.h.
References UserGroupMediator::_userGroupsContainer, Group::ContainsUser(), GroupList::FindGroup(), UserList::FindUser(), Helpers::formatstring(), GroupList::GroupNames(), UserGroupsContainer::Groups, Group::RemoveUser(), and UserGroupsContainer::Users.
Referenced by DesignPatternExamples_cpp::Mediator_Exercise(), and UserGroupMediator::RemoveUser().
|
inline |
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. |
ArgumentException | User or group does not exist. |
Definition at line 137 of file Mediator_Class.h.
References UserGroupMediator::_userGroupsContainer, GroupList::FindGroup(), UserList::FindUser(), Helpers::formatstring(), UserGroupsContainer::Groups, Group::RemoveUser(), and UserGroupsContainer::Users.
Referenced by DesignPatternExamples_cpp::Mediator_Exercise().
|
private |
Definition at line 50 of file Mediator_Class.h.
Referenced by UserGroupMediator::AddGroup(), UserGroupMediator::AddUser(), UserGroupMediator::AddUserToGroup(), UserGroupMediator::GetAllGroups(), UserGroupMediator::GetAllUsers(), UserGroupMediator::GetGroupsWithUser(), UserGroupMediator::GetUsersInGroup(), UserGroupMediator::IsUserInGroup(), UserGroupMediator::RemoveGroup(), UserGroupMediator::RemoveUser(), UserGroupMediator::RemoveUserFromAllGroups(), and UserGroupMediator::RemoveUserFromGroup().