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

Represents a list of Groups. More...

#include <Mediator_Group_Classes.h>

Collaboration diagram for GroupList:
Collaboration graph

Public Member Functions

StringList GroupNames ()
 The names of all groups contained in this list (read-only). The list is always sorted.
 
GroupFindGroup (std::string name)
 Retrieve the Group instance for the specified group name. The found group may be altered so it must point to the one in the list.
 
void AddGroup (std::string name)
 Add a group to the list using the given group name. Operation ignored if the group is already in the list.
 
void RemoveGroup (std::string name)
 Remove the specified group from the list. Operation ignored if the group is not in the list.
 

Private Member Functions

std::vector< Group >::iterator _SearchForGroup (const std::string &name)
 Get an iterator pointing to the group with the specified name. Returns std::end(_groups) if the group was not found with that name.
 

Private Attributes

std::vector< Group_groups
 The list of groups.
 

Detailed Description

Represents a list of Groups.

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

Definition at line 159 of file Mediator_Group_Classes.h.

Member Function Documentation

◆ _SearchForGroup()

std::vector< Group >::iterator _SearchForGroup ( const std::string &  name)
inlineprivate

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

Definition at line 172 of file Mediator_Group_Classes.h.

References GroupList::_groups, and Group::Equals().

Referenced by GroupList::FindGroup(), and GroupList::RemoveGroup().

◆ AddGroup()

void AddGroup ( std::string  name)
inline

Add a group to the list using the given group name. Operation ignored if the group is already in the list.

Parameters
nameName of the group to add. Cannot be null or empty.
Exceptions
ArgumentNullExceptionThe group name cannot be null or empty.

Definition at line 229 of file Mediator_Group_Classes.h.

References GroupList::_groups, and GroupList::FindGroup().

Referenced by UserGroupMediator::AddGroup().

◆ FindGroup()

Group * FindGroup ( std::string  name)
inline

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

Parameters
nameGroup name to search for.

<returns">Returns pointer to a Group object if name found. Returns null if not found.

Definition at line 211 of file Mediator_Group_Classes.h.

References GroupList::_groups, and GroupList::_SearchForGroup().

Referenced by GroupList::AddGroup(), UserGroupMediator::AddUserToGroup(), UserGroupMediator::GetGroupsWithUser(), UserGroupMediator::GetUsersInGroup(), UserGroupMediator::IsUserInGroup(), UserGroupMediator::RemoveUserFromAllGroups(), and UserGroupMediator::RemoveUserFromGroup().

◆ GroupNames()

StringList GroupNames ( )
inline

The names of all groups contained in this list (read-only). The list is always sorted.

Definition at line 187 of file Mediator_Group_Classes.h.

References GroupList::_groups, and Helpers::stricmp().

Referenced by UserGroupMediator::GetAllGroups(), UserGroupMediator::GetGroupsWithUser(), and UserGroupMediator::RemoveUserFromAllGroups().

◆ RemoveGroup()

void RemoveGroup ( std::string  name)
inline

Remove the specified group from the list. Operation ignored if the group is not in the list.

Parameters
nameName of the group to remove.

Definition at line 248 of file Mediator_Group_Classes.h.

References GroupList::_groups, and GroupList::_SearchForGroup().

Referenced by UserGroupMediator::RemoveGroup().

Member Data Documentation

◆ _groups

std::vector<Group> _groups
private

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