Skip to content
This repository has been archived by the owner on Mar 4, 2021. It is now read-only.
/ et-plus-plus Public archive

ET++ is used to study the Design Patterns book of GOF

Notifications You must be signed in to change notification settings

binshengliu/et-plus-plus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Patterns introduced in Design Patterns

ET++ is referenced in Abstract Factory (p97), Builder, Factory Method, Prototype, Adapter, Bridge (p151), Composite, Decorator, Facade, Flyweight, Chain of Responsibility, Command, Iterator, Mediator, Observer, and Strategy in Design Patterns (ISBN-13: 9787111095071).

Abstract Factory

Factories:

  • WindowSystem (abstract)

    • NeWSWindowSystem

    • ServerWindowSystem

    • SunWindowSystem

    • XWindowSystem

Products:

  • WindowPort (abstract)

    • NeWSWindowPort

    • ServerPort

    • SunWindowPort

    • XWindowPort

  • FontManager (abstract)

    • NeWSFontManager

    • ServerFontManager

    • SunFontManager

    • XFontManager

  • DevBitmap (abstract)

    • SunBitmap

    • XBitmap

  • ClipBoard (abstract)

    • SunClipBoard

    • XClipBoard

How does et++ decide which concrete factory to use?

In InitWindowSystem, it uses macros to choose the concrete factory.

WindowSystem    *gWindowSystem= 0;

void InitWindowSystem()
{
    // ...

#ifdef WS_SUNSERVER
    if (gWindowSystem == 0)
	gWindowSystem= NewServerWindowSystem(); // try to connect to SunWindow server
#endif WS_SUNSERVER

#ifdef WS_X
    if (gWindowSystem == 0)
	gWindowSystem= NewXWindowSystem();      // try to connect to X server
#endif WS_X

#ifdef WS_NEWS
    if (gWindowSystem == 0)
	gWindowSystem= NewNeWSWindowSystem();   // try to connect to NeWS server
#endif WS_NEWS
    
#ifdef WS_SUNWINDOW
    if (gWindowSystem == 0)
	gWindowSystem= NewSunWindowSystem();    // try SunWindow System
#endif WS_SUNWINDOW
    
    // ...
}

Bridge

  • BlankWin (Abstraction)

    • Window (Refined Abstraction)

    • Icon (Refined Abstraction)

  • WindowPort (Implementor)

    • NeWSWindowPort (Concrete Implementor)

    • ServerPort (Concrete Implementor)

    • SunWindowPort (Concrete Implementor)

    • XWindowPort (Concrete Implementor)

This pattern is combined with Abstract Factory to make a concrete WindowPort object.

class WindowPort *BlankWin::MakePort()
{
    if (portDesc == 0) {
        portDesc= gWindowSystem->MakeWindow((InpHandlerFun) &BlankWin::input, this,
                        TestFlag(eBWinOverlay), TestFlag(eBWinBlock), FALSE);
        portDesc->cursor= cursor;
    }
    return portDesc;
}

About

ET++ is used to study the Design Patterns book of GOF

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published