Design Pattern Examples
Overview of object-oriented design patterns
c/Mediator_Exercise.h File Reference

Declaration of the Mediator_Exercise() function as used in the Mediator Pattern. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define __MEDIATOR_EXERCISE_H__
 

Functions

void Mediator_Exercise (void)
 Example of using the Mediator Pattern.
 

Detailed Description

Declaration of the Mediator_Exercise() function as used in the Mediator Pattern.

Definition in file c/Mediator_Exercise.h.

Macro Definition Documentation

◆ __MEDIATOR_EXERCISE_H__

#define __MEDIATOR_EXERCISE_H__

Definition at line 9 of file c/Mediator_Exercise.h.

Function Documentation

◆ Mediator_Exercise()

void Mediator_Exercise ( void  )

Example of using the Mediator Pattern.

A mediator is instantiated then populated with users and groups. Users are added to some of the groups.

A series of operations are then performed through the Mediator. The output shows the results of each operation. Note that all operations are done using user and group names, with no knowledge of the actual lists of users and groups. The mediator hides all the details.

The odd design of this example is to more effectively accommodate error handling from the mediator. This is what you get if you don't have exceptions, like in C++.

Definition at line 577 of file Mediator_Exercise.c.

References _Mediator_Example_AddUserToGroup(), _Mediator_Example_RemoveUser(), _Mediator_Example_RemoveUserFromAllGroups(), _Mediator_Example_RemoveUserFromGroup(), _Mediator_Example_SeeIfUserInGroup(), _Mediator_Example_ShowAllGroups(), _Mediator_Example_ShowAllGroupsContainingUser(), _Mediator_Example_ShowAllUsers(), _Mediator_Example_ShowUsersInGroup(), Mediator_ClearAll(), Mediator_SetupGroups(), and Mediator_SetupUsers().