Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Examples  

examp19.cpp

This example is to show use of the Mediator and Memento patterns. We create three (3) Colleagues:

ListColleague - Maintains a list of sentences that the user can edit SelectColleague - Sets up the select of the sentence to edit EditColleague - Provides editing for a sentence

When something occurs in a Colleague, it captures the state in a Memento which is made part of the Event. The Colleague then calls the Mediator action interface with the event.

The flow of traffic is:

A) ListColleague updates the list and calls the mediator with a memento that contains the current list --> B

B) SelectColleague is interested in list changes, so it receives an event with the current list.

C) The ListMediator invokes SelectColleague to do it's thing, which is to display the list and allow for a selection. When a valid selection is received, it calls the mediator with a memento containing the text of the selection ---> D

D) The EditColleague receives the event and displays the selected string with a edit prompt. It calls the mediator with a memento that contains the original string, and the replacement string ---> E

E) The ListColleague receives the event and updates it list and A then C.


This is the CoreLinux++ reference manual
Provided by The CoreLinux Consortium