Design Pattern Examples
Overview of object-oriented design patterns
UserList Class Reference

Represents a list of users. More...

#include <Mediator_User_Classes.h>

Collaboration diagram for UserList:
Collaboration graph

Public Member Functions

StringList UserNames ()
 The user names contained in this list (read-only). The list is always sorted.
 
UserFindUser (std::string name)
 Retrieve the User instance for the specified user name. The found user may be altered so it must point to the one in the list.
 
void AddUser (std::string name)
 Add the specified user name as a user. Operation ignored if user is already in the list.
 
void RemoveUser (std::string name)
 Remove the specified user name as a user. Operation ignored if user is not in the list.
 

Private Member Functions

std::vector< User >::iterator _SearchForUser (const std::string &name)
 Get an iterator pointing to the user with the specified name. Returns std::end(_users) if the user was not found with that name.
 

Private Attributes

std::vector< User_users
 The list of users.
 

Detailed Description

Represents a list of users.

This is a simple implementation using a simple list. It is NOT thread-safe.

Definition at line 87 of file Mediator_User_Classes.h.

Member Function Documentation

◆ _SearchForUser()

std::vector< User >::iterator _SearchForUser ( const std::string &  name)
inlineprivate

Get an iterator pointing to the user with the specified name. Returns std::end(_users) if the user was not found with that name.

Definition at line 100 of file Mediator_User_Classes.h.

References UserList::_users, and User::Equals().

Referenced by UserList::FindUser(), and UserList::RemoveUser().

◆ AddUser()

void AddUser ( std::string  name)
inline

Add the specified user name as a user. Operation ignored if user is already in the list.

Parameters
nameName of user to add. Cannot be null or empty.
Exceptions
ArgumentNullExceptionThe 'name' parameter is null or empty.

Definition at line 152 of file Mediator_User_Classes.h.

References UserList::_users, and UserList::FindUser().

Referenced by UserGroupMediator::AddUser().

◆ FindUser()

User * FindUser ( std::string  name)
inline

Retrieve the User instance for the specified user name. The found user may be altered so it must point to the one in the list.

Parameters
nameUser name to search for.
Returns
Returns a User object if name found.

Definition at line 133 of file Mediator_User_Classes.h.

References UserList::_SearchForUser(), and UserList::_users.

Referenced by UserList::AddUser(), UserGroupMediator::AddUserToGroup(), UserGroupMediator::GetGroupsWithUser(), UserGroupMediator::IsUserInGroup(), UserGroupMediator::RemoveUserFromAllGroups(), and UserGroupMediator::RemoveUserFromGroup().

◆ RemoveUser()

void RemoveUser ( std::string  name)
inline

Remove the specified user name as a user. Operation ignored if user is not in the list.

Parameters
nameName of user to remove.

Definition at line 172 of file Mediator_User_Classes.h.

References UserList::_SearchForUser(), and UserList::_users.

Referenced by UserGroupMediator::RemoveUser().

◆ UserNames()

StringList UserNames ( )
inline

The user names contained in this list (read-only). The list is always sorted.

Definition at line 115 of file Mediator_User_Classes.h.

References UserList::_users.

Referenced by UserGroupMediator::GetAllUsers().

Member Data Documentation

◆ _users


The documentation for this class was generated from the following file: