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

examp8.cpp

This example is to show use of the Facade pattern, our Facade (ObjectModel) is the application interface to the following:

Dictionary(D) - maintains a collection of names for objects in the system. Names can be added and deleted from the Dictionary but there can be no collisions. The following methods are used:

addName(string); changeName( string, string ); removeName( string ); getIdentifierForName( string ); getNameForIdentifier( Identifier );

Factory(F) - creates and destroys objects. If the object being asked for create is already in existence, it returns that instance.

createObject( Identifier ); destroyObject( Identifier );

Modeler(M) - manages links between parents and children

addParent( Identifier, Identifier ); removeParent( Identifier, Identifier ); getParents( Identifier );

With the above, ObjectModel is all the user needs to create and maintain a hierarchy of objects.

createObject("name"); // Uses D F, and M

destroyObject("name"); // Uses D, F, and M

changeName("oldname","newname"); // Uses D

addParent("childname","parentname"); // Uses D, F, and M

removeParent("childname","parentname");// Uses D, F, and M

display("name"); // Uses D, F, and M

Objects that are created have a parent ("Root") automatically assigned to them. This parent stays with them regardless of other relationships.

For your own experimentation, you can change the semantics around but keep in mind they can get a little hairy, for example:

1. Is it a cylical or acylical? 2. Is it multi-inheritence or single? 3. What is visibility?


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