Showing preview only (580K chars total). Download the full file or copy to clipboard to get everything.
Repository: me115/design_patterns
Branch: master
Commit: 0cbd7856a83d
Files: 320
Total size: 526.4 KB
Directory structure:
gitextract_qiu8ox4r/
├── .gitattributes
├── .gitignore
├── LICENSE
├── Makefile
├── behavioral_patterns/
│ ├── behavioral.rst
│ ├── command.rst
│ ├── mediator.rst
│ ├── observer.rst
│ ├── state.rst
│ └── strategy.rst
├── code/
│ ├── AbstractFactory/
│ │ ├── AbstractFactory.cpp
│ │ ├── AbstractFactory.h
│ │ ├── AbstractProductA.cpp
│ │ ├── AbstractProductA.h
│ │ ├── AbstractProductB.cpp
│ │ ├── AbstractProductB.h
│ │ ├── ConcreteFactory1.cpp
│ │ ├── ConcreteFactory1.h
│ │ ├── ConcreteFactory2.cpp
│ │ ├── ConcreteFactory2.h
│ │ ├── ProductA1.cpp
│ │ ├── ProductA1.h
│ │ ├── ProductA2.cpp
│ │ ├── ProductA2.h
│ │ ├── ProductB1.cpp
│ │ ├── ProductB1.h
│ │ ├── ProductB2.cpp
│ │ ├── ProductB2.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── AbstractFactory.o
│ │ ├── AbstractProductA.o
│ │ ├── AbstractProductB.o
│ │ ├── ConcreteFactory1.o
│ │ ├── ConcreteFactory2.o
│ │ ├── ProductA1.o
│ │ ├── ProductA2.o
│ │ ├── ProductB1.o
│ │ ├── ProductB2.o
│ │ └── main.o
│ ├── Adapter/
│ │ ├── Adaptee.cpp
│ │ ├── Adaptee.h
│ │ ├── Adapter.cpp
│ │ ├── Adapter.h
│ │ ├── Client.cpp
│ │ ├── Client.h
│ │ ├── Target.cpp
│ │ ├── Target.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── Adaptee.o
│ │ ├── Adapter.o
│ │ ├── Target.o
│ │ └── main.o
│ ├── Bridge/
│ │ ├── Abstraction.cpp
│ │ ├── Abstraction.h
│ │ ├── ConcreteImplementorA.cpp
│ │ ├── ConcreteImplementorA.h
│ │ ├── ConcreteImplementorB.cpp
│ │ ├── ConcreteImplementorB.h
│ │ ├── Implementor.cpp
│ │ ├── Implementor.h
│ │ ├── RefinedAbstraction.cpp
│ │ ├── RefinedAbstraction.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── Abstraction.o
│ │ ├── ConcreteImplementorA.o
│ │ ├── ConcreteImplementorB.o
│ │ ├── Implementor.o
│ │ ├── RefinedAbstraction.o
│ │ └── main.o
│ ├── Builder/
│ │ ├── Builder.cpp
│ │ ├── Builder.h
│ │ ├── ConcreteBuilder.cpp
│ │ ├── ConcreteBuilder.h
│ │ ├── Director.cpp
│ │ ├── Director.h
│ │ ├── Product.cpp
│ │ ├── Product.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── Builder.o
│ │ ├── ConcreteBuilder.o
│ │ ├── Director.o
│ │ ├── Product.o
│ │ └── main.o
│ ├── Command/
│ │ ├── Command.cpp
│ │ ├── Command.h
│ │ ├── ConcreteCommand.cpp
│ │ ├── ConcreteCommand.h
│ │ ├── Invoker.cpp
│ │ ├── Invoker.h
│ │ ├── Receiver.cpp
│ │ ├── Receiver.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── Command.o
│ │ ├── ConcreteCommand.o
│ │ ├── Invoker.o
│ │ ├── Receiver.o
│ │ └── main.o
│ ├── Decorator/
│ │ ├── Component.cpp
│ │ ├── Component.h
│ │ ├── ConcreteComponent.cpp
│ │ ├── ConcreteComponent.h
│ │ ├── ConcreteDecoratorA.cpp
│ │ ├── ConcreteDecoratorA.h
│ │ ├── ConcreteDecoratorB.cpp
│ │ ├── ConcreteDecoratorB.h
│ │ ├── Decorator.cpp
│ │ ├── Decorator.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── Component.o
│ │ ├── ConcreteComponent.o
│ │ ├── ConcreteDecoratorA.o
│ │ ├── ConcreteDecoratorB.o
│ │ ├── Decorator.o
│ │ └── main.o
│ ├── Facade/
│ │ ├── Client.cpp
│ │ ├── Client.h
│ │ ├── Facade.cpp
│ │ ├── Facade.h
│ │ ├── SystemA.cpp
│ │ ├── SystemA.h
│ │ ├── SystemB.cpp
│ │ ├── SystemB.h
│ │ ├── SystemC.cpp
│ │ ├── SystemC.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── Facade.o
│ │ ├── SystemA.o
│ │ ├── SystemB.o
│ │ ├── SystemC.o
│ │ └── main.o
│ ├── FactoryMethod/
│ │ ├── Client.cpp
│ │ ├── Client.h
│ │ ├── ConcreteFactory.cpp
│ │ ├── ConcreteFactory.h
│ │ ├── ConcreteProduct.cpp
│ │ ├── ConcreteProduct.h
│ │ ├── Factory.cpp
│ │ ├── Factory.h
│ │ ├── Product.cpp
│ │ ├── Product.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── Client.o
│ │ ├── ConcreteFactory.o
│ │ ├── ConcreteProduct.o
│ │ ├── Factory.o
│ │ ├── Product.o
│ │ └── main.o
│ ├── Flyweight/
│ │ ├── ConcreteFlyweight.cpp
│ │ ├── ConcreteFlyweight.h
│ │ ├── Flyweight.cpp
│ │ ├── Flyweight.h
│ │ ├── FlyweightFactory.cpp
│ │ ├── FlyweightFactory.h
│ │ ├── UnsharedConcreteFlyweight.cpp
│ │ ├── UnsharedConcreteFlyweight.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── ConcreteFlyweight.o
│ │ ├── Flyweight.o
│ │ ├── FlyweightFactory.o
│ │ └── main.o
│ ├── Mediator/
│ │ ├── Colleague.cpp
│ │ ├── Colleague.h
│ │ ├── ConcreteColleagueA.cpp
│ │ ├── ConcreteColleagueA.h
│ │ ├── ConcreteColleagueB.cpp
│ │ ├── ConcreteColleagueB.h
│ │ ├── ConcreteMediator.cpp
│ │ ├── ConcreteMediator.h
│ │ ├── Mediator.cpp
│ │ ├── Mediator.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── Colleague.o
│ │ ├── ConcreteColleagueA.o
│ │ ├── ConcreteColleagueB.o
│ │ ├── ConcreteMediator.o
│ │ ├── Mediator.o
│ │ └── main.o
│ ├── Obeserver/
│ │ ├── ConcreteObeserver.cpp
│ │ ├── ConcreteObeserver.h
│ │ ├── ConcreteSubject.cpp
│ │ ├── ConcreteSubject.h
│ │ ├── Obeserver.cpp
│ │ ├── Obeserver.h
│ │ ├── Subject.cpp
│ │ ├── Subject.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── ConcreteObeserver.o
│ │ ├── ConcreteSubject.o
│ │ ├── Obeserver.o
│ │ ├── Subject.o
│ │ └── main.o
│ ├── Proxy/
│ │ ├── Proxy.cpp
│ │ ├── Proxy.h
│ │ ├── RealSubject.cpp
│ │ ├── RealSubject.h
│ │ ├── Subject.cpp
│ │ ├── Subject.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── Proxy.o
│ │ ├── RealSubject.o
│ │ ├── Subject.o
│ │ └── main.o
│ ├── SimpleFactory/
│ │ ├── ConcreteProductA.cpp
│ │ ├── ConcreteProductA.h
│ │ ├── ConcreteProductB.cpp
│ │ ├── ConcreteProductB.h
│ │ ├── Factory.cpp
│ │ ├── Factory.h
│ │ ├── Product.cpp
│ │ ├── Product.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── ConcreteProductA.o
│ │ ├── ConcreteProductB.o
│ │ ├── Factory.o
│ │ ├── Product.o
│ │ └── main.o
│ ├── Singleton/
│ │ ├── Singleton.cpp
│ │ ├── Singleton.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── Singleton.o
│ │ └── main.o
│ ├── State/
│ │ ├── ConcreteStateA.cpp
│ │ ├── ConcreteStateA.h
│ │ ├── ConcreteStateB.cpp
│ │ ├── ConcreteStateB.h
│ │ ├── Context.cpp
│ │ ├── Context.h
│ │ ├── State.cpp
│ │ ├── State.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── ConcreteStateA.o
│ │ ├── ConcreteStateB.o
│ │ ├── Context.o
│ │ ├── State.o
│ │ └── main.o
│ ├── Strategy/
│ │ ├── ConcreteStrategyA.cpp
│ │ ├── ConcreteStrategyA.h
│ │ ├── ConcreteStrategyB.cpp
│ │ ├── ConcreteStrategyB.h
│ │ ├── Context.cpp
│ │ ├── Context.h
│ │ ├── Strategy.cpp
│ │ ├── Strategy.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ ├── main.o
│ │ └── mingw5/
│ │ ├── ConcreteStrategyA.o
│ │ ├── ConcreteStrategyB.o
│ │ ├── Context.o
│ │ ├── Strategy.o
│ │ └── main.o
│ └── main/
│ ├── main.cfp
│ ├── main.cfpg
│ └── main.cpp
├── conf.py
├── creational_patterns/
│ ├── abstract_factory.rst
│ ├── builder.rst
│ ├── creational.rst
│ ├── factory_method.rst
│ ├── simple_factory.rst
│ └── singleton.rst
├── design_patterns.EAP
├── dp_tmp.txt
├── index.rst
├── make.bat
├── read_uml.rst
├── readme.rst
├── sphinx_rtd_theme/
│ ├── __init__.py
│ ├── breadcrumbs.html
│ ├── footer.html
│ ├── layout.html
│ ├── layout_old.html
│ ├── search.html
│ ├── searchbox.html
│ ├── static/
│ │ ├── css/
│ │ │ ├── badge_only.css
│ │ │ ├── font_lato_googleapi.css
│ │ │ └── theme.css
│ │ ├── fonts/
│ │ │ └── FontAwesome.otf
│ │ └── js/
│ │ └── theme.js
│ ├── theme.conf
│ └── versions.html
├── state_diagram.vsd
└── structural_patterns/
├── adapter.rst
├── bridge.rst
├── decorator.rst
├── facade.rst
├── flyweight.rst
├── proxy.rst
└── structural.rst
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
================================================
FILE: .gitignore
================================================
#################
## Eclipse
#################
_build/
*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
#################
## Visual Studio
#################
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.Publish.xml
*.pubxml
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
App_Data/*.mdf
App_Data/*.ldf
#############
## Windows detritus
#############
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mac crap
.DS_Store
#############
## Python
#############
*.py[co]
# Packages
*.egg
*.egg-info
dist/
build/
eggs/
parts/
var/
sdist/
develop-eggs/
.installed.cfg
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
#Translations
*.mo
#Mr Developer
.mr.developer.cfg
================================================
FILE: LICENSE
================================================
版权说明
=====================
本书所有源代码及图片可自由分享,包括用于商业用途;
由于部分章节内容使用到刘伟的课件《java设计模式》(互联网分享),所以本书
文字内容不可用于商业目的(可在互联网自由分享);
本书内容转载请注明出处;
参考:
--------------------
《Java设计模式》PPT , 刘伟
================================================
FILE: Makefile
================================================
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
# User-friendly check for sphinx-build
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
endif
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " xml to make Docutils-native XML files"
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
clean:
rm -rf $(BUILDDIR)/*
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/redis.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/redis.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/redis"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/redis"
@echo "# devhelp"
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
latexpdfja:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through platex and dvipdfmx..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."
info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
xml:
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
@echo
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
================================================
FILE: behavioral_patterns/behavioral.rst
================================================
.. _behavioral:
行为型模式
====================
行为型模式(Behavioral Pattern)是对在不同的对象之间划分责任和算法的抽象化。
行为型模式不仅仅关注类和对象的结构,而且重点关注它们之间的相互作用。
通过行为型模式,可以更加清晰地划分类与对象的职责,并研究系统在运行时实例对象
之间的交互。在系统运行时,对象并不是孤立的,它们可以通过相互通信与协作完成某些复杂功能,一个对象在运行时也将影响到其他对象的运行。
行为型模式分为类行为型模式和对象行为型模式两种:
- 类行为型模式:类的行为型模式使用继承关系在几个类之间分配行为,类行为型模式主要通过多态等方式来分配父类与子类的职责。
- 对象行为型模式:对象的行为型模式则使用对象的聚合关联关系来分配行为,对象行为型模式主要是通过对象关联等方式来分配两个或多个类的职责。根据“合成复用原则”,系统中要尽量使用关联关系来取代继承关系,因此大部分行为型设计模式都属于对象行为型设计模式。
**包含模式**
- 职责链模式(Chain of Responsibility)
重要程度:3
- 命令模式(Command)
重要程度:4
- 解释器模式(Interpreter)
重要程度:1
- 迭代器模式(Iterator)
重要程度:5
- 中介者模式(Mediator)
重要程度:2
- 备忘录模式(Memento)
重要程度:2
- 观察者模式(Observer)
重要程度:5
- 状态模式(State)
重要程度:3
- 策略模式(Strategy)
重要程度:4
- 模板方法模式(Template Method)
重要程度:3
- 访问者模式(Visitor)
重要程度:1
**目录**
.. toctree::
:maxdepth: 2
:numbered: 2
command
mediator
observer
state
strategy
================================================
FILE: behavioral_patterns/command.rst
================================================
.. _command:
命令模式
====================
.. contents:: 目录
模式动机
--------------------
在软件设计中,我们经常需要向某些对象发送请求,但是并不知道请求的接收者是谁,也不知道被请求的操作是哪个,我们只需在程序运行时指定具体的请求接收者即可,此时,可以使用命令模式来进行设计,使得请求发送者与请求接收者消除彼此之间的耦合,让对象之间的调用关系更加灵活。
命令模式可以对发送者和接收者完全解耦,发送者与接收者之间没有直接引用关系,发送请求的对象只需要知道如何发送请求,而不必知道如何完成请求。这就是命令模式的模式动机。
模式定义
--------------------
命令模式(Command Pattern):将一个请求封装为一个对象,从而使我们可用不同的请求对客户进行参数化;对请求排队或者记录请求日志,以及支持可撤销的操作。命令模式是一种对象行为型模式,其别名为动作(Action)模式或事务(Transaction)模式。
模式结构
--------------------
命令模式包含如下角色:
- Command: 抽象命令类
- ConcreteCommand: 具体命令类
- Invoker: 调用者
- Receiver: 接收者
- Client:客户类
.. image:: /_static/Command.jpg
时序图
--------------------
.. image:: /_static/seq_Command.jpg
代码分析
--------------------
.. literalinclude:: /code/Command/main.cpp
:language: cpp
:linenos:
:lines: 1-
:emphasize-lines: 10-13
.. literalinclude:: /code/Command/Receiver.h
:language: cpp
:linenos:
:lines: 1-
.. literalinclude:: /code/Command/Receiver.cpp
:language: cpp
:linenos:
:lines: 1-
.. literalinclude:: /code/Command/ConcreteCommand.h
:language: cpp
:linenos:
:lines: 1-
:emphasize-lines: 22
.. literalinclude:: /code/Command/ConcreteCommand.cpp
:language: cpp
:linenos:
:lines: 1-
:emphasize-lines: 23-26
.. literalinclude:: /code/Command/Invoker.h
:language: cpp
:linenos:
:lines: 1-
:emphasize-lines: 17-23
.. literalinclude:: /code/Command/Invoker.cpp
:language: cpp
:linenos:
:lines: 1-
:emphasize-lines: 20-23
运行结果:
.. image:: /_static/Command_run.jpg
模式分析
--------------------
命令模式的本质是对命令进行封装,将发出命令的责任和执行命令的责任分割开。
- 每一个命令都是一个操作:请求的一方发出请求,要求执行一个操作;接收的一方收到请求,并执行操作。
- 命令模式允许请求的一方和接收的一方独立开来,使得请求的一方不必知道接收请求的一方的接口,更不必知道请求是怎么被接收,以及操作是否被执行、何时被执行,以及是怎么被执行的。
- 命令模式使请求本身成为一个对象,这个对象和其他对象一样可以被存储和传递。
- 命令模式的关键在于引入了抽象命令接口,且发送者针对抽象命令接口编程,只有实现了抽象命令接口的具体命令才能与接收者相关联。
实例
--------------------
实例一:电视机遥控器
- 电视机是请求的接收者,遥控器是请求的发送者,遥控器上有一些按钮,不同的按钮对应电视机的不同操作。抽象命令角色由一个命令接口来扮演,有三个具体的命令类实现了抽象命令接口,这三个具体命令类分别代表三种操作:打开电视机、关闭电视机和切换频道。显然,电视机遥控器就是一个典型的命令模式应用实例。
.. image:: /_static/Command_eg.jpg
时序图:
.. image:: /_static/seq_Command_eg.jpg
优点
--------------------
命令模式的优点
- 降低系统的耦合度。
- 新的命令可以很容易地加入到系统中。
- 可以比较容易地设计一个命令队列和宏命令(组合命令)。
- 可以方便地实现对请求的Undo和Redo。
缺点
--------------------
命令模式的缺点
- 使用命令模式可能会导致某些系统有过多的具体命令类。因为针对每一个命令都需要设计一个具体命令类,因此某些系统可能需要大量具体命令类,这将影响命令模式的使用。
适用环境
--------------------
在以下情况下可以使用命令模式:
- 系统需要将请求调用者和请求接收者解耦,使得调用者和接收者不直接交互。
- 系统需要在不同的时间指定请求、将请求排队和执行请求。
- 系统需要支持命令的撤销(Undo)操作和恢复(Redo)操作。
- 系统需要将一组操作组合在一起,即支持宏命令
模式应用
--------------------
很多系统都提供了宏命令功能,如UNIX平台下的Shell编程,可以将多条命令封装在一个命令对象中,只需要一条简单的命令即可执行一个命令序列,这也是命令模式的应用实例之一。
模式扩展
--------------------
宏命令又称为组合命令,它是命令模式和组合模式联用的产物。
-宏命令也是一个具体命令,不过它包含了对其他命令对象的引用,在调用宏命令的execute()方法时,将递归调用它所包含的每个成员命令的execute()方法,一个宏命令的成员对象可以是简单命令,还可以继续是宏命令。执行一个宏命令将执行多个具体命令,从而实现对命令的批处理。
总结
--------------------
- 在命令模式中,将一个请求封装为一个对象,从而使我们可用不同的请求对客户进行参数化;对请求排队或者记录请求日志,以及支持可撤销的操作。命令模式是一种对象行为型模式,其别名为动作模式或事务模式。
- 命令模式包含四个角色:抽象命令类中声明了用于执行请求的execute()等方法,通过这些方法可以调用请求接收者的相关操作;具体命令类是抽象命令类的子类,实现了在抽象命令类中声明的方法,它对应具体的接收者对象,将接收者对象的动作绑定其中;调用者即请求的发送者,又称为请求者,它通过命令对象来执行请求;接收者执行与请求相关的操作,它具体实现对请求的业务处理。
- 命令模式的本质是对命令进行封装,将发出命令的责任和执行命令的责任分割开。命令模式使请求本身成为一个对象,这个对象和其他对象一样可以被存储和传递。
- 命令模式的主要优点在于降低系统的耦合度,增加新的命令很方便,而且可以比较容易地设计一个命令队列和宏命令,并方便地实现对请求的撤销和恢复;其主要缺点在于可能会导致某些系统有过多的具体命令类。
- 命令模式适用情况包括:需要将请求调用者和请求接收者解耦,使得调用者和接收者不直接交互;需要在不同的时间指定请求、将请求排队和执行请求;需要支持命令的撤销操作和恢复操作,需要将一组操作组合在一起,即支持宏命令。
================================================
FILE: behavioral_patterns/mediator.rst
================================================
.. _mediator:
中介者模式
====================
.. contents:: 目录
模式动机
--------------------
- 在用户与用户直接聊天的设计方案中,用户对象之间存在很强的关联性,将导致系统出现如下问题:
- 系统结构复杂:对象之间存在大量的相互关联和调用,若有一个对象发生变化,则需要跟踪和该对象关联的其他所有对象,并进行适当处理。
- 对象可重用性差:由于一个对象和其他对象具有很强的关联,若没有其他对象的支持,一个对象很难被另一个系统或模块重用,这些对象表现出来更像一个不可分割的整体,职责较为混乱。
- 系统扩展性低:增加一个新的对象需要在原有相关对象上增加引用,增加新的引用关系也需要调整原有对象,系统耦合度很高,对象操作很不灵活,扩展性差。
- 在面向对象的软件设计与开发过程中,根据“单一职责原则”,我们应该尽量将对象细化,使其只负责或呈现单一的职责。
- 对于一个模块,可能由很多对象构成,而且这些对象之间可能存在相互的引用,为了减少对象两两之间复杂的引用关系,使之成为一个松耦合的系统,我们需要使用中介者模式,这就是中介者模式的模式动机。
模式定义
--------------------
中介者模式(Mediator Pattern)定义:用一个中介对象来封装一系列的对象交互,中介者使各对象不需要显式地相互引用,从而使其耦合松散,而且可以独立地改变它们之间的交互。中介者模式又称为调停者模式,它是一种对象行为型模式。
模式结构
--------------------
中介者模式包含如下角色:
- Mediator: 抽象中介者
- ConcreteMediator: 具体中介者
- Colleague: 抽象同事类
- ConcreteColleague: 具体同事类
.. image:: /_static/Mediator.jpg
时序图
--------------------
.. image:: /_static/seq_Mediator.jpg
代码分析
--------------------
.. literalinclude:: /code/Mediator/main.cpp
:language: cpp
:linenos:
:lines: 1-
:emphasize-lines: 10-19
.. literalinclude:: /code/Mediator/ConcreteMediator.h
:language: cpp
:linenos:
:lines: 1-
:emphasize-lines: 23-26
.. literalinclude:: /code/Mediator/ConcreteMediator.cpp
:language: cpp
:linenos:
:lines: 1-
:emphasize-lines: 21-42
.. literalinclude:: /code/Mediator/ConcreteColleagueA.h
:language: cpp
:linenos:
:lines: 1-
:emphasize-lines: 20-21
.. literalinclude:: /code/Mediator/ConcreteColleagueA.cpp
:language: cpp
:linenos:
:lines: 1-
:emphasize-lines: 18-25
运行结果:
.. image:: /_static/Mediator_run.jpg
模式分析
--------------------
中介者模式可以使对象之间的关系数量急剧减少。
中介者承担两方面的职责:
- 中转作用(结构性):通过中介者提供的中转作用,各个同事对象就不再需要显式引用其他同事,当需要和其他同事进行通信时,通过中介者即可。该中转作用属于中介者在结构上的支持。
- 协调作用(行为性):中介者可以更进一步的对同事之间的关系进行封装,同事可以一致地和中介者进行交互,而不需要指明中介者需要具体怎么做,中介者根据封装在自身内部的协调逻辑,对同事的请求进行进一步处理,将同事成员之间的关系行为进行分离和封装。该协调作用属于中介者在行为上的支持。
.. image:: /_static/Mediator_eg.jpg
时序图
.. image:: /_static/seq_Mediator_eg.jpg
实例
--------------------
实例:虚拟聊天室
某论坛系统欲增加一个虚拟聊天室,允许论坛会员通过该聊天室进行信息交流,普通会员(CommonMember)可以给其他会员发送文本信息,钻石会员(DiamondMember)既可以给其他会员发送文本信息,还可以发送图片信息。该聊天室可以对不雅字符进行过滤,如“日”等字符;还可以对发送的图片大小进行控制。用中介者模式设计该虚拟聊天室。
优点
--------------------
中介者模式的优点
- 简化了对象之间的交互。
- 将各同事解耦。
- 减少子类生成。
- 可以简化各同事类的设计和实现。
缺点
--------------------
中介者模式的缺点
- 在具体中介者类中包含了同事之间的交互细节,可能会导致具体中介者类非常复杂,使得系统难以维护。
适用环境
--------------------
在以下情况下可以使用中介者模式:
- 系统中对象之间存在复杂的引用关系,产生的相互依赖关系结构混乱且难以理解。
- 一个对象由于引用了其他很多对象并且直接和这些对象通信,导致难以复用该对象。
- 想通过一个中间类来封装多个类中的行为,而又不想生成太多的子类。可以通过引入中介者类来实现,在中介者中定义对象。
- 交互的公共行为,如果需要改变行为则可以增加新的中介者类。
模式应用
--------------------
MVC架构中控制器
Controller 作为一种中介者,它负责控制视图对象View和模型对象Model之间的交互。如在Struts中,Action就可以作为JSP页面与业务对象之间的中介者。
模式扩展
--------------------
中介者模式与迪米特法则
- 在中介者模式中,通过创造出一个中介者对象,将系统中有关的对象所引用的其他对象数目减少到最少,使得一个对象与其同事之间的相互作用被这个对象与中介者对象之间的相互作用所取代。因此,中介者模式就是迪米特法则的一个典型应用。
中介者模式与GUI开发
- 中介者模式可以方便地应用于图形界面(GUI)开发中,在比较复杂的界面中可能存在多个界面组件之间的交互关系。
- 对于这些复杂的交互关系,有时候我们可以引入一个中介者类,将这些交互的组件作为具体的同事类,将它们之间的引用和控制关系交由中介者负责,在一定程度上简化系统的交互,这也是中介者模式的常见应用之一。
总结
--------------------
- 中介者模式用一个中介对象来封装一系列的对象交互,中介者使各对象不需要显式地相互引用,从而使其耦合松散,而且可以独立地改变它们之间的交互。中介者模式又称为调停者模式,它是一种对象行为型模式。
- 中介者模式包含四个角色:抽象中介者用于定义一个接口,该接口用于与各同事对象之间的通信;具体中介者是抽象中介者的子类,通过协调各个同事对象来实现协作行为,了解并维护它的各个同事对象的引用;抽象同事类定义各同事的公有方法;具体同事类是抽象同事类的子类,每一个同事对象都引用一个中介者对象;每一个同事对象在需要和其他同事对象通信时,先与中介者通信,通过中介者来间接完成与其他同事类的通信;在具体同事类中实现了在抽象同事类中定义的方法。
- 通过引入中介者对象,可以将系统的网状结构变成以中介者为中心的星形结构,中介者承担了中转作用和协调作用。中介者类是中介者模式的核心,它对整个系统进行控制和协调,简化了对象之间的交互,还可以对对象间的交互进行进一步的控制。
- 中介者模式的主要优点在于简化了对象之间的交互,将各同事解耦,还可以减少子类生成,对于复杂的对象之间的交互,通过引入中介者,可以简化各同事类的设计和实现;中介者模式主要缺点在于具体中介者类中包含了同事之间的交互细节,可能会导致具体中介者类非常复杂,使得系统难以维护。
- 中介者模式适用情况包括:系统中对象之间存在复杂的引用关系,产生的相互依赖关系结构混乱且难以理解;一个对象由于引用了其他很多对象并且直接和这些对象通信,导致难以复用该对象;想通过一个中间类来封装多个类中的行为,而又不想生成太多的子类。
================================================
FILE: behavioral_patterns/observer.rst
================================================
.. _observer:
观察者模式
====================
.. contents:: 目录
模式动机
--------------------
建立一种对象与对象之间的依赖关系,一个对象发生改变时将自动通知其他对象,其他对象将相应做出反应。在此,发生改变的对象称为观察目标,而被通知的对象称为观察者,一个观察目标可以对应多个观察者,而且这些观察者之间没有相互联系,可以根据需要增加和删除观察者,使得系统更易于扩展,这就是观察者模式的模式动机。
模式定义
--------------------
观察者模式(Observer Pattern):定义对象间的一种一对多依赖关系,使得每当一个对象状态发生改变时,其相关依赖对象皆得到通知并被自动更新。观察者模式又叫做发布-订阅(Publish/Subscribe)模式、模型-视图(Model/View)模式、源-监听器(Source/Listener)模式或从属者(Dependents)模式。
观察者模式是一种对象行为型模式。
模式结构
--------------------
观察者模式包含如下角色:
- Subject: 目标
- ConcreteSubject: 具体目标
- Observer: 观察者
- ConcreteObserver: 具体观察者
.. image:: /_static/Obeserver.jpg
时序图
--------------------
.. image:: /_static/seq_Obeserver.jpg
代码分析
--------------------
.. literalinclude:: /code/Obeserver/main.cpp
:language: cpp
:linenos:
:lines: 1-
:emphasize-lines: 11-23
.. literalinclude:: /code/Obeserver/Subject.h
:language: cpp
:linenos:
:lines: 1-
:emphasize-lines: 23-25,31
.. literalinclude:: /code/Obeserver/Subject.cpp
:language: cpp
:linenos:
:lines: 1-
:emphasize-lines: 18-41
.. literalinclude:: /code/Obeserver/Obeserver.h
:language: cpp
:linenos:
:lines: 1-
:emphasize-lines: 11
.. literalinclude:: /code/Obeserver/ConcreteObeserver.h
:language: cpp
:linenos:
:lines: 1-
.. literalinclude:: /code/Obeserver/ConcreteObeserver.cpp
:language: cpp
:linenos:
:lines: 1-
:emphasize-lines: 22-25
运行结果:
.. image:: /_static/Obeserver_run.jpg
模式分析
--------------------
- 观察者模式描述了如何建立对象与对象之间的依赖关系,如何构造满足这种需求的系统。
- 这一模式中的关键对象是观察目标和观察者,一个目标可以有任意数目的与之相依赖的观察者,一旦目标的状态发生改变,所有的观察者都将得到通知。
- 作为对这个通知的响应,每个观察者都将即时更新自己的状态,以与目标状态同步,这种交互也称为发布-订阅(publishsubscribe)。目标是通知的发布者,它发出通知时并不需要知道谁是它的观察者,可以有任意数目的观察者订阅它并接收通
知。
实例
--------------------
优点
--------------------
观察者模式的优点
- 观察者模式可以实现表示层和数据逻辑层的分离,并定义了稳定的消息更新传递机制,抽象了更新接口,使得可以有各种各样不同的表示层作为具体观察者角色。
- 观察者模式在观察目标和观察者之间建立一个抽象的耦合。
- 观察者模式支持广播通信。
- 观察者模式符合“开闭原则”的要求。
缺点
--------------------
观察者模式的缺点
- 如果一个观察目标对象有很多直接和间接的观察者的话,将所有的观察者都通知到会花费很多时间。
- 如果在观察者和观察目标之间有循环依赖的话,观察目标会触发它们之间进行循环调用,可能导致系统崩溃。
- 观察者模式没有相应的机制让观察者知道所观察的目标对象是怎么发生变化的,而仅仅只是知道观察目标发生了变化。
适用环境
--------------------
在以下情况下可以使用观察者模式:
- 一个抽象模型有两个方面,其中一个方面依赖于另一个方面。将这些方面封装在独立的对象中使它们可以各自独立地改变和复用。
- 一个对象的改变将导致其他一个或多个对象也发生改变,而不知道具体有多少对象将发生改变,可以降低对象之间的耦合度。
- 一个对象必须通知其他对象,而并不知道这些对象是谁。
- 需要在系统中创建一个触发链,A对象的行为将影响B对象,B对象的行为将影响C对象……,可以使用观察者模式创建一种链式触发机制。
模式应用
--------------------
观察者模式在软件开发中应用非常广泛,如某电子商务网站可以在执行发送操作后给用户多个发送商品打折信息,某团队战斗游戏中某队友牺牲将给所有成员提示等等,凡是涉及到一对一或者一对多的对象交互场景都可以使用观察者模式。
模式扩展
--------------------
MVC模式
- MVC模式是一种架构模式,它包含三个角色:模型(Model),视图(View)和控制器(Controller)。观察者模式可以用来实现MVC模式,观察者模式中的观察目标就是MVC模式中的模型(Model),而观察者就是MVC中的视图(View),控制器(Controller)充当两者之间的中介者(Mediator)。当模型层的数据发生改变时,视图层将自动改变其显示内容。
总结
--------------------
- 观察者模式定义对象间的一种一对多依赖关系,使得每当一个对象状态发生改变时,其相关依赖对象皆得到通知并被自动更新。观察者模式又叫做发布-订阅模式、模型-视图模式、源-监听器模式或从属者模式。观察者模式是一种对象行为型模式。
- 观察者模式包含四个角色:目标又称为主题,它是指被观察的对象;具体目标是目标类的子类,通常它包含有经常发生改变的数据,当它的状态发生改变时,向它的各个观察者发出通知;观察者将对观察目标的改变做出反应;在具体观察者中维护一个指向具体目标对象的引用,它存储具体观察者的有关状态,这些状态需要和具体目标的状态保持一致。
- 观察者模式定义了一种一对多的依赖关系,让多个观察者对象同时监听某一个目标对象,当这个目标对象的状态发生变化时,会通知所有观察者对象,使它们能够自动更新。
- 观察者模式的主要优点在于可以实现表示层和数据逻辑层的分离,并在观察目标和观察者之间建立一个抽象的耦合,支持广播通信;其主要缺点在于如果一个观察目标对象有很多直接和间接的观察者的话,将所有的观察者都通知到会花费很多时间,而且如果在观察者和观察目标之间有循环依赖的话,观察目标会触发它们之间进行循环调用,可能导致系统崩溃。
- 观察者模式适用情况包括:一个抽象模型有两个方面,其中一个方面依赖于另一个方面;一个对象的改变将导致其他一个或多个对象也发生改变,而不知道具体有多少对象将发生改变;一个对象必须通知其他对象,而并不知道这些对象是谁;需要在系统中创建一个触发链。
- 在JDK的java.util包中,提供了Observable类以及Observer接口,它们构成了Java语言对观察者模式的支持。
================================================
FILE: behavioral_patterns/state.rst
================================================
.. _state:
状态模式
====================
.. contents:: 目录
模式动机
--------------------
- 在很多情况下,一个对象的行为取决于一个或多个动态变化的属性,这样的属性叫做状态,这样的对象叫做有状态的(stateful)对象,这样的对象状态是从事先定义好的一系列值中取出的。当一个这样的对象与外部事件产生互动时,其内部状态就会改变,从而使得系统的行为也随之发生变化。
- 在UML中可以使用状态图来描述对象状态的变化。
模式定义
--------------------
状态模式(State Pattern) :允许一个对象在其内部状态改变时改变它的行为,对象看起来似乎修改了它的类。其别名为状态对象(Objects for States),状态模式是一种对象行为型模式。
模式结构
--------------------
状态模式包含如下角色:
- Context: 环境类
- State: 抽象状态类
- ConcreteState: 具体状态类
.. image:: /_static/State.jpg
时序图
--------------------
.. image:: /_static/seq_State.jpg
既然是状态模式,加上状态图,对状态转换间的理解会清晰很多:
.. image:: /_static/State1.png
代码分析
--------------------
.. literalinclude:: /code/State/main.cpp
:language: cpp
:linenos:
:lines: 1-
.. literalinclude:: /code/State/Context.h
:language: cpp
:linenos:
:lines: 1-
:emphasize-lines: 20-24
.. literalinclude:: /code/State/Context.cpp
:language: cpp
:linenos:
:lines: 1-
:emphasize-lines: 19-25
.. literalinclude:: /code/State/ConcreteStateA.h
:language: cpp
:linenos:
:lines: 1-
.. literalinclude:: /code/State/ConcreteStateA.cpp
:language: cpp
:linenos:
:lines: 1-
:emphasize-lines: 30-33
运行结果:
.. image:: /_static/State_run.jpg
模式分析
--------------------
- 状态模式描述了对象状态的变化以及对象如何在每一种状态下表现出不同的行为。
- 状态模式的关键是引入了一个抽象类来专门表示对象的状态,这个类我们叫做抽象状态类,而对象的每一种具体状态类都继承了该类,并在不同具体状态类中实现了不同状态的行为,包括各种状态之间的转换。
在状态模式结构中需要理解环境类与抽象状态类的作用:
- 环境类实际上就是拥有状态的对象,环境类有时候可以充当状态管理器(State Manager)的角色,可以在环境类中对状态进行切换操作。
- 抽象状态类可以是抽象类,也可以是接口,不同状态类就是继承这个父类的不同子类,状态类的产生是由于环境类存在多个状态,同时还满足两个条件: 这些状态经常需要切换,在不同的状态下对象的行为不同。因此可以将不同对象下的行为单独提取出来封装在具体的状态类中,使得环境类对象在其内部状态改变时可以改变它的行为,对象看起来似乎修改了它的类,而实际上是由于切换到不同的具体状态类实现的。由于环境类可以设置为任一具体状态类,因此它针对抽象状态类进行编程,在程序运行时可以将任一具体状态类的对象设置到环境类中,从而使得环境类可以改变内部状态,并且改变行为。
实例
--------------------
TCPConnection
这个示例来自《设计模式》,展示了一个简化版的TCP协议实现;
TCP连接的状态有多种可能,状态之间的转换有相应的逻辑前提;
这是使用状态模式的场合;
状态图:
.. image:: /_static/State2.png
结构图:
.. image:: /_static/State_eg.jpg
时序图:
.. image:: /_static/seq_State_eg.jpg
优点
--------------------
状态模式的优点
- 封装了转换规则。
- 枚举可能的状态,在枚举状态之前需要确定状态种类。
- 将所有与某个状态有关的行为放到一个类中,并且可以方便地增加新的状态,只需要改变对象状态即可改变对象的行为。
- 允许状态转换逻辑与状态对象合成一体,而不是某一个巨大的条件语句块。
- 可以让多个环境对象共享一个状态对象,从而减少系统中对象的个数。
缺点
--------------------
状态模式的缺点
- 状态模式的使用必然会增加系统类和对象的个数。
- 状态模式的结构与实现都较为复杂,如果使用不当将导致程序结构和代码的混乱。
- 状态模式对“开闭原则”的支持并不太好,对于可以切换状态的状态模式,增加新的状态类需要修改那些负责状态转换的源代码,否则无法切换到新增状态;而且修改某个状态类的行为也需修改对应类的源代码。
适用环境
--------------------
在以下情况下可以使用状态模式:
- 对象的行为依赖于它的状态(属性)并且可以根据它的状态改变而改变它的相关行为。
- 代码中包含大量与对象状态有关的条件语句,这些条件语句的出现,会导致代码的可维护性和灵活性变差,不能方便地增加和删除状态,使客户类与类库之间的耦合增强。在这些条件语句中包含了对象的行为,而且这些条件对应于对象的各种状态。
模式应用
--------------------
状态模式在工作流或游戏等类型的软件中得以广泛使用,甚至可以用于这些系统的核心功能设计,如在政府OA办公系统中,一个批文的状态有多种:尚未办理;正在办理;正在批示;正在审核;已经完成等各种状态,而且批文状态不同时对批文的操作也有所差异。使用状态模式可以描述工作流对象(如批文)的状态转换以及不同状态下它所具有的行为。
模式扩展
--------------------
共享状态
- 在有些情况下多个环境对象需要共享同一个状态,如果希望在系统中实现多个环境对象实例共享一个或多个状态对象,那么需要将这些状态对象定义为环境的静态成员对象。
简单状态模式与可切换状态的状态模式
1) 简单状态模式:简单状态模式是指状态都相互独立,状态之间无须进行转换的状态模式,这是最简单的一种状态模式。对于这种状态模式,每个状态类都封装与状态相关的操作,而无须关心状态的切换,可以在客户端直接实例化状态类,然后将状态对象设置到环境类中。如果是这种简单的状态模式,它遵循“开闭原则”,在客户端可以针对抽象状态类进行编程,而将具体状态类写到配置文件中,同时增加新的状态类对原有系统也不造成任何影响。
2) 可切换状态的状态模式:大多数的状态模式都是可以切换状态的状态模式,在实现状态切换时,在具体状态类内部需要调用环境类Context的setState()方法进行状态的转换操作,在具体状态类中可以调用到环境类的方法,因此状态类与环境类之间通常还存在关联关系或者依赖关系。通过在状态类中引用环境类的对象来回调环境类的setState()方法实现状态的切换。在这种可以切换状态的状态模式中,增加新的状态类可能需要修改其他某些状态类甚至环境类的源代码,否则系统无法切换到新增状态。
总结
--------------------
- 状态模式允许一个对象在其内部状态改变时改变它的行为,对象看起来似乎修改了它的类。其别名为状态对象,状态模式是一种对象行为型模式。
- 状态模式包含三个角色:环境类又称为上下文类,它是拥有状态的对象,在环境类中维护一个抽象状态类State的实例,这个实例定义当前状态,在具体实现时,它是一个State子类的对象,可以定义初始状态;抽象状态类用于定义一个接口以封装与环境类的一个特定状态相关的行为;具体状态类是抽象状态类的子类,每一个子类实现一个与环境类的一个状态相关的行为,每一个具体状态类对应环境的一个具体状态,不同的具体状态类其行为有所不同。
- 状态模式描述了对象状态的变化以及对象如何在每一种状态下表现出不同的行为。
- 状态模式的主要优点在于封装了转换规则,并枚举可能的状态,它将所有与某个状态有关的行为放到一个类中,并且可以方便地增加新的状态,只需要改变对象状态即可改变对象的行为,还可以让多个环境对象共享一个状态对象,从而减少系统中对象的个数;其缺点在于使用状态模式会增加系统类和对象的个数,且状态模式的结构与实现都较为复杂,如果使用不当将导致程序结构和代码的混乱,对于可以切换状态的状态模式不满足“开闭原则”的要求。
- 状态模式适用情况包括:对象的行为依赖于它的状态(属性)并且可以根据它的状态改变而改变它的相关行为;代码中包含大量与对象状态有关的条件语句,这些条件语句的出现,会导致代码的可维护性和灵活性变差,不能方便地增加和删除状态,使客户类与类库之间的耦合增强。
================================================
FILE: behavioral_patterns/strategy.rst
================================================
.. _strategy:
策略模式
====================
.. contents:: 目录
模式动机
--------------------
- 完成一项任务,往往可以有多种不同的方式,每一种方式称为一个策略,我们可以根据环境或者条件的不同选择不同的策略来完成该项任务。
- 在软件开发中也常常遇到类似的情况,实现某一个功能有多个途径,此时可以使用一种设计模式来使得系统可以灵活地选择解决途径,也能够方便地增加新的解决途径。
- 在软件系统中,有许多算法可以实现某一功能,如查找、排序等,一种常用的方法是硬编码(Hard Coding)在一个类中,如需要提供多种查找算法,可以将这些算法写到一个类中,在该类中提供多个方法,每一个方法对应一个具体的查找算法;当然也可以将这些查找算法封装在一个统一的方法中,通过if…else…等条件判断语句来进行选择。这两种实现方法我们都可以称之为硬编码,如果需要增加一种新的查找算法,需要修改封装算法类的源代码;更换查找算法,也需要修改客户端调用代码。在这个算法类中封装了大量查找算法,该类代码将较复杂,维护较为困难。
- 除了提供专门的查找算法类之外,还可以在客户端程序中直接包含算法代码,这种做法更不可取,将导致客户端程序庞大而且难以维护,如果存在大量可供选择的算法时问题将变得更加严重。
- 为了解决这些问题,可以定义一些独立的类来封装不同的算法,每一个类封装一个具体的算法,在这里,每一个封装算法的类我们都可以称之为策略(Strategy),为了保证这些策略的一致性,一般会用一个抽象的策略类来做算法的定义,而具体每种算法则对应于一个具体策略类。
模式定义
--------------------
策略模式(Strategy Pattern):定义一系列算法,将每一个算法封装起来,并让它们可以相互替换。策略模式让算法独立于使用它的客户而变化,也称为政策模式(Policy)。
策略模式是一种对象行为型模式。
模式结构
--------------------
策略模式包含如下角色:
- Context: 环境类
- Strategy: 抽象策略类
- ConcreteStrategy: 具体策略类
.. image:: /_static/Strategy.jpg
时序图
--------------------
.. image:: /_static/seq_Strategy.jpg
代码分析
--------------------
.. literalinclude:: /code/Strategy/main.cpp
:language: cpp
:linenos:
:emphasize-lines: 10-17
.. literalinclude:: /code/Strategy/Context.h
:language: cpp
:linenos:
.. literalinclude:: /code/Strategy/Context.cpp
:language: cpp
:linenos:
:emphasize-lines: 16-22
.. literalinclude:: /code/Strategy/ConcreteStrategyA.h
:language: cpp
:linenos:
.. literalinclude:: /code/Strategy/ConcreteStrategyA.cpp
:language: cpp
:linenos:
运行结果:
.. image:: /_static/Strategy_run.jpg
模式分析
--------------------
- 策略模式是一个比较容易理解和使用的设计模式,策略模式是对算法的封装,它把算法的责任和算法本身分割开,委派给不同的对象管理。策略模式通常把一个系列的算法封装到一系列的策略类里面,作为一个抽象策略类的子类。用一句话来说,就是“准备一组算法,并将每一个算法封装起来,使得它们可以互换”。
- 在策略模式中,应当由客户端自己决定在什么情况下使用什么具体策略角色。
- 策略模式仅仅封装算法,提供新算法插入到已有系统中,以及老算法从系统中“退休”的方便,策略模式并不决定在何时使用何种算法,算法的选择由客户端来决定。这在一定程度上提高了系统的灵活性,但是客户端需要理解所有具体策略类之间的区别,以便选择合适的算法,这也是策略模式的缺点之一,在一定程度上增加了客户端的使用难度。
实例
--------------------
优点
--------------------
策略模式的优点
- 策略模式提供了对“开闭原则”的完美支持,用户可以在不修改原有系统的基础上选择算法或行为,也可以灵活地增加新的算法或行为。
- 策略模式提供了管理相关的算法族的办法。
- 策略模式提供了可以替换继承关系的办法。
- 使用策略模式可以避免使用多重条件转移语句。
缺点
--------------------
策略模式的缺点
- 客户端必须知道所有的策略类,并自行决定使用哪一个策略类。
- 策略模式将造成产生很多策略类,可以通过使用享元模式在一定程度上减少对象的数量。
适用环境
--------------------
在以下情况下可以使用策略模式:
- 如果在一个系统里面有许多类,它们之间的区别仅在于它们的行为,那么使用策略模式可以动态地让一个对象在许多行为中选择一种行为。
- 一个系统需要动态地在几种算法中选择一种。
- 如果一个对象有很多的行为,如果不用恰当的模式,这些行为就只好使用多重的条件选择语句来实现。
- 不希望客户端知道复杂的、与算法相关的数据结构,在具体策略类中封装算法和相关的数据结构,提高算法的保密性与安全性。
模式应用
--------------------
模式扩展
--------------------
策略模式与状态模式
- 可以通过环境类状态的个数来决定是使用策略模式还是状态模式。
- 策略模式的环境类自己选择一个具体策略类,具体策略类无须关心环境类;而状态模式的环境类由于外在因素需要放进一个具体状态中,以便通过其方法实现状态的切换,因此环境类和状态类之间存在一种双向的关联关系。
- 使用策略模式时,客户端需要知道所选的具体策略是哪一个,而使用状态模式时,客户端无须关心具体状态,环境类的状态会根据用户的操作自动转换。
- 如果系统中某个类的对象存在多种状态,不同状态下行为有差异,而且这些状态之间可以发生转换时使用状态模式;如果系统中某个类的某一行为存在多种实现方式,而且这些实现方式可以互换时使用策略模式。
总结
--------------------
- 在策略模式中定义了一系列算法,将每一个算法封装起来,并让它们可以相互替换。策略模式让算法独立于使用它的客户而变化,也称为政策模式。策略模式是一种对象行为型模式。
- 策略模式包含三个角色:环境类在解决某个问题时可以采用多种策略,在环境类中维护一个对抽象策略类的引用实例;抽象策略类为所支持的算法声明了抽象方法,是所有策略类的父类;具体策略类实现了在抽象策略类中定义的算法。
- 策略模式是对算法的封装,它把算法的责任和算法本身分割开,委派给不同的对象管理。策略模式通常把一个系列的算法封装到一系列的策略类里面,作为一个抽象策略类的子类。
- 策略模式主要优点在于对“开闭原则”的完美支持,在不修改原有系统的基础上可以更换算法或者增加新的算法,它很好地管理算法族,提高了代码的复用性,是一种替换继承,避免多重条件转移语句的实现方式;其缺点在于客户端必须知道所有的策略类,并理解其区别,同时在一定程度上增加了系统中类的个数,可能会存在很多策略类。
- 策略模式适用情况包括:在一个系统里面有许多类,它们之间的区别仅在于它们的行为,使用策略模式可以动态地让一个对象在许多行为中选择一种行为;一个系统需要动态地在几种算法中选择一种;避免使用难以维护的多重条件选择语句;希望在具体策略类中封装算法和与相关的数据结构。
================================================
FILE: code/AbstractFactory/AbstractFactory.cpp
================================================
///////////////////////////////////////////////////////////
// AbstractFactory.cpp
// Implementation of the Class AbstractFactory
// Created on: 02-十月-2014 15:04:10
// Original author: cl
///////////////////////////////////////////////////////////
#include "AbstractFactory.h"
AbstractFactory::AbstractFactory(){
}
AbstractFactory::~AbstractFactory(){
}
================================================
FILE: code/AbstractFactory/AbstractFactory.h
================================================
///////////////////////////////////////////////////////////
// AbstractFactory.h
// Implementation of the Class AbstractFactory
// Created on: 02-十月-2014 15:04:09
// Original author: cl
///////////////////////////////////////////////////////////
#if !defined(EA_B48A03BA_2A60_4d85_B9EF_57DBDEEFE360__INCLUDED_)
#define EA_B48A03BA_2A60_4d85_B9EF_57DBDEEFE360__INCLUDED_
#include "AbstractProductA.h"
#include "AbstractProductB.h"
class AbstractFactory
{
public:
AbstractFactory();
virtual ~AbstractFactory();
virtual AbstractProductA * createProductA() = 0;
virtual AbstractProductB * createProductB() = 0;
};
#endif // !defined(EA_B48A03BA_2A60_4d85_B9EF_57DBDEEFE360__INCLUDED_)
================================================
FILE: code/AbstractFactory/AbstractProductA.cpp
================================================
///////////////////////////////////////////////////////////
// AbstractProductA.cpp
// Implementation of the Class AbstractProductA
// Created on: 02-十月-2014 15:04:14
// Original author: colin
///////////////////////////////////////////////////////////
#include "AbstractProductA.h"
AbstractProductA::AbstractProductA(){
}
AbstractProductA::~AbstractProductA(){
}
================================================
FILE: code/AbstractFactory/AbstractProductA.h
================================================
///////////////////////////////////////////////////////////
// AbstractProductA.h
// Implementation of the Class AbstractProductA
// Created on: 02-十月-2014 15:04:14
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_A8C81D97_DDD6_4ee6_8D9A_35E6305ED449__INCLUDED_)
#define EA_A8C81D97_DDD6_4ee6_8D9A_35E6305ED449__INCLUDED_
class AbstractProductA
{
public:
AbstractProductA();
virtual ~AbstractProductA();
virtual void use() = 0;
};
#endif // !defined(EA_A8C81D97_DDD6_4ee6_8D9A_35E6305ED449__INCLUDED_)
================================================
FILE: code/AbstractFactory/AbstractProductB.cpp
================================================
///////////////////////////////////////////////////////////
// AbstractProductB.cpp
// Implementation of the Class AbstractProductB
// Created on: 02-十月-2014 15:04:15
// Original author: colin
///////////////////////////////////////////////////////////
#include "AbstractProductB.h"
AbstractProductB::AbstractProductB(){
}
AbstractProductB::~AbstractProductB(){
}
================================================
FILE: code/AbstractFactory/AbstractProductB.h
================================================
///////////////////////////////////////////////////////////
// AbstractProductB.h
// Implementation of the Class AbstractProductB
// Created on: 02-十月-2014 15:04:15
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_20F4F7CF_3782_441b_BB79_CC25B8481002__INCLUDED_)
#define EA_20F4F7CF_3782_441b_BB79_CC25B8481002__INCLUDED_
class AbstractProductB
{
public:
AbstractProductB();
virtual ~AbstractProductB();
virtual void eat() = 0;
};
#endif // !defined(EA_20F4F7CF_3782_441b_BB79_CC25B8481002__INCLUDED_)
================================================
FILE: code/AbstractFactory/ConcreteFactory1.cpp
================================================
///////////////////////////////////////////////////////////
// ConcreteFactory1.cpp
// Implementation of the Class ConcreteFactory1
// Created on: 02-十月-2014 15:04:11
// Original author: colin
///////////////////////////////////////////////////////////
#include "ConcreteFactory1.h"
#include "ProductA1.h"
#include "ProductB1.h"
ConcreteFactory1::ConcreteFactory1(){
}
ConcreteFactory1::~ConcreteFactory1(){
}
AbstractProductA * ConcreteFactory1::createProductA(){
return new ProductA1();
}
AbstractProductB * ConcreteFactory1::createProductB(){
return new ProductB1();
}
================================================
FILE: code/AbstractFactory/ConcreteFactory1.h
================================================
///////////////////////////////////////////////////////////
// ConcreteFactory1.h
// Implementation of the Class ConcreteFactory1
// Created on: 02-十月-2014 15:04:11
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_A1BE35BD_23B8_4607_8EE7_7BCA32867D8E__INCLUDED_)
#define EA_A1BE35BD_23B8_4607_8EE7_7BCA32867D8E__INCLUDED_
#include "AbstractFactory.h"
#include "AbstractProductA.h"
#include "AbstractProductB.h"
class ConcreteFactory1 : public AbstractFactory
{
public:
ConcreteFactory1();
virtual ~ConcreteFactory1();
virtual AbstractProductA * createProductA();
virtual AbstractProductB * createProductB();
};
#endif // !defined(EA_A1BE35BD_23B8_4607_8EE7_7BCA32867D8E__INCLUDED_)
================================================
FILE: code/AbstractFactory/ConcreteFactory2.cpp
================================================
///////////////////////////////////////////////////////////
// ConcreteFactory2.cpp
// Implementation of the Class ConcreteFactory2
// Created on: 02-十月-2014 15:04:13
// Original author: colin
///////////////////////////////////////////////////////////
#include "ConcreteFactory2.h"
#include "ProductA2.h"
#include "ProductB2.h"
ConcreteFactory2::ConcreteFactory2(){
}
ConcreteFactory2::~ConcreteFactory2(){
}
AbstractProductA * ConcreteFactory2::createProductA(){
return new ProductA2();
}
AbstractProductB * ConcreteFactory2::createProductB(){
return new ProductB2();
}
================================================
FILE: code/AbstractFactory/ConcreteFactory2.h
================================================
///////////////////////////////////////////////////////////
// ConcreteFactory2.h
// Implementation of the Class ConcreteFactory2
// Created on: 02-十月-2014 15:04:13
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_E8105A80_B2A3_4ec2_821E_1061C896A888__INCLUDED_)
#define EA_E8105A80_B2A3_4ec2_821E_1061C896A888__INCLUDED_
#include "AbstractFactory.h"
#include "AbstractProductA.h"
#include "AbstractProductB.h"
class ConcreteFactory2 : public AbstractFactory
{
public:
ConcreteFactory2();
virtual ~ConcreteFactory2();
virtual AbstractProductA * createProductA();
virtual AbstractProductB * createProductB();
};
#endif // !defined(EA_E8105A80_B2A3_4ec2_821E_1061C896A888__INCLUDED_)
================================================
FILE: code/AbstractFactory/ProductA1.cpp
================================================
///////////////////////////////////////////////////////////
// ProductA1.cpp
// Implementation of the Class ProductA1
// Created on: 02-十月-2014 15:04:17
// Original author: colin
///////////////////////////////////////////////////////////
#include "ProductA1.h"
#include <iostream>
using namespace std;
ProductA1::ProductA1(){
}
ProductA1::~ProductA1(){
}
void ProductA1::use(){
cout << "use Product A1" << endl;
}
================================================
FILE: code/AbstractFactory/ProductA1.h
================================================
///////////////////////////////////////////////////////////
// ProductA1.h
// Implementation of the Class ProductA1
// Created on: 02-十月-2014 15:04:16
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_A2B201B2_C47D_41bd_9B53_C404C047CB78__INCLUDED_)
#define EA_A2B201B2_C47D_41bd_9B53_C404C047CB78__INCLUDED_
#include "AbstractProductA.h"
class ProductA1 : public AbstractProductA
{
public:
ProductA1();
virtual ~ProductA1();
void use();
};
#endif // !defined(EA_A2B201B2_C47D_41bd_9B53_C404C047CB78__INCLUDED_)
================================================
FILE: code/AbstractFactory/ProductA2.cpp
================================================
///////////////////////////////////////////////////////////
// ProductA2.cpp
// Implementation of the Class ProductA2
// Created on: 02-十月-2014 15:04:18
// Original author: colin
///////////////////////////////////////////////////////////
#include "ProductA2.h"
#include <iostream>
using namespace std;
ProductA2::ProductA2(){
}
ProductA2::~ProductA2(){
}
void ProductA2::use(){
cout << "use Product A2" << endl;
}
================================================
FILE: code/AbstractFactory/ProductA2.h
================================================
///////////////////////////////////////////////////////////
// ProductA2.h
// Implementation of the Class ProductA2
// Created on: 02-十月-2014 15:04:18
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_FA4DE366_9B79_4c87_B2A6_197B4713DFB1__INCLUDED_)
#define EA_FA4DE366_9B79_4c87_B2A6_197B4713DFB1__INCLUDED_
#include "AbstractProductA.h"
class ProductA2 : public AbstractProductA
{
public:
ProductA2();
virtual ~ProductA2();
void use();
};
#endif // !defined(EA_FA4DE366_9B79_4c87_B2A6_197B4713DFB1__INCLUDED_)
================================================
FILE: code/AbstractFactory/ProductB1.cpp
================================================
///////////////////////////////////////////////////////////
// ProductB1.cpp
// Implementation of the Class ProductB1
// Created on: 02-十月-2014 15:04:19
// Original author: colin
///////////////////////////////////////////////////////////
#include "ProductB1.h"
#include <iostream>
using namespace std;
ProductB1::ProductB1(){
}
ProductB1::~ProductB1(){
}
void ProductB1::eat(){
cout << "eat Product B1" << endl;
}
================================================
FILE: code/AbstractFactory/ProductB1.h
================================================
///////////////////////////////////////////////////////////
// ProductB1.h
// Implementation of the Class ProductB1
// Created on: 02-十月-2014 15:04:19
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_CAAE93FF_EC03_413c_A931_0528F68AA18A__INCLUDED_)
#define EA_CAAE93FF_EC03_413c_A931_0528F68AA18A__INCLUDED_
#include "AbstractProductB.h"
class ProductB1 : public AbstractProductB
{
public:
ProductB1();
virtual ~ProductB1();
void eat();
};
#endif // !defined(EA_CAAE93FF_EC03_413c_A931_0528F68AA18A__INCLUDED_)
================================================
FILE: code/AbstractFactory/ProductB2.cpp
================================================
///////////////////////////////////////////////////////////
// ProductB2.cpp
// Implementation of the Class ProductB2
// Created on: 02-十月-2014 15:04:20
// Original author: colin
///////////////////////////////////////////////////////////
#include "ProductB2.h"
#include <iostream>
using namespace std;
ProductB2::ProductB2(){
}
ProductB2::~ProductB2(){
}
void ProductB2::eat(){
cout << "eat Product B2" << endl;
}
================================================
FILE: code/AbstractFactory/ProductB2.h
================================================
///////////////////////////////////////////////////////////
// ProductB2.h
// Implementation of the Class ProductB2
// Created on: 02-十月-2014 15:04:20
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_D451967B_37E0_4776_9D7A_85DD6DC72821__INCLUDED_)
#define EA_D451967B_37E0_4776_9D7A_85DD6DC72821__INCLUDED_
#include "AbstractProductB.h"
class ProductB2 : public AbstractProductB
{
public:
ProductB2();
virtual ~ProductB2();
void eat();
};
#endif // !defined(EA_D451967B_37E0_4776_9D7A_85DD6DC72821__INCLUDED_)
================================================
FILE: code/AbstractFactory/main.cfp
================================================
<Project version="3.0">
<Name>main</Name>
<Type>CUI</Type>
<TargetName>main</TargetName>
<TargetType>exe</TargetType>
<Folder name="Source Files">
<File>main.cpp</File>
</Folder>
<Folder name="Header Files">
</Folder>
<Folder name="Other Files">
</Folder>
<File>AbstractFactory.cpp</File>
<File>AbstractFactory.h</File>
<File>AbstractProductA.cpp</File>
<File>AbstractProductA.h</File>
<File>AbstractProductB.cpp</File>
<File>AbstractProductB.h</File>
<File>ConcreteFactory1.cpp</File>
<File>ConcreteFactory1.h</File>
<File>ConcreteFactory2.cpp</File>
<File>ConcreteFactory2.h</File>
<File>ProductA1.cpp</File>
<File>ProductA1.h</File>
<File>ProductA2.cpp</File>
<File>ProductA2.h</File>
<File>ProductB1.cpp</File>
<File>ProductB1.h</File>
<File>ProductB2.cpp</File>
<File>ProductB2.h</File>
<Attribute topline="4" x="7" y="15">main.cpp</Attribute>
<Attribute topline="13" x="1" y="20">AbstractFactory.cpp</Attribute>
<Attribute topline="1" x="1" y="12">AbstractFactory.h</Attribute>
<Attribute topline="13" x="1" y="20">AbstractProductA.cpp</Attribute>
<Attribute topline="1" x="1" y="17">AbstractProductA.h</Attribute>
<Attribute topline="16" x="1" y="20">AbstractProductB.cpp</Attribute>
<Attribute topline="1" x="25" y="18">AbstractProductB.h</Attribute>
<Attribute topline="10" x="1" y="11">ConcreteFactory1.cpp</Attribute>
<Attribute topline="10" x="43" y="23">ConcreteFactory1.h</Attribute>
<Attribute topline="1" x="1" y="15">ConcreteFactory2.cpp</Attribute>
<Attribute topline="7" x="26" y="22">ConcreteFactory2.h</Attribute>
<Attribute topline="7" x="1" y="16">ProductA1.cpp</Attribute>
<Attribute topline="10" x="1" y="24">ProductA1.h</Attribute>
<Attribute topline="16" x="1" y="17">ProductA2.cpp</Attribute>
<Attribute topline="16" x="1" y="22">ProductB1.cpp</Attribute>
<Attribute topline="1" x="2" y="26">ProductB2.cpp</Attribute>
<FolderState>111</FolderState>
<DefConfig>mingw5</DefConfig>
<Builder name="mingw5" type="MinGW" version="1.0">
<TargetName>main</TargetName>
<TargetType>exe</TargetType>
<TargetDir>mingw5</TargetDir>
<InterimDir>mingw5</InterimDir>
<IncPaths endslash="0">
<Path>$(CFRoot)\mingw\include</Path>
<Path>$(CFRoot)\mingw\include\c++\3.4.5</Path>
<Path>$(CFRoot)\mingw\lib\gcc\mingw32\3.4.5\include</Path>
<Pattern>*\Include</Pattern>
<Pattern>*\Include\G++</Pattern>
<Pattern>*\Include\c++\?.?.?</Pattern>
</IncPaths>
<LibPaths>
<Path>$(CFRoot)\mingw\lib</Path>
<Path>$(CFRoot)\mingw\mingw32\lib</Path>
<Pattern>*\Lib</Pattern>
</LibPaths>
<ExePaths>
<Path>$(CFRoot)\mingw\bin</Path>
<Path>$(CFRoot)\mingw\mingw32\bin</Path>
<Pattern>*\Bin</Pattern>
</ExePaths>
<AutoDetect>
<Path>$(CFRoot)\mingw</Path>
<Path>C:\MinGW</Path>
<Path>D:\MinGW</Path>
<Path>E:\MinGW</Path>
<Path>F:\MinGW</Path>
<Path>G:\MinGW</Path>
<Path>C:\Dev-Cpp</Path>
<Path>D:\Dev-Cpp</Path>
<Path>E:\Dev-Cpp</Path>
<Path>F:\Dev-Cpp</Path>
<Path>G:\Dev-Cpp</Path>
<Reg>\SOFTWARE\Dev-C++|Install_Dir</Reg>
<Reg>\SOFTWARE\CodeBlocks|Path</Reg>
<Reg>\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MinGW_is1|Inno Setup: App Path</Reg>
<Reg>\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MinGW|InstallLocation</Reg>
</AutoDetect>
<CompilerOptions>
<Category name="C++ Language">
<Option value="-fno-for-scope" desc="Variables extends to the end of the for scope [-fno-for-scop]"/>
<Option value="-fno-default-inline" desc="Do not assume `inline' inside a class scope [-fno-default-inline]"/>
<Option value="-Wold-style-cast" desc="Warn if a C-style cast is used within a C++ program [-Wold-style-cast]"/>
</Category>
<Category name="C Language">
<Option value="-std=c89" desc="Compatible with standard iso9899:1990 (ISO C89) [-std=c89]"/>
<Option value="-std=c99" desc="ISO9899:1999 (ISO C99, this standard may be not yet fully supported) [-std=c99]"/>
<Option value="-std=gnu99" desc="ISO C99 plus GNU extensions [-std=gnu99]"/>
<Option value="-fno-asm" desc="Do not recognize asm, inline or typeof as a keyword [-fno-asm]"/>
<Option value="-fallow-single-precision" desc="Don't promote single precision math operations to double precision [-fallow-single-precision]"/>
</Category>
<Category name="Debugging">
<Option value="-g" desc="Produce debugging information for use by GDB [-g]"/>
</Category>
<Category name="Warnings">
<Option value="-w" desc="Inhibit all warning messages [-w]"/>
<Option value="-Wall" desc="Enable all compiler warnings [-Wall]"/>
<Option value="-Werror" desc="Make all warnings into errors [-Werror]"/>
<Option value="-Wformat" desc="Check calls to printf and scanf, etc. [-Wformat]"/>
<Option value="-Wmain" desc="Warn if the type of `main' is suspicious [-Wmain]"/>
<Option value="-Wreturn-type" desc="Warn if a function is defined with a return-type that defaults to int [-Wreturn-type]"/>
<Option value="-Wunused" desc="Combine all the `-Wunused' options [-Wunused]"/>
<Option value="-Wfloat-equal" desc="Warn if floating point values used in equality comparisons [-Wfloat-equal]"/>
<Option value="-Wunreachable-code" desc="Warn if there is code never be executed [-Wunreachable-code]"/>
</Category>
<Category name="Optimization">
<Option value="-O" desc="Optimize (for speed) [-O]"/>
<Option value="-O1" desc="Optimize more (for speed) [-O1]"/>
<Option value="-O2" desc="Optimize even more (for speed) [-O2]"/>
<Option value="-O3" desc="Optimize fully (for speed) [-O3]"/>
<Option value="-Os" desc="Optimize (for size) [-Os]"/>
</Category>
<RawOptionsDebug enabled="1">
<Default>-g -DDEBUG</Default>
<User>-g -DDEBUG</User>
</RawOptionsDebug>
<RawOptionsRelease enabled="0">
<Default>-O2</Default>
<User>-O2</User>
</RawOptionsRelease>
</CompilerOptions>
<LinkerOptions>
<LibsDebug enabled="1">
<Default>
</Default>
<User>
</User>
</LibsDebug>
<LibsRelease enabled="0">
<Default>
</Default>
<User>
</User>
</LibsRelease>
<RawOptionsDebug enabled="1">
<Default></Default>
<User></User>
</RawOptionsDebug>
<RawOptionsRelease enabled="0">
<Default>-s</Default>
<User>-s</User>
</RawOptionsRelease>
</LinkerOptions>
<Configs>
<BuildLog enabled="0">$(CFRoot)\Build.log</BuildLog>
<LibExt>lib;a</LibExt>
<ObjExt>o;obj</ObjExt>
<ResExt>res</ResExt>
</Configs>
<Commands msghandler="Gcc.mhr">
<Command name="C Compiler" io="1" rdos="0" sys="0">
<Program enabled="1">gcc.exe</Program>
<Parameter enabled="1">"$(FileName)" -c -o "$(Path)$(Name).o" $(CompilerOptions) -I$(IncPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">c</FileExt>
<Target>$(PATH)$(NAME).o</Target>
<TargetType>o</TargetType>
<CurrentDir>$(FilePath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Compiling $(FILENAME)...#81001</MsgID>
</Command>
<Command name="C++ Compiler" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">"$(FileName)" -c -o "$(Path)$(Name).o" $(CompilerOptions) -I$(IncPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">cpp;cxx;c++;cc</FileExt>
<Target>$(PATH)$(NAME).o</Target>
<TargetType>o</TargetType>
<CurrentDir>$(FilePath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Compiling $(FILENAME)...#81001</MsgID>
</Command>
<Command name="Linker(CUI)" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">$(ProjectFiles) -l$(Libs) -o "$(Target)" $(LinkerOptions) -L$(LibPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">o;obj;a;lib;res</FileExt>
<Target>$(Target)</Target>
<TargetType>cui</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Linker(GUI)" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">$(ProjectFiles) -l$(Libs) -o "$(Target)" $(LinkerOptions) -mwindows -L$(LibPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">o;obj;a;lib;res</FileExt>
<Target>$(Target)</Target>
<TargetType>gui</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Linker for DLL" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">-shared -Wl,--output-def="$(Path)$(Name).def" -Wl,--out-implib="$(Path)$(Name).lib" -Wl,--dll -L$(LibPaths) $(ProjectFiles) -o "$(Target)" $(LinkerOptions) -l$(Libs)</Parameter>
<FileExt enabled="1">o;obj;a;lib;res;def</FileExt>
<Target>$(Target)</Target>
<TargetType>dll</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Linker for Lib" io="1" rdos="0" sys="0">
<Program enabled="1">ar.exe</Program>
<Parameter enabled="1">-r "$(Target)" $(ProjectFiles)</Parameter>
<FileExt enabled="1">o;obj</FileExt>
<Target>$(Target)</Target>
<TargetType>lib</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Resource Compiler" io="1" rdos="0" sys="0">
<Program enabled="1">windres.exe</Program>
<Parameter enabled="1">-O coff -i "$(ShortFileName)" -o "$(Path)$(Name).res" --include-dir=$(ShortPath) --include-dir=$(IncPaths)</Parameter>
<FileExt enabled="1">rc</FileExt>
<Target>$(PATH)$(NAME).res</Target>
<TargetType>res</TargetType>
<CurrentDir>$(FilePath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Compiling $(FILENAME)...#81001</MsgID>
</Command>
<Command name="Debugger" io="0" rdos="0" sys="0">
<Program enabled="0">gdb.exe</Program>
<Parameter enabled="0">gdebug.dll</Parameter>
<FileExt enabled="0">*.*</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81003</MsgID>
</Command>
<Command name="Run Exe" io="0" rdos="0" sys="0">
<Program enabled="0">$(Target)</Program>
<Parameter enabled="0">$(Parameters)</Parameter>
<FileExt enabled="1">exe</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81004</MsgID>
</Command>
<Command name="Run DLL" io="0" rdos="0" sys="0">
<Program enabled="0">$(HostApp)</Program>
<Parameter enabled="0">$(Parameters)</Parameter>
<FileExt enabled="1">dll</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81004</MsgID>
</Command>
<Command name="Run" io="0" rdos="0" sys="0">
<Program enabled="0">$(HostApp)</Program>
<Parameter enabled="0">$(Parameters)</Parameter>
<FileExt enabled="0">:exe;dll</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81004</MsgID>
</Command>
<Command name="Clean Objects" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="1">"$(Path)$(Name).o" $(FileName)</Parameter>
<FileExt enabled="1">c;cpp;cxx;c++;cc</FileExt>
<Target>$(Target)</Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
<Command name="Clean Resource" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="1">"$(Path)$(Name).res" $(FileName)</Parameter>
<FileExt enabled="1">rc</FileExt>
<Target>$(Target)</Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
<Command name="Clean Io" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="0">"$(Path)$(Name).o" -silent</Parameter>
<FileExt enabled="0">*.*</FileExt>
<Target>$(Target)</Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
<Command name="Clean Target" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="0">"$(Target)"</Parameter>
<FileExt enabled="1">*.*</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
</Commands>
<Actions>
<Action name="Compile" depend="0">
<File>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
</File>
<Project>
</Project>
<MsgID>Complete Compile $(FileName): $(Error) error(s), $(Warning) warning(s)\nGenerated $(Target)#81005</MsgID>
<ErrMsgID>Complete Compile $(FileName): $(Error) error(s), $(Warning) warning(s)#81006</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Build" depend="0">
<File>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</File>
<Project>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</Project>
<MsgID>Complete Build $(TargetName): $(Error) error(s), $(Warning) warning(s)\nGenerated $(Target)#81007</MsgID>
<ErrMsgID>Complete Build $(TargetName): $(Error) error(s), $(Warning) warning(s)#81008</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Make" depend="1">
<File>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</File>
<Project>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</Project>
<MsgID>Complete Make $(TargetName): $(Error) error(s), $(Warning) warning(s)\nGenerated $(Target)#81009</MsgID>
<ErrMsgID>Complete Make $(TargetName): $(Error) error(s), $(Warning) warning(s)#81010</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Run" depend="0">
<File>
<Action>"Make"</Action>
<Command>"Run Exe""Run DLL""Run"</Command>
</File>
<Project>
<Action>"Make"</Action>
<Command>"Run Exe""Run DLL""Run"</Command>
</Project>
<MsgID>#81011</MsgID>
<ErrMsgID>#81012</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Debug" depend="0">
<File>
<Action>"Make"</Action>
<Command>"Debugger"</Command>
</File>
<Project>
<Action>"Make"</Action>
<Command>"Debugger"</Command>
</Project>
<MsgID>#81013</MsgID>
<ErrMsgID>#81014</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Clean" depend="0">
<File>
<Command>"Clean Objects""Clean Resource"</Command>
<Command>"Clean Io"</Command>
<Command>"Clean Target"</Command>
</File>
<Project>
<Command>"Clean Objects""Clean Resource""Clean Io"</Command>
<Command>"Clean Io"</Command>
<Command>"Clean Target"</Command>
</Project>
<MsgID>Complete Clean $(TargetName)#81015</MsgID>
<ErrMsgID>Clean $(TargetName) error#81016</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
</Actions>
</Builder>
</Project>
================================================
FILE: code/AbstractFactory/main.cfpg
================================================
<Projects version="2.0">
<Project active="1">main.cfp</Project>
<File active="1">main.cpp</File>
</Projects>
================================================
FILE: code/AbstractFactory/main.cpp
================================================
#include <iostream>
#include "AbstractFactory.h"
#include "AbstractProductA.h"
#include "AbstractProductB.h"
#include "ConcreteFactory1.h"
#include "ConcreteFactory2.h"
using namespace std;
int main(int argc, char *argv[])
{
AbstractFactory * fc = new ConcreteFactory1();
AbstractProductA * pa = fc->createProductA();
AbstractProductB * pb = fc->createProductB();
pa->use();
pb->eat();
AbstractFactory * fc2 = new ConcreteFactory2();
AbstractProductA * pa2 = fc2->createProductA();
AbstractProductB * pb2 = fc2->createProductB();
pa2->use();
pb2->eat();
delete fc;
delete pa;
delete pb;
delete fc2;
delete pa2;
delete pb2;
return 0;
}
================================================
FILE: code/Adapter/Adaptee.cpp
================================================
///////////////////////////////////////////////////////////
// Adaptee.cpp
// Implementation of the Class Adaptee
// Created on: 03-十月-2014 17:32:00
// Original author: colin
///////////////////////////////////////////////////////////
#include "Adaptee.h"
#include <iostream>
using namespace std;
Adaptee::Adaptee(){
}
Adaptee::~Adaptee(){
}
void Adaptee::specificRequest(){
cout << "specificRequest()|this is real Request from Adaptee!" << endl;
}
================================================
FILE: code/Adapter/Adaptee.h
================================================
///////////////////////////////////////////////////////////
// Adaptee.h
// Implementation of the Class Adaptee
// Created on: 03-十月-2014 17:32:00
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_826E6B4F_12BE_4609_A0A3_95BD5E657D36__INCLUDED_)
#define EA_826E6B4F_12BE_4609_A0A3_95BD5E657D36__INCLUDED_
class Adaptee
{
public:
Adaptee();
virtual ~Adaptee();
void specificRequest();
};
#endif // !defined(EA_826E6B4F_12BE_4609_A0A3_95BD5E657D36__INCLUDED_)
================================================
FILE: code/Adapter/Adapter.cpp
================================================
///////////////////////////////////////////////////////////
// Adapter.cpp
// Implementation of the Class Adapter
// Created on: 03-十月-2014 17:32:00
// Original author: colin
///////////////////////////////////////////////////////////
#include "Adapter.h"
Adapter::Adapter(Adaptee * adaptee){
m_pAdaptee = adaptee;
}
Adapter::~Adapter(){
}
void Adapter::request(){
m_pAdaptee->specificRequest();
}
================================================
FILE: code/Adapter/Adapter.h
================================================
///////////////////////////////////////////////////////////
// Adapter.h
// Implementation of the Class Adapter
// Created on: 03-十月-2014 17:32:00
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_BD766D47_0C69_4131_B7B9_21DF78B1E80D__INCLUDED_)
#define EA_BD766D47_0C69_4131_B7B9_21DF78B1E80D__INCLUDED_
#include "Target.h"
#include "Adaptee.h"
class Adapter : public Target
{
public:
Adapter(Adaptee *adaptee);
virtual ~Adapter();
virtual void request();
private:
Adaptee* m_pAdaptee;
};
#endif // !defined(EA_BD766D47_0C69_4131_B7B9_21DF78B1E80D__INCLUDED_)
================================================
FILE: code/Adapter/Client.cpp
================================================
///////////////////////////////////////////////////////////
// Client.cpp
// Implementation of the Class Client
// Created on: 03-十月-2014 17:32:01
// Original author: colin
///////////////////////////////////////////////////////////
#include "Client.h"
Client::Client(){
}
Client::~Client(){
}
================================================
FILE: code/Adapter/Client.h
================================================
///////////////////////////////////////////////////////////
// Client.h
// Implementation of the Class Client
// Created on: 03-十月-2014 17:32:01
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_E8E0A9E0_55D9_4f95_81DE_7D51BC6C4087__INCLUDED_)
#define EA_E8E0A9E0_55D9_4f95_81DE_7D51BC6C4087__INCLUDED_
class Client
{
public:
Client();
virtual ~Client();
};
#endif // !defined(EA_E8E0A9E0_55D9_4f95_81DE_7D51BC6C4087__INCLUDED_)
================================================
FILE: code/Adapter/Target.cpp
================================================
///////////////////////////////////////////////////////////
// Target.cpp
// Implementation of the Class Target
// Created on: 03-十月-2014 17:32:01
// Original author: colin
///////////////////////////////////////////////////////////
#include "Target.h"
#include <iostream>
using namespace std;
Target::Target(){
}
Target::~Target(){
}
void Target::request(){
cout << "this is original request " << endl;
}
================================================
FILE: code/Adapter/Target.h
================================================
///////////////////////////////////////////////////////////
// Target.h
// Implementation of the Class Target
// Created on: 03-十月-2014 17:32:01
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_F694149D_AE3C_4295_962B_85E6916C402F__INCLUDED_)
#define EA_F694149D_AE3C_4295_962B_85E6916C402F__INCLUDED_
class Target
{
public:
Target();
virtual ~Target();
virtual void request();
};
#endif // !defined(EA_F694149D_AE3C_4295_962B_85E6916C402F__INCLUDED_)
================================================
FILE: code/Adapter/main.cfp
================================================
<Project version="3.0">
<Name>main</Name>
<Type>CUI</Type>
<TargetName>main</TargetName>
<TargetType>exe</TargetType>
<Folder name="Source Files">
<File>main.cpp</File>
</Folder>
<Folder name="Header Files">
</Folder>
<Folder name="Other Files">
</Folder>
<File>Adaptee.cpp</File>
<File>Adaptee.h</File>
<File>Adapter.cpp</File>
<File>Adapter.h</File>
<File>Target.cpp</File>
<File>Target.h</File>
<Attribute topline="1" x="37" y="10">main.cpp</Attribute>
<Attribute topline="1" x="17" y="12">Adaptee.cpp</Attribute>
<Attribute topline="4" x="25" y="18">Adaptee.h</Attribute>
<Attribute topline="16" x="2" y="20">Adapter.cpp</Attribute>
<Attribute topline="10" x="21" y="12">Adapter.h</Attribute>
<Attribute topline="1" x="21" y="10">Target.cpp</Attribute>
<Attribute topline="1" x="25" y="18">Target.h</Attribute>
<FolderState>111</FolderState>
<DefConfig>mingw5</DefConfig>
<Builder name="mingw5" type="MinGW" version="1.0">
<TargetName>main</TargetName>
<TargetType>exe</TargetType>
<TargetDir>mingw5</TargetDir>
<InterimDir>mingw5</InterimDir>
<IncPaths endslash="0">
<Path>$(CFRoot)\mingw\include</Path>
<Path>$(CFRoot)\mingw\include\c++\3.4.5</Path>
<Path>$(CFRoot)\mingw\lib\gcc\mingw32\3.4.5\include</Path>
<Pattern>*\Include</Pattern>
<Pattern>*\Include\G++</Pattern>
<Pattern>*\Include\c++\?.?.?</Pattern>
</IncPaths>
<LibPaths>
<Path>$(CFRoot)\mingw\lib</Path>
<Path>$(CFRoot)\mingw\mingw32\lib</Path>
<Pattern>*\Lib</Pattern>
</LibPaths>
<ExePaths>
<Path>$(CFRoot)\mingw\bin</Path>
<Path>$(CFRoot)\mingw\mingw32\bin</Path>
<Pattern>*\Bin</Pattern>
</ExePaths>
<AutoDetect>
<Path>$(CFRoot)\mingw</Path>
<Path>C:\MinGW</Path>
<Path>D:\MinGW</Path>
<Path>E:\MinGW</Path>
<Path>F:\MinGW</Path>
<Path>G:\MinGW</Path>
<Path>C:\Dev-Cpp</Path>
<Path>D:\Dev-Cpp</Path>
<Path>E:\Dev-Cpp</Path>
<Path>F:\Dev-Cpp</Path>
<Path>G:\Dev-Cpp</Path>
<Reg>\SOFTWARE\Dev-C++|Install_Dir</Reg>
<Reg>\SOFTWARE\CodeBlocks|Path</Reg>
<Reg>\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MinGW_is1|Inno Setup: App Path</Reg>
<Reg>\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MinGW|InstallLocation</Reg>
</AutoDetect>
<CompilerOptions>
<Category name="C++ Language">
<Option value="-fno-for-scope" desc="Variables extends to the end of the for scope [-fno-for-scop]"/>
<Option value="-fno-default-inline" desc="Do not assume `inline' inside a class scope [-fno-default-inline]"/>
<Option value="-Wold-style-cast" desc="Warn if a C-style cast is used within a C++ program [-Wold-style-cast]"/>
</Category>
<Category name="C Language">
<Option value="-std=c89" desc="Compatible with standard iso9899:1990 (ISO C89) [-std=c89]"/>
<Option value="-std=c99" desc="ISO9899:1999 (ISO C99, this standard may be not yet fully supported) [-std=c99]"/>
<Option value="-std=gnu99" desc="ISO C99 plus GNU extensions [-std=gnu99]"/>
<Option value="-fno-asm" desc="Do not recognize asm, inline or typeof as a keyword [-fno-asm]"/>
<Option value="-fallow-single-precision" desc="Don't promote single precision math operations to double precision [-fallow-single-precision]"/>
</Category>
<Category name="Debugging">
<Option value="-g" desc="Produce debugging information for use by GDB [-g]"/>
</Category>
<Category name="Warnings">
<Option value="-w" desc="Inhibit all warning messages [-w]"/>
<Option value="-Wall" desc="Enable all compiler warnings [-Wall]"/>
<Option value="-Werror" desc="Make all warnings into errors [-Werror]"/>
<Option value="-Wformat" desc="Check calls to printf and scanf, etc. [-Wformat]"/>
<Option value="-Wmain" desc="Warn if the type of `main' is suspicious [-Wmain]"/>
<Option value="-Wreturn-type" desc="Warn if a function is defined with a return-type that defaults to int [-Wreturn-type]"/>
<Option value="-Wunused" desc="Combine all the `-Wunused' options [-Wunused]"/>
<Option value="-Wfloat-equal" desc="Warn if floating point values used in equality comparisons [-Wfloat-equal]"/>
<Option value="-Wunreachable-code" desc="Warn if there is code never be executed [-Wunreachable-code]"/>
</Category>
<Category name="Optimization">
<Option value="-O" desc="Optimize (for speed) [-O]"/>
<Option value="-O1" desc="Optimize more (for speed) [-O1]"/>
<Option value="-O2" desc="Optimize even more (for speed) [-O2]"/>
<Option value="-O3" desc="Optimize fully (for speed) [-O3]"/>
<Option value="-Os" desc="Optimize (for size) [-Os]"/>
</Category>
<RawOptionsDebug enabled="1">
<Default>-g -DDEBUG</Default>
<User>-g -DDEBUG</User>
</RawOptionsDebug>
<RawOptionsRelease enabled="0">
<Default>-O2</Default>
<User>-O2</User>
</RawOptionsRelease>
</CompilerOptions>
<LinkerOptions>
<LibsDebug enabled="1">
<Default>
</Default>
<User>
</User>
</LibsDebug>
<LibsRelease enabled="0">
<Default>
</Default>
<User>
</User>
</LibsRelease>
<RawOptionsDebug enabled="1">
<Default></Default>
<User></User>
</RawOptionsDebug>
<RawOptionsRelease enabled="0">
<Default>-s</Default>
<User>-s</User>
</RawOptionsRelease>
</LinkerOptions>
<Configs>
<BuildLog enabled="0">$(CFRoot)\Build.log</BuildLog>
<LibExt>lib;a</LibExt>
<ObjExt>o;obj</ObjExt>
<ResExt>res</ResExt>
</Configs>
<Commands msghandler="Gcc.mhr">
<Command name="C Compiler" io="1" rdos="0" sys="0">
<Program enabled="1">gcc.exe</Program>
<Parameter enabled="1">"$(FileName)" -c -o "$(Path)$(Name).o" $(CompilerOptions) -I$(IncPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">c</FileExt>
<Target>$(PATH)$(NAME).o</Target>
<TargetType>o</TargetType>
<CurrentDir>$(FilePath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Compiling $(FILENAME)...#81001</MsgID>
</Command>
<Command name="C++ Compiler" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">"$(FileName)" -c -o "$(Path)$(Name).o" $(CompilerOptions) -I$(IncPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">cpp;cxx;c++;cc</FileExt>
<Target>$(PATH)$(NAME).o</Target>
<TargetType>o</TargetType>
<CurrentDir>$(FilePath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Compiling $(FILENAME)...#81001</MsgID>
</Command>
<Command name="Linker(CUI)" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">$(ProjectFiles) -l$(Libs) -o "$(Target)" $(LinkerOptions) -L$(LibPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">o;obj;a;lib;res</FileExt>
<Target>$(Target)</Target>
<TargetType>cui</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Linker(GUI)" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">$(ProjectFiles) -l$(Libs) -o "$(Target)" $(LinkerOptions) -mwindows -L$(LibPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">o;obj;a;lib;res</FileExt>
<Target>$(Target)</Target>
<TargetType>gui</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Linker for DLL" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">-shared -Wl,--output-def="$(Path)$(Name).def" -Wl,--out-implib="$(Path)$(Name).lib" -Wl,--dll -L$(LibPaths) $(ProjectFiles) -o "$(Target)" $(LinkerOptions) -l$(Libs)</Parameter>
<FileExt enabled="1">o;obj;a;lib;res;def</FileExt>
<Target>$(Target)</Target>
<TargetType>dll</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Linker for Lib" io="1" rdos="0" sys="0">
<Program enabled="1">ar.exe</Program>
<Parameter enabled="1">-r "$(Target)" $(ProjectFiles)</Parameter>
<FileExt enabled="1">o;obj</FileExt>
<Target>$(Target)</Target>
<TargetType>lib</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Resource Compiler" io="1" rdos="0" sys="0">
<Program enabled="1">windres.exe</Program>
<Parameter enabled="1">-O coff -i "$(ShortFileName)" -o "$(Path)$(Name).res" --include-dir=$(ShortPath) --include-dir=$(IncPaths)</Parameter>
<FileExt enabled="1">rc</FileExt>
<Target>$(PATH)$(NAME).res</Target>
<TargetType>res</TargetType>
<CurrentDir>$(FilePath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Compiling $(FILENAME)...#81001</MsgID>
</Command>
<Command name="Debugger" io="0" rdos="0" sys="0">
<Program enabled="0">gdb.exe</Program>
<Parameter enabled="0">gdebug.dll</Parameter>
<FileExt enabled="0">*.*</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81003</MsgID>
</Command>
<Command name="Run Exe" io="0" rdos="0" sys="0">
<Program enabled="0">$(Target)</Program>
<Parameter enabled="0">$(Parameters)</Parameter>
<FileExt enabled="1">exe</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81004</MsgID>
</Command>
<Command name="Run DLL" io="0" rdos="0" sys="0">
<Program enabled="0">$(HostApp)</Program>
<Parameter enabled="0">$(Parameters)</Parameter>
<FileExt enabled="1">dll</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81004</MsgID>
</Command>
<Command name="Run" io="0" rdos="0" sys="0">
<Program enabled="0">$(HostApp)</Program>
<Parameter enabled="0">$(Parameters)</Parameter>
<FileExt enabled="0">:exe;dll</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81004</MsgID>
</Command>
<Command name="Clean Objects" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="1">"$(Path)$(Name).o" $(FileName)</Parameter>
<FileExt enabled="1">c;cpp;cxx;c++;cc</FileExt>
<Target>$(Target)</Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
<Command name="Clean Resource" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="1">"$(Path)$(Name).res" $(FileName)</Parameter>
<FileExt enabled="1">rc</FileExt>
<Target>$(Target)</Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
<Command name="Clean Io" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="0">"$(Path)$(Name).o" -silent</Parameter>
<FileExt enabled="0">*.*</FileExt>
<Target>$(Target)</Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
<Command name="Clean Target" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="0">"$(Target)"</Parameter>
<FileExt enabled="1">*.*</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
</Commands>
<Actions>
<Action name="Compile" depend="0">
<File>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
</File>
<Project>
</Project>
<MsgID>Complete Compile $(FileName): $(Error) error(s), $(Warning) warning(s)\nGenerated $(Target)#81005</MsgID>
<ErrMsgID>Complete Compile $(FileName): $(Error) error(s), $(Warning) warning(s)#81006</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Build" depend="0">
<File>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</File>
<Project>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</Project>
<MsgID>Complete Build $(TargetName): $(Error) error(s), $(Warning) warning(s)\nGenerated $(Target)#81007</MsgID>
<ErrMsgID>Complete Build $(TargetName): $(Error) error(s), $(Warning) warning(s)#81008</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Make" depend="1">
<File>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</File>
<Project>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</Project>
<MsgID>Complete Make $(TargetName): $(Error) error(s), $(Warning) warning(s)\nGenerated $(Target)#81009</MsgID>
<ErrMsgID>Complete Make $(TargetName): $(Error) error(s), $(Warning) warning(s)#81010</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Run" depend="0">
<File>
<Action>"Make"</Action>
<Command>"Run Exe""Run DLL""Run"</Command>
</File>
<Project>
<Action>"Make"</Action>
<Command>"Run Exe""Run DLL""Run"</Command>
</Project>
<MsgID>#81011</MsgID>
<ErrMsgID>#81012</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Debug" depend="0">
<File>
<Action>"Make"</Action>
<Command>"Debugger"</Command>
</File>
<Project>
<Action>"Make"</Action>
<Command>"Debugger"</Command>
</Project>
<MsgID>#81013</MsgID>
<ErrMsgID>#81014</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Clean" depend="0">
<File>
<Command>"Clean Objects""Clean Resource"</Command>
<Command>"Clean Io"</Command>
<Command>"Clean Target"</Command>
</File>
<Project>
<Command>"Clean Objects""Clean Resource""Clean Io"</Command>
<Command>"Clean Io"</Command>
<Command>"Clean Target"</Command>
</Project>
<MsgID>Complete Clean $(TargetName)#81015</MsgID>
<ErrMsgID>Clean $(TargetName) error#81016</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
</Actions>
</Builder>
</Project>
================================================
FILE: code/Adapter/main.cfpg
================================================
<Projects version="2.0">
<Project active="1">main.cfp</Project>
<File active="1">main.cpp</File>
</Projects>
================================================
FILE: code/Adapter/main.cpp
================================================
#include <iostream>
#include "Adapter.h"
#include "Adaptee.h"
#include "Target.h"
using namespace std;
int main(int argc, char *argv[])
{
Adaptee * adaptee = new Adaptee();
Target * tar = new Adapter(adaptee);
tar->request();
return 0;
}
================================================
FILE: code/Bridge/Abstraction.cpp
================================================
///////////////////////////////////////////////////////////
// Abstraction.cpp
// Implementation of the Class Abstraction
// Created on: 03-十月-2014 18:12:43
// Original author: colin
///////////////////////////////////////////////////////////
#include "Abstraction.h"
Abstraction::Abstraction(){
}
Abstraction::~Abstraction(){
delete m_pImp;
}
Abstraction::Abstraction(Implementor* imp){
m_pImp = imp;
}
void Abstraction::operation(){
}
================================================
FILE: code/Bridge/Abstraction.h
================================================
///////////////////////////////////////////////////////////
// Abstraction.h
// Implementation of the Class Abstraction
// Created on: 03-十月-2014 18:12:43
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_E8BB74E1_58E2_463e_B8EE_5EC7E8E218B0__INCLUDED_)
#define EA_E8BB74E1_58E2_463e_B8EE_5EC7E8E218B0__INCLUDED_
#include "Implementor.h"
class Abstraction
{
public:
Abstraction();
virtual ~Abstraction();
Abstraction(Implementor* imp);
virtual void operation();
protected:
Implementor* m_pImp;
};
#endif // !defined(EA_E8BB74E1_58E2_463e_B8EE_5EC7E8E218B0__INCLUDED_)
================================================
FILE: code/Bridge/ConcreteImplementorA.cpp
================================================
///////////////////////////////////////////////////////////
// ConcreteImplementorA.cpp
// Implementation of the Class ConcreteImplementorA
// Created on: 03-十月-2014 18:12:43
// Original author: colin
///////////////////////////////////////////////////////////
#include "ConcreteImplementorA.h"
#include <iostream>
using namespace std;
ConcreteImplementorA::ConcreteImplementorA(){
}
ConcreteImplementorA::~ConcreteImplementorA(){
}
void ConcreteImplementorA::operationImp(){
cout << "imp in ConcreteImplementorA style." << endl;
}
================================================
FILE: code/Bridge/ConcreteImplementorA.h
================================================
///////////////////////////////////////////////////////////
// ConcreteImplementorA.h
// Implementation of the Class ConcreteImplementorA
// Created on: 03-十月-2014 18:12:43
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_77F5D11B_99CE_4c63_9971_9226E73FCBD1__INCLUDED_)
#define EA_77F5D11B_99CE_4c63_9971_9226E73FCBD1__INCLUDED_
#include "Implementor.h"
class ConcreteImplementorA : public Implementor
{
public:
ConcreteImplementorA();
virtual ~ConcreteImplementorA();
virtual void operationImp();
};
#endif // !defined(EA_77F5D11B_99CE_4c63_9971_9226E73FCBD1__INCLUDED_)
================================================
FILE: code/Bridge/ConcreteImplementorB.cpp
================================================
///////////////////////////////////////////////////////////
// ConcreteImplementorB.cpp
// Implementation of the Class ConcreteImplementorB
// Created on: 03-十月-2014 18:12:43
// Original author: colin
///////////////////////////////////////////////////////////
#include "ConcreteImplementorB.h"
#include <iostream>
using namespace std;
ConcreteImplementorB::ConcreteImplementorB(){
}
ConcreteImplementorB::~ConcreteImplementorB(){
}
void ConcreteImplementorB::operationImp(){
cout << "imp in ConcreteImplementorB style." << endl;
}
================================================
FILE: code/Bridge/ConcreteImplementorB.h
================================================
///////////////////////////////////////////////////////////
// ConcreteImplementorB.h
// Implementation of the Class ConcreteImplementorB
// Created on: 03-十月-2014 18:12:43
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_ED81E431_10B1_41f3_A4D6_037143E5773B__INCLUDED_)
#define EA_ED81E431_10B1_41f3_A4D6_037143E5773B__INCLUDED_
#include "Implementor.h"
class ConcreteImplementorB : public Implementor
{
public:
ConcreteImplementorB();
virtual ~ConcreteImplementorB();
virtual void operationImp();
};
#endif // !defined(EA_ED81E431_10B1_41f3_A4D6_037143E5773B__INCLUDED_)
================================================
FILE: code/Bridge/Implementor.cpp
================================================
///////////////////////////////////////////////////////////
// Implementor.cpp
// Implementation of the Class Implementor
// Created on: 03-十月-2014 18:12:43
// Original author: colin
///////////////////////////////////////////////////////////
#include "Implementor.h"
Implementor::Implementor(){
}
Implementor::~Implementor(){
}
void Implementor::operationImp(){
}
================================================
FILE: code/Bridge/Implementor.h
================================================
///////////////////////////////////////////////////////////
// Implementor.h
// Implementation of the Class Implementor
// Created on: 03-十月-2014 18:12:43
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_DBC56CB0_0310_476d_A44C_C159323E3181__INCLUDED_)
#define EA_DBC56CB0_0310_476d_A44C_C159323E3181__INCLUDED_
class Implementor
{
public:
Implementor();
virtual ~Implementor();
virtual void operationImp();
};
#endif // !defined(EA_DBC56CB0_0310_476d_A44C_C159323E3181__INCLUDED_)
================================================
FILE: code/Bridge/RefinedAbstraction.cpp
================================================
///////////////////////////////////////////////////////////
// RefinedAbstraction.cpp
// Implementation of the Class RefinedAbstraction
// Created on: 03-十月-2014 18:12:43
// Original author: colin
///////////////////////////////////////////////////////////
#include "RefinedAbstraction.h"
#include <iostream>
using namespace std;
RefinedAbstraction::RefinedAbstraction(){
}
RefinedAbstraction::RefinedAbstraction(Implementor* imp)
:Abstraction(imp)
{
}
RefinedAbstraction::~RefinedAbstraction(){
}
void RefinedAbstraction::operation(){
cout << "do something else ,and then " << endl;
m_pImp->operationImp();
}
================================================
FILE: code/Bridge/RefinedAbstraction.h
================================================
///////////////////////////////////////////////////////////
// RefinedAbstraction.h
// Implementation of the Class RefinedAbstraction
// Created on: 03-十月-2014 18:12:43
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_4BA5BE7C_DED5_4236_8362_F2988921CFA7__INCLUDED_)
#define EA_4BA5BE7C_DED5_4236_8362_F2988921CFA7__INCLUDED_
#include "Abstraction.h"
class RefinedAbstraction : public Abstraction
{
public:
RefinedAbstraction();
RefinedAbstraction(Implementor* imp);
virtual ~RefinedAbstraction();
virtual void operation();
};
#endif // !defined(EA_4BA5BE7C_DED5_4236_8362_F2988921CFA7__INCLUDED_)
================================================
FILE: code/Bridge/main.cfp
================================================
<Project version="3.0">
<Name>main</Name>
<Type>CUI</Type>
<TargetName>main</TargetName>
<TargetType>exe</TargetType>
<Folder name="Source Files">
<File>main.cpp</File>
</Folder>
<Folder name="Header Files">
</Folder>
<Folder name="Other Files">
</Folder>
<File>Abstraction.cpp</File>
<File>Abstraction.h</File>
<File>ConcreteImplementorA.cpp</File>
<File>ConcreteImplementorA.h</File>
<File>ConcreteImplementorB.cpp</File>
<File>ConcreteImplementorB.h</File>
<File>Implementor.cpp</File>
<File>Implementor.h</File>
<File>RefinedAbstraction.cpp</File>
<File>RefinedAbstraction.h</File>
<Attribute topline="4" x="2" y="15">main.cpp</Attribute>
<Attribute topline="13" x="17" y="30">Abstraction.cpp</Attribute>
<Attribute topline="4" x="1" y="22">Abstraction.h</Attribute>
<Attribute topline="4" x="1" y="27">ConcreteImplementorA.cpp</Attribute>
<Attribute topline="7" x="1" y="1">ConcreteImplementorA.h</Attribute>
<Attribute topline="16" x="1" y="26">ConcreteImplementorB.cpp</Attribute>
<Attribute topline="1" x="18" y="11">Implementor.h</Attribute>
<Attribute topline="13" x="1" y="25">RefinedAbstraction.cpp</Attribute>
<Attribute topline="10" x="3" y="23">RefinedAbstraction.h</Attribute>
<FolderState>111</FolderState>
<DefConfig>mingw5</DefConfig>
<Builder name="mingw5" type="MinGW" version="1.0">
<TargetName>main</TargetName>
<TargetType>exe</TargetType>
<TargetDir>mingw5</TargetDir>
<InterimDir>mingw5</InterimDir>
<IncPaths endslash="0">
<Path>$(CFRoot)\mingw\include</Path>
<Path>$(CFRoot)\mingw\include\c++\3.4.5</Path>
<Path>$(CFRoot)\mingw\lib\gcc\mingw32\3.4.5\include</Path>
<Pattern>*\Include</Pattern>
<Pattern>*\Include\G++</Pattern>
<Pattern>*\Include\c++\?.?.?</Pattern>
</IncPaths>
<LibPaths>
<Path>$(CFRoot)\mingw\lib</Path>
<Path>$(CFRoot)\mingw\mingw32\lib</Path>
<Pattern>*\Lib</Pattern>
</LibPaths>
<ExePaths>
<Path>$(CFRoot)\mingw\bin</Path>
<Path>$(CFRoot)\mingw\mingw32\bin</Path>
<Pattern>*\Bin</Pattern>
</ExePaths>
<AutoDetect>
<Path>$(CFRoot)\mingw</Path>
<Path>C:\MinGW</Path>
<Path>D:\MinGW</Path>
<Path>E:\MinGW</Path>
<Path>F:\MinGW</Path>
<Path>G:\MinGW</Path>
<Path>C:\Dev-Cpp</Path>
<Path>D:\Dev-Cpp</Path>
<Path>E:\Dev-Cpp</Path>
<Path>F:\Dev-Cpp</Path>
<Path>G:\Dev-Cpp</Path>
<Reg>\SOFTWARE\Dev-C++|Install_Dir</Reg>
<Reg>\SOFTWARE\CodeBlocks|Path</Reg>
<Reg>\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MinGW_is1|Inno Setup: App Path</Reg>
<Reg>\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MinGW|InstallLocation</Reg>
</AutoDetect>
<CompilerOptions>
<Category name="C++ Language">
<Option value="-fno-for-scope" desc="Variables extends to the end of the for scope [-fno-for-scop]"/>
<Option value="-fno-default-inline" desc="Do not assume `inline' inside a class scope [-fno-default-inline]"/>
<Option value="-Wold-style-cast" desc="Warn if a C-style cast is used within a C++ program [-Wold-style-cast]"/>
</Category>
<Category name="C Language">
<Option value="-std=c89" desc="Compatible with standard iso9899:1990 (ISO C89) [-std=c89]"/>
<Option value="-std=c99" desc="ISO9899:1999 (ISO C99, this standard may be not yet fully supported) [-std=c99]"/>
<Option value="-std=gnu99" desc="ISO C99 plus GNU extensions [-std=gnu99]"/>
<Option value="-fno-asm" desc="Do not recognize asm, inline or typeof as a keyword [-fno-asm]"/>
<Option value="-fallow-single-precision" desc="Don't promote single precision math operations to double precision [-fallow-single-precision]"/>
</Category>
<Category name="Debugging">
<Option value="-g" desc="Produce debugging information for use by GDB [-g]"/>
</Category>
<Category name="Warnings">
<Option value="-w" desc="Inhibit all warning messages [-w]"/>
<Option value="-Wall" desc="Enable all compiler warnings [-Wall]"/>
<Option value="-Werror" desc="Make all warnings into errors [-Werror]"/>
<Option value="-Wformat" desc="Check calls to printf and scanf, etc. [-Wformat]"/>
<Option value="-Wmain" desc="Warn if the type of `main' is suspicious [-Wmain]"/>
<Option value="-Wreturn-type" desc="Warn if a function is defined with a return-type that defaults to int [-Wreturn-type]"/>
<Option value="-Wunused" desc="Combine all the `-Wunused' options [-Wunused]"/>
<Option value="-Wfloat-equal" desc="Warn if floating point values used in equality comparisons [-Wfloat-equal]"/>
<Option value="-Wunreachable-code" desc="Warn if there is code never be executed [-Wunreachable-code]"/>
</Category>
<Category name="Optimization">
<Option value="-O" desc="Optimize (for speed) [-O]"/>
<Option value="-O1" desc="Optimize more (for speed) [-O1]"/>
<Option value="-O2" desc="Optimize even more (for speed) [-O2]"/>
<Option value="-O3" desc="Optimize fully (for speed) [-O3]"/>
<Option value="-Os" desc="Optimize (for size) [-Os]"/>
</Category>
<RawOptionsDebug enabled="1">
<Default>-g -DDEBUG</Default>
<User>-g -DDEBUG</User>
</RawOptionsDebug>
<RawOptionsRelease enabled="0">
<Default>-O2</Default>
<User>-O2</User>
</RawOptionsRelease>
</CompilerOptions>
<LinkerOptions>
<LibsDebug enabled="1">
<Default>
</Default>
<User>
</User>
</LibsDebug>
<LibsRelease enabled="0">
<Default>
</Default>
<User>
</User>
</LibsRelease>
<RawOptionsDebug enabled="1">
<Default></Default>
<User></User>
</RawOptionsDebug>
<RawOptionsRelease enabled="0">
<Default>-s</Default>
<User>-s</User>
</RawOptionsRelease>
</LinkerOptions>
<Configs>
<BuildLog enabled="0">$(CFRoot)\Build.log</BuildLog>
<LibExt>lib;a</LibExt>
<ObjExt>o;obj</ObjExt>
<ResExt>res</ResExt>
</Configs>
<Commands msghandler="Gcc.mhr">
<Command name="C Compiler" io="1" rdos="0" sys="0">
<Program enabled="1">gcc.exe</Program>
<Parameter enabled="1">"$(FileName)" -c -o "$(Path)$(Name).o" $(CompilerOptions) -I$(IncPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">c</FileExt>
<Target>$(PATH)$(NAME).o</Target>
<TargetType>o</TargetType>
<CurrentDir>$(FilePath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Compiling $(FILENAME)...#81001</MsgID>
</Command>
<Command name="C++ Compiler" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">"$(FileName)" -c -o "$(Path)$(Name).o" $(CompilerOptions) -I$(IncPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">cpp;cxx;c++;cc</FileExt>
<Target>$(PATH)$(NAME).o</Target>
<TargetType>o</TargetType>
<CurrentDir>$(FilePath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Compiling $(FILENAME)...#81001</MsgID>
</Command>
<Command name="Linker(CUI)" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">$(ProjectFiles) -l$(Libs) -o "$(Target)" $(LinkerOptions) -L$(LibPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">o;obj;a;lib;res</FileExt>
<Target>$(Target)</Target>
<TargetType>cui</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Linker(GUI)" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">$(ProjectFiles) -l$(Libs) -o "$(Target)" $(LinkerOptions) -mwindows -L$(LibPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">o;obj;a;lib;res</FileExt>
<Target>$(Target)</Target>
<TargetType>gui</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Linker for DLL" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">-shared -Wl,--output-def="$(Path)$(Name).def" -Wl,--out-implib="$(Path)$(Name).lib" -Wl,--dll -L$(LibPaths) $(ProjectFiles) -o "$(Target)" $(LinkerOptions) -l$(Libs)</Parameter>
<FileExt enabled="1">o;obj;a;lib;res;def</FileExt>
<Target>$(Target)</Target>
<TargetType>dll</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Linker for Lib" io="1" rdos="0" sys="0">
<Program enabled="1">ar.exe</Program>
<Parameter enabled="1">-r "$(Target)" $(ProjectFiles)</Parameter>
<FileExt enabled="1">o;obj</FileExt>
<Target>$(Target)</Target>
<TargetType>lib</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Resource Compiler" io="1" rdos="0" sys="0">
<Program enabled="1">windres.exe</Program>
<Parameter enabled="1">-O coff -i "$(ShortFileName)" -o "$(Path)$(Name).res" --include-dir=$(ShortPath) --include-dir=$(IncPaths)</Parameter>
<FileExt enabled="1">rc</FileExt>
<Target>$(PATH)$(NAME).res</Target>
<TargetType>res</TargetType>
<CurrentDir>$(FilePath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Compiling $(FILENAME)...#81001</MsgID>
</Command>
<Command name="Debugger" io="0" rdos="0" sys="0">
<Program enabled="0">gdb.exe</Program>
<Parameter enabled="0">gdebug.dll</Parameter>
<FileExt enabled="0">*.*</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81003</MsgID>
</Command>
<Command name="Run Exe" io="0" rdos="0" sys="0">
<Program enabled="0">$(Target)</Program>
<Parameter enabled="0">$(Parameters)</Parameter>
<FileExt enabled="1">exe</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81004</MsgID>
</Command>
<Command name="Run DLL" io="0" rdos="0" sys="0">
<Program enabled="0">$(HostApp)</Program>
<Parameter enabled="0">$(Parameters)</Parameter>
<FileExt enabled="1">dll</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81004</MsgID>
</Command>
<Command name="Run" io="0" rdos="0" sys="0">
<Program enabled="0">$(HostApp)</Program>
<Parameter enabled="0">$(Parameters)</Parameter>
<FileExt enabled="0">:exe;dll</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81004</MsgID>
</Command>
<Command name="Clean Objects" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="1">"$(Path)$(Name).o" $(FileName)</Parameter>
<FileExt enabled="1">c;cpp;cxx;c++;cc</FileExt>
<Target>$(Target)</Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
<Command name="Clean Resource" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="1">"$(Path)$(Name).res" $(FileName)</Parameter>
<FileExt enabled="1">rc</FileExt>
<Target>$(Target)</Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
<Command name="Clean Io" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="0">"$(Path)$(Name).o" -silent</Parameter>
<FileExt enabled="0">*.*</FileExt>
<Target>$(Target)</Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
<Command name="Clean Target" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="0">"$(Target)"</Parameter>
<FileExt enabled="1">*.*</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
</Commands>
<Actions>
<Action name="Compile" depend="0">
<File>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
</File>
<Project>
</Project>
<MsgID>Complete Compile $(FileName): $(Error) error(s), $(Warning) warning(s)\nGenerated $(Target)#81005</MsgID>
<ErrMsgID>Complete Compile $(FileName): $(Error) error(s), $(Warning) warning(s)#81006</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Build" depend="0">
<File>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</File>
<Project>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</Project>
<MsgID>Complete Build $(TargetName): $(Error) error(s), $(Warning) warning(s)\nGenerated $(Target)#81007</MsgID>
<ErrMsgID>Complete Build $(TargetName): $(Error) error(s), $(Warning) warning(s)#81008</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Make" depend="1">
<File>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</File>
<Project>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</Project>
<MsgID>Complete Make $(TargetName): $(Error) error(s), $(Warning) warning(s)\nGenerated $(Target)#81009</MsgID>
<ErrMsgID>Complete Make $(TargetName): $(Error) error(s), $(Warning) warning(s)#81010</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Run" depend="0">
<File>
<Action>"Make"</Action>
<Command>"Run Exe""Run DLL""Run"</Command>
</File>
<Project>
<Action>"Make"</Action>
<Command>"Run Exe""Run DLL""Run"</Command>
</Project>
<MsgID>#81011</MsgID>
<ErrMsgID>#81012</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Debug" depend="0">
<File>
<Action>"Make"</Action>
<Command>"Debugger"</Command>
</File>
<Project>
<Action>"Make"</Action>
<Command>"Debugger"</Command>
</Project>
<MsgID>#81013</MsgID>
<ErrMsgID>#81014</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Clean" depend="0">
<File>
<Command>"Clean Objects""Clean Resource"</Command>
<Command>"Clean Io"</Command>
<Command>"Clean Target"</Command>
</File>
<Project>
<Command>"Clean Objects""Clean Resource""Clean Io"</Command>
<Command>"Clean Io"</Command>
<Command>"Clean Target"</Command>
</Project>
<MsgID>Complete Clean $(TargetName)#81015</MsgID>
<ErrMsgID>Clean $(TargetName) error#81016</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
</Actions>
</Builder>
</Project>
================================================
FILE: code/Bridge/main.cfpg
================================================
<Projects version="2.0">
<Project active="1">main.cfp</Project>
<File active="1">main.cpp</File>
</Projects>
================================================
FILE: code/Bridge/main.cpp
================================================
#include <iostream>
#include "ConcreteImplementorA.h"
#include "ConcreteImplementorB.h"
#include "RefinedAbstraction.h"
#include "Abstraction.h"
using namespace std;
int main(int argc, char *argv[])
{
Implementor * pImp = new ConcreteImplementorA();
Abstraction * pa = new RefinedAbstraction(pImp);
pa->operation();
Abstraction * pb = new RefinedAbstraction(new ConcreteImplementorB());
pb->operation();
delete pa;
delete pb;
return 0;
}
================================================
FILE: code/Builder/Builder.cpp
================================================
///////////////////////////////////////////////////////////
// Builder.cpp
// Implementation of the Class Builder
// Created on: 02-十月-2014 15:57:02
// Original author: colin
///////////////////////////////////////////////////////////
#include "Builder.h"
Builder::Builder(){
m_prod = new Product();
}
Builder::~Builder(){
}
void Builder::buildPartA(){
}
void Builder::buildPartB(){
}
void Builder::buildPartC(){
}
Product* Builder::getResult(){
return m_prod;
}
================================================
FILE: code/Builder/Builder.h
================================================
///////////////////////////////////////////////////////////
// Builder.h
// Implementation of the Class Builder
// Created on: 02-十月-2014 15:57:02
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_938F1725_29F0_4174_93A3_D49DAB5D16A0__INCLUDED_)
#define EA_938F1725_29F0_4174_93A3_D49DAB5D16A0__INCLUDED_
#include "Product.h"
class Builder
{
public:
Builder();
virtual ~Builder();
virtual void buildPartA();
virtual void buildPartB();
virtual void buildPartC();
virtual Product * getResult();
protected :
Product * m_prod;
};
#endif // !defined(EA_938F1725_29F0_4174_93A3_D49DAB5D16A0__INCLUDED_)
================================================
FILE: code/Builder/ConcreteBuilder.cpp
================================================
///////////////////////////////////////////////////////////
// ConcreteBuilder.cpp
// Implementation of the Class ConcreteBuilder
// Created on: 02-十月-2014 15:57:03
// Original author: colin
///////////////////////////////////////////////////////////
#include "ConcreteBuilder.h"
ConcreteBuilder::ConcreteBuilder(){
}
ConcreteBuilder::~ConcreteBuilder(){
}
void ConcreteBuilder::buildPartA(){
m_prod->setA("A Style "); //不同的建造者,可以实现不同产品的建造
}
void ConcreteBuilder::buildPartB(){
m_prod->setB("B Style ");
}
void ConcreteBuilder::buildPartC(){
m_prod->setC("C style ");
}
================================================
FILE: code/Builder/ConcreteBuilder.h
================================================
///////////////////////////////////////////////////////////
// ConcreteBuilder.h
// Implementation of the Class ConcreteBuilder
// Created on: 02-十月-2014 15:57:02
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_8FD38521_8504_468b_A6E5_D23DE3F1E1F1__INCLUDED_)
#define EA_8FD38521_8504_468b_A6E5_D23DE3F1E1F1__INCLUDED_
#include "Builder.h"
class ConcreteBuilder : public Builder
{
public:
ConcreteBuilder();
virtual ~ConcreteBuilder();
virtual void buildPartA();
virtual void buildPartB();
virtual void buildPartC();
};
#endif // !defined(EA_8FD38521_8504_468b_A6E5_D23DE3F1E1F1__INCLUDED_)
================================================
FILE: code/Builder/Director.cpp
================================================
///////////////////////////////////////////////////////////
// Director.cpp
// Implementation of the Class Director
// Created on: 02-十月-2014 15:57:01
// Original author: colin
///////////////////////////////////////////////////////////
#include "Director.h"
Director::Director(){
}
Director::~Director(){
}
Product* Director::constuct(){
m_pbuilder->buildPartA();
m_pbuilder->buildPartB();
m_pbuilder->buildPartC();
return m_pbuilder->getResult();
}
void Director::setBuilder(Builder* buider){
m_pbuilder = buider;
}
================================================
FILE: code/Builder/Director.h
================================================
///////////////////////////////////////////////////////////
// Director.h
// Implementation of the Class Director
// Created on: 02-十月-2014 15:57:00
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_211CC7ED_6EAC_41b3_9A9B_BB97BCCF0D14__INCLUDED_)
#define EA_211CC7ED_6EAC_41b3_9A9B_BB97BCCF0D14__INCLUDED_
#include "Builder.h"
class Director
{
public:
Director();
virtual ~Director();
Builder *m_Builder;
Product* constuct();
void setBuilder(Builder* buider);
private:
Builder * m_pbuilder;
};
#endif // !defined(EA_211CC7ED_6EAC_41b3_9A9B_BB97BCCF0D14__INCLUDED_)
================================================
FILE: code/Builder/Product.cpp
================================================
///////////////////////////////////////////////////////////
// Product.cpp
// Implementation of the Class Product
// Created on: 02-十月-2014 15:57:04
// Original author: colin
///////////////////////////////////////////////////////////
#include "Product.h"
#include <iostream>
using namespace std;
Product::Product(){
}
Product::~Product(){
}
void Product::setA(string str)
{
m_a = str;
}
void Product::setB(string str)
{
m_b = str;
}
void Product::setC(string str)
{
m_c = str;
}
void Product::show()
{
cout << "product has" << m_a << m_b << m_c << endl;
}
================================================
FILE: code/Builder/Product.h
================================================
///////////////////////////////////////////////////////////
// Product.h
// Implementation of the Class Product
// Created on: 02-十月-2014 15:57:04
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_8B945DE2_C5A7_4959_A62A_0055346B957E__INCLUDED_)
#define EA_8B945DE2_C5A7_4959_A62A_0055346B957E__INCLUDED_
#include <iostream>
using namespace std;
class Product
{
public:
Product();
virtual ~Product();
void setA(string str);
void setB(string str);
void setC(string str);
void show();
private:
string m_a;
string m_b;
string m_c;
};
#endif // !defined(EA_8B945DE2_C5A7_4959_A62A_0055346B957E__INCLUDED_)
================================================
FILE: code/Builder/main.cfp
================================================
<Project version="3.0">
<Name>main</Name>
<Type>CUI</Type>
<TargetName>main</TargetName>
<TargetType>exe</TargetType>
<Folder name="Source Files">
<File>main.cpp</File>
</Folder>
<Folder name="Header Files">
</Folder>
<Folder name="Other Files">
</Folder>
<File>Builder.cpp</File>
<File>Builder.h</File>
<File>ConcreteBuilder.cpp</File>
<File>ConcreteBuilder.h</File>
<File>Director.cpp</File>
<File>Director.h</File>
<File>Product.cpp</File>
<File>Product.h</File>
<Attribute topline="1" x="13" y="15">main.cpp</Attribute>
<Attribute topline="33" x="2" y="42">Builder.cpp</Attribute>
<Attribute topline="10" x="3" y="25">Builder.h</Attribute>
<Attribute topline="16" x="33" y="11">ConcreteBuilder.cpp</Attribute>
<Attribute topline="7" x="28" y="22">ConcreteBuilder.h</Attribute>
<Attribute topline="13" x="1" y="23">Director.cpp</Attribute>
<Attribute topline="10" x="14" y="25">Director.h</Attribute>
<Attribute topline="22" x="2" y="40">Product.cpp</Attribute>
<Attribute topline="10" x="11" y="23">Product.h</Attribute>
<FolderState>111</FolderState>
<DefConfig>mingw5</DefConfig>
<Builder name="mingw5" type="MinGW" version="1.0">
<TargetName>main</TargetName>
<TargetType>exe</TargetType>
<TargetDir>mingw5</TargetDir>
<InterimDir>mingw5</InterimDir>
<IncPaths endslash="0">
<Path>$(CFRoot)\mingw\include</Path>
<Path>$(CFRoot)\mingw\include\c++\3.4.5</Path>
<Path>$(CFRoot)\mingw\lib\gcc\mingw32\3.4.5\include</Path>
<Pattern>*\Include</Pattern>
<Pattern>*\Include\G++</Pattern>
<Pattern>*\Include\c++\?.?.?</Pattern>
</IncPaths>
<LibPaths>
<Path>$(CFRoot)\mingw\lib</Path>
<Path>$(CFRoot)\mingw\mingw32\lib</Path>
<Pattern>*\Lib</Pattern>
</LibPaths>
<ExePaths>
<Path>$(CFRoot)\mingw\bin</Path>
<Path>$(CFRoot)\mingw\mingw32\bin</Path>
<Pattern>*\Bin</Pattern>
</ExePaths>
<AutoDetect>
<Path>$(CFRoot)\mingw</Path>
<Path>C:\MinGW</Path>
<Path>D:\MinGW</Path>
<Path>E:\MinGW</Path>
<Path>F:\MinGW</Path>
<Path>G:\MinGW</Path>
<Path>C:\Dev-Cpp</Path>
<Path>D:\Dev-Cpp</Path>
<Path>E:\Dev-Cpp</Path>
<Path>F:\Dev-Cpp</Path>
<Path>G:\Dev-Cpp</Path>
<Reg>\SOFTWARE\Dev-C++|Install_Dir</Reg>
<Reg>\SOFTWARE\CodeBlocks|Path</Reg>
<Reg>\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MinGW_is1|Inno Setup: App Path</Reg>
<Reg>\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MinGW|InstallLocation</Reg>
</AutoDetect>
<CompilerOptions>
<Category name="C++ Language">
<Option value="-fno-for-scope" desc="Variables extends to the end of the for scope [-fno-for-scop]"/>
<Option value="-fno-default-inline" desc="Do not assume `inline' inside a class scope [-fno-default-inline]"/>
<Option value="-Wold-style-cast" desc="Warn if a C-style cast is used within a C++ program [-Wold-style-cast]"/>
</Category>
<Category name="C Language">
<Option value="-std=c89" desc="Compatible with standard iso9899:1990 (ISO C89) [-std=c89]"/>
<Option value="-std=c99" desc="ISO9899:1999 (ISO C99, this standard may be not yet fully supported) [-std=c99]"/>
<Option value="-std=gnu99" desc="ISO C99 plus GNU extensions [-std=gnu99]"/>
<Option value="-fno-asm" desc="Do not recognize asm, inline or typeof as a keyword [-fno-asm]"/>
<Option value="-fallow-single-precision" desc="Don't promote single precision math operations to double precision [-fallow-single-precision]"/>
</Category>
<Category name="Debugging">
<Option value="-g" desc="Produce debugging information for use by GDB [-g]"/>
</Category>
<Category name="Warnings">
<Option value="-w" desc="Inhibit all warning messages [-w]"/>
<Option value="-Wall" desc="Enable all compiler warnings [-Wall]"/>
<Option value="-Werror" desc="Make all warnings into errors [-Werror]"/>
<Option value="-Wformat" desc="Check calls to printf and scanf, etc. [-Wformat]"/>
<Option value="-Wmain" desc="Warn if the type of `main' is suspicious [-Wmain]"/>
<Option value="-Wreturn-type" desc="Warn if a function is defined with a return-type that defaults to int [-Wreturn-type]"/>
<Option value="-Wunused" desc="Combine all the `-Wunused' options [-Wunused]"/>
<Option value="-Wfloat-equal" desc="Warn if floating point values used in equality comparisons [-Wfloat-equal]"/>
<Option value="-Wunreachable-code" desc="Warn if there is code never be executed [-Wunreachable-code]"/>
</Category>
<Category name="Optimization">
<Option value="-O" desc="Optimize (for speed) [-O]"/>
<Option value="-O1" desc="Optimize more (for speed) [-O1]"/>
<Option value="-O2" desc="Optimize even more (for speed) [-O2]"/>
<Option value="-O3" desc="Optimize fully (for speed) [-O3]"/>
<Option value="-Os" desc="Optimize (for size) [-Os]"/>
</Category>
<RawOptionsDebug enabled="1">
<Default>-g -DDEBUG</Default>
<User>-g -DDEBUG</User>
</RawOptionsDebug>
<RawOptionsRelease enabled="0">
<Default>-O2</Default>
<User>-O2</User>
</RawOptionsRelease>
</CompilerOptions>
<LinkerOptions>
<LibsDebug enabled="1">
<Default>
</Default>
<User>
</User>
</LibsDebug>
<LibsRelease enabled="0">
<Default>
</Default>
<User>
</User>
</LibsRelease>
<RawOptionsDebug enabled="1">
<Default></Default>
<User></User>
</RawOptionsDebug>
<RawOptionsRelease enabled="0">
<Default>-s</Default>
<User>-s</User>
</RawOptionsRelease>
</LinkerOptions>
<Configs>
<BuildLog enabled="0">$(CFRoot)\Build.log</BuildLog>
<LibExt>lib;a</LibExt>
<ObjExt>o;obj</ObjExt>
<ResExt>res</ResExt>
</Configs>
<Commands msghandler="Gcc.mhr">
<Command name="C Compiler" io="1" rdos="0" sys="0">
<Program enabled="1">gcc.exe</Program>
<Parameter enabled="1">"$(FileName)" -c -o "$(Path)$(Name).o" $(CompilerOptions) -I$(IncPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">c</FileExt>
<Target>$(PATH)$(NAME).o</Target>
<TargetType>o</TargetType>
<CurrentDir>$(FilePath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Compiling $(FILENAME)...#81001</MsgID>
</Command>
<Command name="C++ Compiler" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">"$(FileName)" -c -o "$(Path)$(Name).o" $(CompilerOptions) -I$(IncPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">cpp;cxx;c++;cc</FileExt>
<Target>$(PATH)$(NAME).o</Target>
<TargetType>o</TargetType>
<CurrentDir>$(FilePath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Compiling $(FILENAME)...#81001</MsgID>
</Command>
<Command name="Linker(CUI)" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">$(ProjectFiles) -l$(Libs) -o "$(Target)" $(LinkerOptions) -L$(LibPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">o;obj;a;lib;res</FileExt>
<Target>$(Target)</Target>
<TargetType>cui</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Linker(GUI)" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">$(ProjectFiles) -l$(Libs) -o "$(Target)" $(LinkerOptions) -mwindows -L$(LibPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">o;obj;a;lib;res</FileExt>
<Target>$(Target)</Target>
<TargetType>gui</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Linker for DLL" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">-shared -Wl,--output-def="$(Path)$(Name).def" -Wl,--out-implib="$(Path)$(Name).lib" -Wl,--dll -L$(LibPaths) $(ProjectFiles) -o "$(Target)" $(LinkerOptions) -l$(Libs)</Parameter>
<FileExt enabled="1">o;obj;a;lib;res;def</FileExt>
<Target>$(Target)</Target>
<TargetType>dll</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Linker for Lib" io="1" rdos="0" sys="0">
<Program enabled="1">ar.exe</Program>
<Parameter enabled="1">-r "$(Target)" $(ProjectFiles)</Parameter>
<FileExt enabled="1">o;obj</FileExt>
<Target>$(Target)</Target>
<TargetType>lib</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Resource Compiler" io="1" rdos="0" sys="0">
<Program enabled="1">windres.exe</Program>
<Parameter enabled="1">-O coff -i "$(ShortFileName)" -o "$(Path)$(Name).res" --include-dir=$(ShortPath) --include-dir=$(IncPaths)</Parameter>
<FileExt enabled="1">rc</FileExt>
<Target>$(PATH)$(NAME).res</Target>
<TargetType>res</TargetType>
<CurrentDir>$(FilePath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Compiling $(FILENAME)...#81001</MsgID>
</Command>
<Command name="Debugger" io="0" rdos="0" sys="0">
<Program enabled="0">gdb.exe</Program>
<Parameter enabled="0">gdebug.dll</Parameter>
<FileExt enabled="0">*.*</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81003</MsgID>
</Command>
<Command name="Run Exe" io="0" rdos="0" sys="0">
<Program enabled="0">$(Target)</Program>
<Parameter enabled="0">$(Parameters)</Parameter>
<FileExt enabled="1">exe</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81004</MsgID>
</Command>
<Command name="Run DLL" io="0" rdos="0" sys="0">
<Program enabled="0">$(HostApp)</Program>
<Parameter enabled="0">$(Parameters)</Parameter>
<FileExt enabled="1">dll</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81004</MsgID>
</Command>
<Command name="Run" io="0" rdos="0" sys="0">
<Program enabled="0">$(HostApp)</Program>
<Parameter enabled="0">$(Parameters)</Parameter>
<FileExt enabled="0">:exe;dll</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81004</MsgID>
</Command>
<Command name="Clean Objects" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="1">"$(Path)$(Name).o" $(FileName)</Parameter>
<FileExt enabled="1">c;cpp;cxx;c++;cc</FileExt>
<Target>$(Target)</Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
<Command name="Clean Resource" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="1">"$(Path)$(Name).res" $(FileName)</Parameter>
<FileExt enabled="1">rc</FileExt>
<Target>$(Target)</Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
<Command name="Clean Io" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="0">"$(Path)$(Name).o" -silent</Parameter>
<FileExt enabled="0">*.*</FileExt>
<Target>$(Target)</Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
<Command name="Clean Target" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="0">"$(Target)"</Parameter>
<FileExt enabled="1">*.*</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
</Commands>
<Actions>
<Action name="Compile" depend="0">
<File>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
</File>
<Project>
</Project>
<MsgID>Complete Compile $(FileName): $(Error) error(s), $(Warning) warning(s)\nGenerated $(Target)#81005</MsgID>
<ErrMsgID>Complete Compile $(FileName): $(Error) error(s), $(Warning) warning(s)#81006</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Build" depend="0">
<File>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</File>
<Project>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</Project>
<MsgID>Complete Build $(TargetName): $(Error) error(s), $(Warning) warning(s)\nGenerated $(Target)#81007</MsgID>
<ErrMsgID>Complete Build $(TargetName): $(Error) error(s), $(Warning) warning(s)#81008</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Make" depend="1">
<File>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</File>
<Project>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</Project>
<MsgID>Complete Make $(TargetName): $(Error) error(s), $(Warning) warning(s)\nGenerated $(Target)#81009</MsgID>
<ErrMsgID>Complete Make $(TargetName): $(Error) error(s), $(Warning) warning(s)#81010</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Run" depend="0">
<File>
<Action>"Make"</Action>
<Command>"Run Exe""Run DLL""Run"</Command>
</File>
<Project>
<Action>"Make"</Action>
<Command>"Run Exe""Run DLL""Run"</Command>
</Project>
<MsgID>#81011</MsgID>
<ErrMsgID>#81012</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Debug" depend="0">
<File>
<Action>"Make"</Action>
<Command>"Debugger"</Command>
</File>
<Project>
<Action>"Make"</Action>
<Command>"Debugger"</Command>
</Project>
<MsgID>#81013</MsgID>
<ErrMsgID>#81014</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Clean" depend="0">
<File>
<Command>"Clean Objects""Clean Resource"</Command>
<Command>"Clean Io"</Command>
<Command>"Clean Target"</Command>
</File>
<Project>
<Command>"Clean Objects""Clean Resource""Clean Io"</Command>
<Command>"Clean Io"</Command>
<Command>"Clean Target"</Command>
</Project>
<MsgID>Complete Clean $(TargetName)#81015</MsgID>
<ErrMsgID>Clean $(TargetName) error#81016</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
</Actions>
</Builder>
</Project>
================================================
FILE: code/Builder/main.cfpg
================================================
<Projects version="2.0">
<Project active="1">main.cfp</Project>
<File active="1">main.cpp</File>
</Projects>
================================================
FILE: code/Builder/main.cpp
================================================
#include <iostream>
#include "ConcreteBuilder.h"
#include "Director.h"
#include "Builder.h"
#include "Product.h"
using namespace std;
int main(int argc, char *argv[])
{
ConcreteBuilder * builder = new ConcreteBuilder();
Director director;
director.setBuilder(builder);
Product * pd = director.constuct();
pd->show();
delete builder;
delete pd;
return 0;
}
================================================
FILE: code/Command/Command.cpp
================================================
///////////////////////////////////////////////////////////
// Command.cpp
// Implementation of the Class Command
// Created on: 07-十月-2014 17:44:01
// Original author: colin
///////////////////////////////////////////////////////////
#include "Command.h"
Command::Command(){
}
Command::~Command(){
}
void Command::execute(){
}
================================================
FILE: code/Command/Command.h
================================================
///////////////////////////////////////////////////////////
// Command.h
// Implementation of the Class Command
// Created on: 07-十月-2014 17:44:01
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_DC004DA4_1FE9_4d5b_828F_6163F90CBEB9__INCLUDED_)
#define EA_DC004DA4_1FE9_4d5b_828F_6163F90CBEB9__INCLUDED_
class Command
{
public:
Command();
virtual ~Command();
virtual void execute();
};
#endif // !defined(EA_DC004DA4_1FE9_4d5b_828F_6163F90CBEB9__INCLUDED_)
================================================
FILE: code/Command/ConcreteCommand.cpp
================================================
///////////////////////////////////////////////////////////
// ConcreteCommand.cpp
// Implementation of the Class ConcreteCommand
// Created on: 07-十月-2014 17:44:02
// Original author: colin
///////////////////////////////////////////////////////////
#include "ConcreteCommand.h"
#include <iostream>
using namespace std;
ConcreteCommand::ConcreteCommand(Receiver *pReceiver){
m_pReceiver = pReceiver;
}
ConcreteCommand::~ConcreteCommand(){
}
void ConcreteCommand::execute(){
cout << "ConcreteCommand::execute" << endl;
m_pReceiver->action();
}
================================================
FILE: code/Command/ConcreteCommand.h
================================================
///////////////////////////////////////////////////////////
// ConcreteCommand.h
// Implementation of the Class ConcreteCommand
// Created on: 07-十月-2014 17:44:01
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_1AE70D53_4868_4e81_A1B8_1088DA355C23__INCLUDED_)
#define EA_1AE70D53_4868_4e81_A1B8_1088DA355C23__INCLUDED_
#include "Command.h"
#include "Receiver.h"
class ConcreteCommand : public Command
{
public:
ConcreteCommand(Receiver * pReceiver);
virtual ~ConcreteCommand();
virtual void execute();
private:
Receiver *m_pReceiver;
};
#endif // !defined(EA_1AE70D53_4868_4e81_A1B8_1088DA355C23__INCLUDED_)
================================================
FILE: code/Command/Invoker.cpp
================================================
///////////////////////////////////////////////////////////
// Invoker.cpp
// Implementation of the Class Invoker
// Created on: 07-十月-2014 17:44:02
// Original author: colin
///////////////////////////////////////////////////////////
#include "Invoker.h"
#include <iostream>
using namespace std;
Invoker::Invoker(Command * pCommand){
m_pCommand = pCommand;
}
Invoker::~Invoker(){
}
void Invoker::call(){
cout << "invoker calling" << endl;
m_pCommand->execute();
}
================================================
FILE: code/Command/Invoker.h
================================================
///////////////////////////////////////////////////////////
// Invoker.h
// Implementation of the Class Invoker
// Created on: 07-十月-2014 17:44:02
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_3DACB62A_0813_4d11_8A82_10BF1FB00D9A__INCLUDED_)
#define EA_3DACB62A_0813_4d11_8A82_10BF1FB00D9A__INCLUDED_
#include "Command.h"
class Invoker
{
public:
Invoker(Command * pCommand);
virtual ~Invoker();
void call();
private:
Command *m_pCommand;
};
#endif // !defined(EA_3DACB62A_0813_4d11_8A82_10BF1FB00D9A__INCLUDED_)
================================================
FILE: code/Command/Receiver.cpp
================================================
///////////////////////////////////////////////////////////
// Receiver.cpp
// Implementation of the Class Receiver
// Created on: 07-十月-2014 17:44:02
// Original author: colin
///////////////////////////////////////////////////////////
#include "Receiver.h"
#include <iostream>
using namespace std;
Receiver::Receiver(){
}
Receiver::~Receiver(){
}
void Receiver::action(){
cout << "receiver action." << endl;
}
================================================
FILE: code/Command/Receiver.h
================================================
///////////////////////////////////////////////////////////
// Receiver.h
// Implementation of the Class Receiver
// Created on: 07-十月-2014 17:44:02
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_8E5430BB_0904_4a7d_9A3B_7169586237C8__INCLUDED_)
#define EA_8E5430BB_0904_4a7d_9A3B_7169586237C8__INCLUDED_
class Receiver
{
public:
Receiver();
virtual ~Receiver();
void action();
};
#endif // !defined(EA_8E5430BB_0904_4a7d_9A3B_7169586237C8__INCLUDED_)
================================================
FILE: code/Command/main.cfp
================================================
<Project version="3.0">
<Name>main</Name>
<Type>CUI</Type>
<TargetName>main</TargetName>
<TargetType>exe</TargetType>
<Folder name="Source Files">
<File>main.cpp</File>
</Folder>
<Folder name="Header Files">
</Folder>
<Folder name="Other Files">
</Folder>
<File>Command.cpp</File>
<File>Command.h</File>
<File>ConcreteCommand.cpp</File>
<File>ConcreteCommand.h</File>
<File>Invoker.cpp</File>
<File>Invoker.h</File>
<File>Receiver.cpp</File>
<File>Receiver.h</File>
<Attribute topline="1" x="37" y="10">main.cpp</Attribute>
<Attribute topline="4" x="1" y="1">Command.cpp</Attribute>
<Attribute topline="1" x="25" y="18">Command.h</Attribute>
<Attribute topline="16" x="2" y="26">ConcreteCommand.cpp</Attribute>
<Attribute topline="10" x="25" y="20">ConcreteCommand.h</Attribute>
<Attribute topline="7" x="22" y="20">Invoker.cpp</Attribute>
<Attribute topline="5" x="9" y="21">Invoker.h</Attribute>
<Attribute topline="1" x="2" y="22">Receiver.cpp</Attribute>
<Attribute topline="1" x="22" y="16">Receiver.h</Attribute>
<FolderState>111</FolderState>
<DefConfig>mingw5</DefConfig>
<Builder name="mingw5" type="MinGW" version="1.0">
<TargetName>main</TargetName>
<TargetType>exe</TargetType>
<TargetDir>mingw5</TargetDir>
<InterimDir>mingw5</InterimDir>
<IncPaths endslash="0">
<Path>$(CFRoot)\mingw\include</Path>
<Path>$(CFRoot)\mingw\include\c++\3.4.5</Path>
<Path>$(CFRoot)\mingw\lib\gcc\mingw32\3.4.5\include</Path>
<Pattern>*\Include</Pattern>
<Pattern>*\Include\G++</Pattern>
<Pattern>*\Include\c++\?.?.?</Pattern>
</IncPaths>
<LibPaths>
<Path>$(CFRoot)\mingw\lib</Path>
<Path>$(CFRoot)\mingw\mingw32\lib</Path>
<Pattern>*\Lib</Pattern>
</LibPaths>
<ExePaths>
<Path>$(CFRoot)\mingw\bin</Path>
<Path>$(CFRoot)\mingw\mingw32\bin</Path>
<Pattern>*\Bin</Pattern>
</ExePaths>
<AutoDetect>
<Path>$(CFRoot)\mingw</Path>
<Path>C:\MinGW</Path>
<Path>D:\MinGW</Path>
<Path>E:\MinGW</Path>
<Path>F:\MinGW</Path>
<Path>G:\MinGW</Path>
<Path>C:\Dev-Cpp</Path>
<Path>D:\Dev-Cpp</Path>
<Path>E:\Dev-Cpp</Path>
<Path>F:\Dev-Cpp</Path>
<Path>G:\Dev-Cpp</Path>
<Reg>\SOFTWARE\Dev-C++|Install_Dir</Reg>
<Reg>\SOFTWARE\CodeBlocks|Path</Reg>
<Reg>\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MinGW_is1|Inno Setup: App Path</Reg>
<Reg>\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MinGW|InstallLocation</Reg>
</AutoDetect>
<CompilerOptions>
<Category name="C++ Language">
<Option value="-fno-for-scope" desc="Variables extends to the end of the for scope [-fno-for-scop]"/>
<Option value="-fno-default-inline" desc="Do not assume `inline' inside a class scope [-fno-default-inline]"/>
<Option value="-Wold-style-cast" desc="Warn if a C-style cast is used within a C++ program [-Wold-style-cast]"/>
</Category>
<Category name="C Language">
<Option value="-std=c89" desc="Compatible with standard iso9899:1990 (ISO C89) [-std=c89]"/>
<Option value="-std=c99" desc="ISO9899:1999 (ISO C99, this standard may be not yet fully supported) [-std=c99]"/>
<Option value="-std=gnu99" desc="ISO C99 plus GNU extensions [-std=gnu99]"/>
<Option value="-fno-asm" desc="Do not recognize asm, inline or typeof as a keyword [-fno-asm]"/>
<Option value="-fallow-single-precision" desc="Don't promote single precision math operations to double precision [-fallow-single-precision]"/>
</Category>
<Category name="Debugging">
<Option value="-g" desc="Produce debugging information for use by GDB [-g]"/>
</Category>
<Category name="Warnings">
<Option value="-w" desc="Inhibit all warning messages [-w]"/>
<Option value="-Wall" desc="Enable all compiler warnings [-Wall]"/>
<Option value="-Werror" desc="Make all warnings into errors [-Werror]"/>
<Option value="-Wformat" desc="Check calls to printf and scanf, etc. [-Wformat]"/>
<Option value="-Wmain" desc="Warn if the type of `main' is suspicious [-Wmain]"/>
<Option value="-Wreturn-type" desc="Warn if a function is defined with a return-type that defaults to int [-Wreturn-type]"/>
<Option value="-Wunused" desc="Combine all the `-Wunused' options [-Wunused]"/>
<Option value="-Wfloat-equal" desc="Warn if floating point values used in equality comparisons [-Wfloat-equal]"/>
<Option value="-Wunreachable-code" desc="Warn if there is code never be executed [-Wunreachable-code]"/>
</Category>
<Category name="Optimization">
<Option value="-O" desc="Optimize (for speed) [-O]"/>
<Option value="-O1" desc="Optimize more (for speed) [-O1]"/>
<Option value="-O2" desc="Optimize even more (for speed) [-O2]"/>
<Option value="-O3" desc="Optimize fully (for speed) [-O3]"/>
<Option value="-Os" desc="Optimize (for size) [-Os]"/>
</Category>
<RawOptionsDebug enabled="1">
<Default>-g -DDEBUG</Default>
<User>-g -DDEBUG</User>
</RawOptionsDebug>
<RawOptionsRelease enabled="0">
<Default>-O2</Default>
<User>-O2</User>
</RawOptionsRelease>
</CompilerOptions>
<LinkerOptions>
<LibsDebug enabled="1">
<Default>
</Default>
<User>
</User>
</LibsDebug>
<LibsRelease enabled="0">
<Default>
</Default>
<User>
</User>
</LibsRelease>
<RawOptionsDebug enabled="1">
<Default></Default>
<User></User>
</RawOptionsDebug>
<RawOptionsRelease enabled="0">
<Default>-s</Default>
<User>-s</User>
</RawOptionsRelease>
</LinkerOptions>
<Configs>
<BuildLog enabled="0">$(CFRoot)\Build.log</BuildLog>
<LibExt>lib;a</LibExt>
<ObjExt>o;obj</ObjExt>
<ResExt>res</ResExt>
</Configs>
<Commands msghandler="Gcc.mhr">
<Command name="C Compiler" io="1" rdos="0" sys="0">
<Program enabled="1">gcc.exe</Program>
<Parameter enabled="1">"$(FileName)" -c -o "$(Path)$(Name).o" $(CompilerOptions) -I$(IncPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">c</FileExt>
<Target>$(PATH)$(NAME).o</Target>
<TargetType>o</TargetType>
<CurrentDir>$(FilePath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Compiling $(FILENAME)...#81001</MsgID>
</Command>
<Command name="C++ Compiler" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">"$(FileName)" -c -o "$(Path)$(Name).o" $(CompilerOptions) -I$(IncPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">cpp;cxx;c++;cc</FileExt>
<Target>$(PATH)$(NAME).o</Target>
<TargetType>o</TargetType>
<CurrentDir>$(FilePath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Compiling $(FILENAME)...#81001</MsgID>
</Command>
<Command name="Linker(CUI)" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">$(ProjectFiles) -l$(Libs) -o "$(Target)" $(LinkerOptions) -L$(LibPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">o;obj;a;lib;res</FileExt>
<Target>$(Target)</Target>
<TargetType>cui</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Linker(GUI)" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">$(ProjectFiles) -l$(Libs) -o "$(Target)" $(LinkerOptions) -mwindows -L$(LibPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">o;obj;a;lib;res</FileExt>
<Target>$(Target)</Target>
<TargetType>gui</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Linker for DLL" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">-shared -Wl,--output-def="$(Path)$(Name).def" -Wl,--out-implib="$(Path)$(Name).lib" -Wl,--dll -L$(LibPaths) $(ProjectFiles) -o "$(Target)" $(LinkerOptions) -l$(Libs)</Parameter>
<FileExt enabled="1">o;obj;a;lib;res;def</FileExt>
<Target>$(Target)</Target>
<TargetType>dll</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Linker for Lib" io="1" rdos="0" sys="0">
<Program enabled="1">ar.exe</Program>
<Parameter enabled="1">-r "$(Target)" $(ProjectFiles)</Parameter>
<FileExt enabled="1">o;obj</FileExt>
<Target>$(Target)</Target>
<TargetType>lib</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Resource Compiler" io="1" rdos="0" sys="0">
<Program enabled="1">windres.exe</Program>
<Parameter enabled="1">-O coff -i "$(ShortFileName)" -o "$(Path)$(Name).res" --include-dir=$(ShortPath) --include-dir=$(IncPaths)</Parameter>
<FileExt enabled="1">rc</FileExt>
<Target>$(PATH)$(NAME).res</Target>
<TargetType>res</TargetType>
<CurrentDir>$(FilePath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Compiling $(FILENAME)...#81001</MsgID>
</Command>
<Command name="Debugger" io="0" rdos="0" sys="0">
<Program enabled="0">gdb.exe</Program>
<Parameter enabled="0">gdebug.dll</Parameter>
<FileExt enabled="0">*.*</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81003</MsgID>
</Command>
<Command name="Run Exe" io="0" rdos="0" sys="0">
<Program enabled="0">$(Target)</Program>
<Parameter enabled="0">$(Parameters)</Parameter>
<FileExt enabled="1">exe</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81004</MsgID>
</Command>
<Command name="Run DLL" io="0" rdos="0" sys="0">
<Program enabled="0">$(HostApp)</Program>
<Parameter enabled="0">$(Parameters)</Parameter>
<FileExt enabled="1">dll</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81004</MsgID>
</Command>
<Command name="Run" io="0" rdos="0" sys="0">
<Program enabled="0">$(HostApp)</Program>
<Parameter enabled="0">$(Parameters)</Parameter>
<FileExt enabled="0">:exe;dll</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81004</MsgID>
</Command>
<Command name="Clean Objects" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="1">"$(Path)$(Name).o" $(FileName)</Parameter>
<FileExt enabled="1">c;cpp;cxx;c++;cc</FileExt>
<Target>$(Target)</Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
<Command name="Clean Resource" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="1">"$(Path)$(Name).res" $(FileName)</Parameter>
<FileExt enabled="1">rc</FileExt>
<Target>$(Target)</Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
<Command name="Clean Io" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="0">"$(Path)$(Name).o" -silent</Parameter>
<FileExt enabled="0">*.*</FileExt>
<Target>$(Target)</Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
<Command name="Clean Target" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="0">"$(Target)"</Parameter>
<FileExt enabled="1">*.*</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
</Commands>
<Actions>
<Action name="Compile" depend="0">
<File>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
</File>
<Project>
</Project>
<MsgID>Complete Compile $(FileName): $(Error) error(s), $(Warning) warning(s)\nGenerated $(Target)#81005</MsgID>
<ErrMsgID>Complete Compile $(FileName): $(Error) error(s), $(Warning) warning(s)#81006</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Build" depend="0">
<File>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</File>
<Project>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</Project>
<MsgID>Complete Build $(TargetName): $(Error) error(s), $(Warning) warning(s)\nGenerated $(Target)#81007</MsgID>
<ErrMsgID>Complete Build $(TargetName): $(Error) error(s), $(Warning) warning(s)#81008</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Make" depend="1">
<File>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</File>
<Project>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</Project>
<MsgID>Complete Make $(TargetName): $(Error) error(s), $(Warning) warning(s)\nGenerated $(Target)#81009</MsgID>
<ErrMsgID>Complete Make $(TargetName): $(Error) error(s), $(Warning) warning(s)#81010</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Run" depend="0">
<File>
<Action>"Make"</Action>
<Command>"Run Exe""Run DLL""Run"</Command>
</File>
<Project>
<Action>"Make"</Action>
<Command>"Run Exe""Run DLL""Run"</Command>
</Project>
<MsgID>#81011</MsgID>
<ErrMsgID>#81012</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Debug" depend="0">
<File>
<Action>"Make"</Action>
<Command>"Debugger"</Command>
</File>
<Project>
<Action>"Make"</Action>
<Command>"Debugger"</Command>
</Project>
<MsgID>#81013</MsgID>
<ErrMsgID>#81014</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Clean" depend="0">
<File>
<Command>"Clean Objects""Clean Resource"</Command>
<Command>"Clean Io"</Command>
<Command>"Clean Target"</Command>
</File>
<Project>
<Command>"Clean Objects""Clean Resource""Clean Io"</Command>
<Command>"Clean Io"</Command>
<Command>"Clean Target"</Command>
</Project>
<MsgID>Complete Clean $(TargetName)#81015</MsgID>
<ErrMsgID>Clean $(TargetName) error#81016</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
</Actions>
</Builder>
</Project>
================================================
FILE: code/Command/main.cfpg
================================================
<Projects version="2.0">
<Project active="1">main.cfp</Project>
<File active="1">main.cpp</File>
</Projects>
================================================
FILE: code/Command/main.cpp
================================================
#include <iostream>
#include "ConcreteCommand.h"
#include "Invoker.h"
#include "Receiver.h"
using namespace std;
int main(int argc, char *argv[])
{
Receiver * pReceiver = new Receiver();
ConcreteCommand * pCommand = new ConcreteCommand(pReceiver);
Invoker * pInvoker = new Invoker(pCommand);
pInvoker->call();
delete pReceiver;
delete pCommand;
delete pInvoker;
return 0;
}
================================================
FILE: code/Decorator/Component.cpp
================================================
///////////////////////////////////////////////////////////
// Component.cpp
// Implementation of the Class Component
// Created on: 03-十月-2014 18:53:00
// Original author: colin
///////////////////////////////////////////////////////////
#include "Component.h"
Component::Component(){
}
Component::~Component(){
}
void Component::operation(){
}
================================================
FILE: code/Decorator/Component.h
================================================
///////////////////////////////////////////////////////////
// Component.h
// Implementation of the Class Component
// Created on: 03-十月-2014 18:53:00
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_1FB0D8F7_EC40_4a8c_A5BC_ED236BBDC33E__INCLUDED_)
#define EA_1FB0D8F7_EC40_4a8c_A5BC_ED236BBDC33E__INCLUDED_
class Component
{
public:
Component();
virtual ~Component();
virtual void operation();
};
#endif // !defined(EA_1FB0D8F7_EC40_4a8c_A5BC_ED236BBDC33E__INCLUDED_)
================================================
FILE: code/Decorator/ConcreteComponent.cpp
================================================
///////////////////////////////////////////////////////////
// ConcreteComponent.cpp
// Implementation of the Class ConcreteComponent
// Created on: 03-十月-2014 18:53:00
// Original author: colin
///////////////////////////////////////////////////////////
#include "ConcreteComponent.h"
#include <iostream>
using namespace std;
ConcreteComponent::ConcreteComponent(){
}
ConcreteComponent::~ConcreteComponent(){
}
void ConcreteComponent::operation(){
cout << "ConcreteComponent's normal operation!" << endl;
}
================================================
FILE: code/Decorator/ConcreteComponent.h
================================================
///////////////////////////////////////////////////////////
// ConcreteComponent.h
// Implementation of the Class ConcreteComponent
// Created on: 03-十月-2014 18:53:00
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_A20435BD_1DDE_439d_83AB_73AA7DAD469E__INCLUDED_)
#define EA_A20435BD_1DDE_439d_83AB_73AA7DAD469E__INCLUDED_
#include "Component.h"
class ConcreteComponent : public Component
{
public:
ConcreteComponent();
virtual ~ConcreteComponent();
void operation();
};
#endif // !defined(EA_A20435BD_1DDE_439d_83AB_73AA7DAD469E__INCLUDED_)
================================================
FILE: code/Decorator/ConcreteDecoratorA.cpp
================================================
///////////////////////////////////////////////////////////
// ConcreteDecoratorA.cpp
// Implementation of the Class ConcreteDecoratorA
// Created on: 03-十月-2014 18:53:00
// Original author: colin
///////////////////////////////////////////////////////////
#include "ConcreteDecoratorA.h"
#include <iostream>
using namespace std;
ConcreteDecoratorA::ConcreteDecoratorA(Component* pcmp)
:Decorator(pcmp)
{
}
ConcreteDecoratorA::~ConcreteDecoratorA(){
}
void ConcreteDecoratorA::addBehavior(){
cout << "addBehavior AAAA" << endl;
}
void ConcreteDecoratorA::operation(){
Decorator::operation();
addBehavior();
}
================================================
FILE: code/Decorator/ConcreteDecoratorA.h
================================================
///////////////////////////////////////////////////////////
// ConcreteDecoratorA.h
// Implementation of the Class ConcreteDecoratorA
// Created on: 03-十月-2014 18:53:00
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_6786B68E_DCE4_44c4_B26D_812F0B3C0382__INCLUDED_)
#define EA_6786B68E_DCE4_44c4_B26D_812F0B3C0382__INCLUDED_
#include "Decorator.h"
#include "Component.h"
class ConcreteDecoratorA : public Decorator
{
public:
ConcreteDecoratorA(Component* pcmp);
virtual ~ConcreteDecoratorA();
void addBehavior();
virtual void operation();
};
#endif // !defined(EA_6786B68E_DCE4_44c4_B26D_812F0B3C0382__INCLUDED_)
================================================
FILE: code/Decorator/ConcreteDecoratorB.cpp
================================================
///////////////////////////////////////////////////////////
// ConcreteDecoratorB.cpp
// Implementation of the Class ConcreteDecoratorB
// Created on: 03-十月-2014 18:53:00
// Original author: colin
///////////////////////////////////////////////////////////
#include "ConcreteDecoratorB.h"
#include <iostream>
using namespace std;
ConcreteDecoratorB::ConcreteDecoratorB(Component* pcmp)
:Decorator(pcmp)
{
}
ConcreteDecoratorB::~ConcreteDecoratorB(){
}
void ConcreteDecoratorB::addBehavior(){
cout << "addBehavior BBBB" << endl;
}
void ConcreteDecoratorB::operation(){
Decorator::operation();
addBehavior();
}
================================================
FILE: code/Decorator/ConcreteDecoratorB.h
================================================
///////////////////////////////////////////////////////////
// ConcreteDecoratorB.h
// Implementation of the Class ConcreteDecoratorB
// Created on: 03-十月-2014 18:53:00
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_D3774874_9201_4a73_956B_78973EC4E890__INCLUDED_)
#define EA_D3774874_9201_4a73_956B_78973EC4E890__INCLUDED_
#include "Decorator.h"
#include "Component.h"
class ConcreteDecoratorB : public Decorator
{
public:
ConcreteDecoratorB(Component* pcmp);
virtual ~ConcreteDecoratorB();
void addBehavior();
virtual void operation();
};
#endif // !defined(EA_D3774874_9201_4a73_956B_78973EC4E890__INCLUDED_)
================================================
FILE: code/Decorator/Decorator.cpp
================================================
///////////////////////////////////////////////////////////
// Decorator.cpp
// Implementation of the Class Decorator
// Created on: 03-十月-2014 18:53:01
// Original author: colin
///////////////////////////////////////////////////////////
#include "Decorator.h"
Decorator::Decorator(Component* pcmp){
m_pComponent = pcmp;
}
Decorator::~Decorator(){
}
void Decorator::operation(){
m_pComponent->operation();
}
================================================
FILE: code/Decorator/Decorator.h
================================================
///////////////////////////////////////////////////////////
// Decorator.h
// Implementation of the Class Decorator
// Created on: 03-十月-2014 18:53:00
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_1B4529AE_AF10_4b83_B1D5_40C798AFFAAA__INCLUDED_)
#define EA_1B4529AE_AF10_4b83_B1D5_40C798AFFAAA__INCLUDED_
#include "Component.h"
class Decorator : public Component
{
public:
Decorator(Component* pcmp);
virtual ~Decorator();
void operation();
private:
Component * m_pComponent;
};
#endif // !defined(EA_1B4529AE_AF10_4b83_B1D5_40C798AFFAAA__INCLUDED_)
================================================
FILE: code/Decorator/main.cfp
================================================
<Project version="3.0">
<Name>main</Name>
<Type>CUI</Type>
<TargetName>main</TargetName>
<TargetType>exe</TargetType>
<Folder name="Source Files">
<File>main.cpp</File>
</Folder>
<Folder name="Header Files">
</Folder>
<Folder name="Other Files">
</Folder>
<File>Component.cpp</File>
<File>Component.h</File>
<File>ConcreteComponent.cpp</File>
<File>ConcreteComponent.h</File>
<File>ConcreteDecoratorA.cpp</File>
<File>ConcreteDecoratorA.h</File>
<File>ConcreteDecoratorB.cpp</File>
<File>ConcreteDecoratorB.h</File>
<File>Decorator.cpp</File>
<File>Decorator.h</File>
<Attribute topline="4" x="53" y="12">main.cpp</Attribute>
<Attribute topline="16" x="2" y="27">Component.cpp</Attribute>
<Attribute topline="1" x="27" y="18">Component.h</Attribute>
<Attribute topline="7" x="28" y="8">ConcreteComponent.cpp</Attribute>
<Attribute topline="4" x="19" y="20">ConcreteComponent.h</Attribute>
<Attribute topline="13" x="2" y="30">ConcreteDecoratorA.cpp</Attribute>
<Attribute topline="10" x="25" y="14">ConcreteDecoratorA.h</Attribute>
<Attribute topline="1" x="21" y="10">ConcreteDecoratorB.cpp</Attribute>
<Attribute topline="1" x="1" y="13">ConcreteDecoratorB.h</Attribute>
<Attribute topline="7" x="1" y="16">Decorator.cpp</Attribute>
<Attribute topline="7" x="1" y="11">Decorator.h</Attribute>
<FolderState>111</FolderState>
<DefConfig>mingw5</DefConfig>
<Builder name="mingw5" type="MinGW" version="1.0">
<TargetName>main</TargetName>
<TargetType>exe</TargetType>
<TargetDir>mingw5</TargetDir>
<InterimDir>mingw5</InterimDir>
<IncPaths endslash="0">
<Path>$(CFRoot)\mingw\include</Path>
<Path>$(CFRoot)\mingw\include\c++\3.4.5</Path>
<Path>$(CFRoot)\mingw\lib\gcc\mingw32\3.4.5\include</Path>
<Pattern>*\Include</Pattern>
<Pattern>*\Include\G++</Pattern>
<Pattern>*\Include\c++\?.?.?</Pattern>
</IncPaths>
<LibPaths>
<Path>$(CFRoot)\mingw\lib</Path>
<Path>$(CFRoot)\mingw\mingw32\lib</Path>
<Pattern>*\Lib</Pattern>
</LibPaths>
<ExePaths>
<Path>$(CFRoot)\mingw\bin</Path>
<Path>$(CFRoot)\mingw\mingw32\bin</Path>
<Pattern>*\Bin</Pattern>
</ExePaths>
<AutoDetect>
<Path>$(CFRoot)\mingw</Path>
<Path>C:\MinGW</Path>
<Path>D:\MinGW</Path>
<Path>E:\MinGW</Path>
<Path>F:\MinGW</Path>
<Path>G:\MinGW</Path>
<Path>C:\Dev-Cpp</Path>
<Path>D:\Dev-Cpp</Path>
<Path>E:\Dev-Cpp</Path>
<Path>F:\Dev-Cpp</Path>
<Path>G:\Dev-Cpp</Path>
<Reg>\SOFTWARE\Dev-C++|Install_Dir</Reg>
<Reg>\SOFTWARE\CodeBlocks|Path</Reg>
<Reg>\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MinGW_is1|Inno Setup: App Path</Reg>
<Reg>\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MinGW|InstallLocation</Reg>
</AutoDetect>
<CompilerOptions>
<Category name="C++ Language">
<Option value="-fno-for-scope" desc="Variables extends to the end of the for scope [-fno-for-scop]"/>
<Option value="-fno-default-inline" desc="Do not assume `inline' inside a class scope [-fno-default-inline]"/>
<Option value="-Wold-style-cast" desc="Warn if a C-style cast is used within a C++ program [-Wold-style-cast]"/>
</Category>
<Category name="C Language">
<Option value="-std=c89" desc="Compatible with standard iso9899:1990 (ISO C89) [-std=c89]"/>
<Option value="-std=c99" desc="ISO9899:1999 (ISO C99, this standard may be not yet fully supported) [-std=c99]"/>
<Option value="-std=gnu99" desc="ISO C99 plus GNU extensions [-std=gnu99]"/>
<Option value="-fno-asm" desc="Do not recognize asm, inline or typeof as a keyword [-fno-asm]"/>
<Option value="-fallow-single-precision" desc="Don't promote single precision math operations to double precision [-fallow-single-precision]"/>
</Category>
<Category name="Debugging">
<Option value="-g" desc="Produce debugging information for use by GDB [-g]"/>
</Category>
<Category name="Warnings">
<Option value="-w" desc="Inhibit all warning messages [-w]"/>
<Option value="-Wall" desc="Enable all compiler warnings [-Wall]"/>
<Option value="-Werror" desc="Make all warnings into errors [-Werror]"/>
<Option value="-Wformat" desc="Check calls to printf and scanf, etc. [-Wformat]"/>
<Option value="-Wmain" desc="Warn if the type of `main' is suspicious [-Wmain]"/>
<Option value="-Wreturn-type" desc="Warn if a function is defined with a return-type that defaults to int [-Wreturn-type]"/>
<Option value="-Wunused" desc="Combine all the `-Wunused' options [-Wunused]"/>
<Option value="-Wfloat-equal" desc="Warn if floating point values used in equality comparisons [-Wfloat-equal]"/>
<Option value="-Wunreachable-code" desc="Warn if there is code never be executed [-Wunreachable-code]"/>
</Category>
<Category name="Optimization">
<Option value="-O" desc="Optimize (for speed) [-O]"/>
<Option value="-O1" desc="Optimize more (for speed) [-O1]"/>
<Option value="-O2" desc="Optimize even more (for speed) [-O2]"/>
<Option value="-O3" desc="Optimize fully (for speed) [-O3]"/>
<Option value="-Os" desc="Optimize (for size) [-Os]"/>
</Category>
<RawOptionsDebug enabled="1">
<Default>-g -DDEBUG</Default>
<User>-g -DDEBUG</User>
</RawOptionsDebug>
<RawOptionsRelease enabled="0">
<Default>-O2</Default>
<User>-O2</User>
</RawOptionsRelease>
</CompilerOptions>
<LinkerOptions>
<LibsDebug enabled="1">
<Default>
</Default>
<User>
</User>
</LibsDebug>
<LibsRelease enabled="0">
<Default>
</Default>
<User>
</User>
</LibsRelease>
<RawOptionsDebug enabled="1">
<Default></Default>
<User></User>
</RawOptionsDebug>
<RawOptionsRelease enabled="0">
<Default>-s</Default>
<User>-s</User>
</RawOptionsRelease>
</LinkerOptions>
<Configs>
<BuildLog enabled="0">$(CFRoot)\Build.log</BuildLog>
<LibExt>lib;a</LibExt>
<ObjExt>o;obj</ObjExt>
<ResExt>res</ResExt>
</Configs>
<Commands msghandler="Gcc.mhr">
<Command name="C Compiler" io="1" rdos="0" sys="0">
<Program enabled="1">gcc.exe</Program>
<Parameter enabled="1">"$(FileName)" -c -o "$(Path)$(Name).o" $(CompilerOptions) -I$(IncPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">c</FileExt>
<Target>$(PATH)$(NAME).o</Target>
<TargetType>o</TargetType>
<CurrentDir>$(FilePath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Compiling $(FILENAME)...#81001</MsgID>
</Command>
<Command name="C++ Compiler" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">"$(FileName)" -c -o "$(Path)$(Name).o" $(CompilerOptions) -I$(IncPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">cpp;cxx;c++;cc</FileExt>
<Target>$(PATH)$(NAME).o</Target>
<TargetType>o</TargetType>
<CurrentDir>$(FilePath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Compiling $(FILENAME)...#81001</MsgID>
</Command>
<Command name="Linker(CUI)" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">$(ProjectFiles) -l$(Libs) -o "$(Target)" $(LinkerOptions) -L$(LibPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">o;obj;a;lib;res</FileExt>
<Target>$(Target)</Target>
<TargetType>cui</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Linker(GUI)" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">$(ProjectFiles) -l$(Libs) -o "$(Target)" $(LinkerOptions) -mwindows -L$(LibPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">o;obj;a;lib;res</FileExt>
<Target>$(Target)</Target>
<TargetType>gui</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Linker for DLL" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">-shared -Wl,--output-def="$(Path)$(Name).def" -Wl,--out-implib="$(Path)$(Name).lib" -Wl,--dll -L$(LibPaths) $(ProjectFiles) -o "$(Target)" $(LinkerOptions) -l$(Libs)</Parameter>
<FileExt enabled="1">o;obj;a;lib;res;def</FileExt>
<Target>$(Target)</Target>
<TargetType>dll</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Linker for Lib" io="1" rdos="0" sys="0">
<Program enabled="1">ar.exe</Program>
<Parameter enabled="1">-r "$(Target)" $(ProjectFiles)</Parameter>
<FileExt enabled="1">o;obj</FileExt>
<Target>$(Target)</Target>
<TargetType>lib</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Resource Compiler" io="1" rdos="0" sys="0">
<Program enabled="1">windres.exe</Program>
<Parameter enabled="1">-O coff -i "$(ShortFileName)" -o "$(Path)$(Name).res" --include-dir=$(ShortPath) --include-dir=$(IncPaths)</Parameter>
<FileExt enabled="1">rc</FileExt>
<Target>$(PATH)$(NAME).res</Target>
<TargetType>res</TargetType>
<CurrentDir>$(FilePath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Compiling $(FILENAME)...#81001</MsgID>
</Command>
<Command name="Debugger" io="0" rdos="0" sys="0">
<Program enabled="0">gdb.exe</Program>
<Parameter enabled="0">gdebug.dll</Parameter>
<FileExt enabled="0">*.*</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81003</MsgID>
</Command>
<Command name="Run Exe" io="0" rdos="0" sys="0">
<Program enabled="0">$(Target)</Program>
<Parameter enabled="0">$(Parameters)</Parameter>
<FileExt enabled="1">exe</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81004</MsgID>
</Command>
<Command name="Run DLL" io="0" rdos="0" sys="0">
<Program enabled="0">$(HostApp)</Program>
<Parameter enabled="0">$(Parameters)</Parameter>
<FileExt enabled="1">dll</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81004</MsgID>
</Command>
<Command name="Run" io="0" rdos="0" sys="0">
<Program enabled="0">$(HostApp)</Program>
<Parameter enabled="0">$(Parameters)</Parameter>
<FileExt enabled="0">:exe;dll</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81004</MsgID>
</Command>
<Command name="Clean Objects" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="1">"$(Path)$(Name).o" $(FileName)</Parameter>
<FileExt enabled="1">c;cpp;cxx;c++;cc</FileExt>
<Target>$(Target)</Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
<Command name="Clean Resource" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="1">"$(Path)$(Name).res" $(FileName)</Parameter>
<FileExt enabled="1">rc</FileExt>
<Target>$(Target)</Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
<Command name="Clean Io" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="0">"$(Path)$(Name).o" -silent</Parameter>
<FileExt enabled="0">*.*</FileExt>
<Target>$(Target)</Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
<Command name="Clean Target" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="0">"$(Target)"</Parameter>
<FileExt enabled="1">*.*</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
</Commands>
<Actions>
<Action name="Compile" depend="0">
<File>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
</File>
<Project>
</Project>
<MsgID>Complete Compile $(FileName): $(Error) error(s), $(Warning) warning(s)\nGenerated $(Target)#81005</MsgID>
<ErrMsgID>Complete Compile $(FileName): $(Error) error(s), $(Warning) warning(s)#81006</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Build" depend="0">
<File>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</File>
<Project>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</Project>
<MsgID>Complete Build $(TargetName): $(Error) error(s), $(Warning) warning(s)\nGenerated $(Target)#81007</MsgID>
<ErrMsgID>Complete Build $(TargetName): $(Error) error(s), $(Warning) warning(s)#81008</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Make" depend="1">
<File>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</File>
<Project>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</Project>
<MsgID>Complete Make $(TargetName): $(Error) error(s), $(Warning) warning(s)\nGenerated $(Target)#81009</MsgID>
<ErrMsgID>Complete Make $(TargetName): $(Error) error(s), $(Warning) warning(s)#81010</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Run" depend="0">
<File>
<Action>"Make"</Action>
<Command>"Run Exe""Run DLL""Run"</Command>
</File>
<Project>
<Action>"Make"</Action>
<Command>"Run Exe""Run DLL""Run"</Command>
</Project>
<MsgID>#81011</MsgID>
<ErrMsgID>#81012</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Debug" depend="0">
<File>
<Action>"Make"</Action>
<Command>"Debugger"</Command>
</File>
<Project>
<Action>"Make"</Action>
<Command>"Debugger"</Command>
</Project>
<MsgID>#81013</MsgID>
<ErrMsgID>#81014</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Clean" depend="0">
<File>
<Command>"Clean Objects""Clean Resource"</Command>
<Command>"Clean Io"</Command>
<Command>"Clean Target"</Command>
</File>
<Project>
<Command>"Clean Objects""Clean Resource""Clean Io"</Command>
<Command>"Clean Io"</Command>
<Command>"Clean Target"</Command>
</Project>
<MsgID>Complete Clean $(TargetName)#81015</MsgID>
<ErrMsgID>Clean $(TargetName) error#81016</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
</Actions>
</Builder>
</Project>
================================================
FILE: code/Decorator/main.cfpg
================================================
<Projects version="2.0">
<Project active="1">main.cfp</Project>
<File active="1">main.cpp</File>
</Projects>
================================================
FILE: code/Decorator/main.cpp
================================================
#include <iostream>
#include "ConcreteComponent.h"
#include "ConcreteDecoratorA.h"
#include "ConcreteDecoratorB.h"
#include "Component.h"
using namespace std;
int main(int argc, char *argv[])
{
ConcreteComponent * pRealProd = new ConcreteComponent();
//̬Ϊ
Component * pA = new ConcreteDecoratorA(pRealProd);
pA->operation();
//̬Ϊ
Component * pB = new ConcreteDecoratorB(pA);
pB->operation();
delete pRealProd;
delete pA;
delete pB;
return 0;
}
================================================
FILE: code/Facade/Client.cpp
================================================
///////////////////////////////////////////////////////////
// Client.cpp
// Implementation of the Class Client
// Created on: 06-十月-2014 19:10:44
// Original author: colin
///////////////////////////////////////////////////////////
#include "Client.h"
Client::Client(){
}
Client::~Client(){
}
================================================
FILE: code/Facade/Client.h
================================================
///////////////////////////////////////////////////////////
// Client.h
// Implementation of the Class Client
// Created on: 06-十月-2014 19:10:43
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_FB09DAF1_FBE1_4f6e_BD52_72D69A9FCA56__INCLUDED_)
#define EA_FB09DAF1_FBE1_4f6e_BD52_72D69A9FCA56__INCLUDED_
class Client
{
public:
Client();
virtual ~Client();
};
#endif // !defined(EA_FB09DAF1_FBE1_4f6e_BD52_72D69A9FCA56__INCLUDED_)
================================================
FILE: code/Facade/Facade.cpp
================================================
///////////////////////////////////////////////////////////
// Facade.cpp
// Implementation of the Class Facade
// Created on: 06-十月-2014 19:10:44
// Original author: colin
///////////////////////////////////////////////////////////
#include "Facade.h"
Facade::Facade(){
m_SystemA = new SystemA();
m_SystemB = new SystemB();
m_SystemC = new SystemC();
}
Facade::~Facade(){
delete m_SystemA;
delete m_SystemB;
delete m_SystemC;
}
void Facade::wrapOpration(){
m_SystemA->operationA();
m_SystemB->operationB();
m_SystemC->opeartionC();
}
================================================
FILE: code/Facade/Facade.h
================================================
///////////////////////////////////////////////////////////
// Facade.h
// Implementation of the Class Facade
// Created on: 06-十月-2014 19:10:44
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_FD130A87_92A9_4168_9B33_7A925C47AFD5__INCLUDED_)
#define EA_FD130A87_92A9_4168_9B33_7A925C47AFD5__INCLUDED_
#include "SystemC.h"
#include "SystemA.h"
#include "SystemB.h"
class Facade
{
public:
Facade();
virtual ~Facade();
void wrapOpration();
private:
SystemC *m_SystemC;
SystemA *m_SystemA;
SystemB *m_SystemB;
};
#endif // !defined(EA_FD130A87_92A9_4168_9B33_7A925C47AFD5__INCLUDED_)
================================================
FILE: code/Facade/SystemA.cpp
================================================
///////////////////////////////////////////////////////////
// SystemA.cpp
// Implementation of the Class SystemA
// Created on: 06-十月-2014 19:10:44
// Original author: colin
///////////////////////////////////////////////////////////
#include "SystemA.h"
#include <iostream>
using namespace std;
SystemA::SystemA(){
}
SystemA::~SystemA(){
}
void SystemA::operationA(){
cout << "operationA" << endl;
}
================================================
FILE: code/Facade/SystemA.h
================================================
///////////////////////////////////////////////////////////
// SystemA.h
// Implementation of the Class SystemA
// Created on: 06-十月-2014 19:10:44
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_4EADC06E_6529_4fd1_B3B2_4C2A130E1229__INCLUDED_)
#define EA_4EADC06E_6529_4fd1_B3B2_4C2A130E1229__INCLUDED_
class SystemA
{
public:
SystemA();
virtual ~SystemA();
void operationA();
};
#endif // !defined(EA_4EADC06E_6529_4fd1_B3B2_4C2A130E1229__INCLUDED_)
================================================
FILE: code/Facade/SystemB.cpp
================================================
///////////////////////////////////////////////////////////
// SystemB.cpp
// Implementation of the Class SystemB
// Created on: 06-十月-2014 19:10:44
// Original author: colin
///////////////////////////////////////////////////////////
#include "SystemB.h"
#include <iostream>
using namespace std;
SystemB::SystemB(){
}
SystemB::~SystemB(){
}
void SystemB::operationB(){
cout << "operationB" << endl;
}
================================================
FILE: code/Facade/SystemB.h
================================================
///////////////////////////////////////////////////////////
// SystemB.h
// Implementation of the Class SystemB
// Created on: 06-十月-2014 19:10:44
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_ED8A018A_4813_445c_BEB5_3C1A9C2D458E__INCLUDED_)
#define EA_ED8A018A_4813_445c_BEB5_3C1A9C2D458E__INCLUDED_
class SystemB
{
public:
SystemB();
virtual ~SystemB();
void operationB();
};
#endif // !defined(EA_ED8A018A_4813_445c_BEB5_3C1A9C2D458E__INCLUDED_)
================================================
FILE: code/Facade/SystemC.cpp
================================================
///////////////////////////////////////////////////////////
// SystemC.cpp
// Implementation of the Class SystemC
// Created on: 06-十月-2014 19:10:44
// Original author: colin
///////////////////////////////////////////////////////////
#include "SystemC.h"
#include <iostream>
using namespace std;
SystemC::SystemC(){
}
SystemC::~SystemC(){
}
void SystemC::opeartionC(){
cout << "operationC" << endl;
}
================================================
FILE: code/Facade/SystemC.h
================================================
///////////////////////////////////////////////////////////
// SystemC.h
// Implementation of the Class SystemC
// Created on: 06-十月-2014 19:10:44
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_CC90A19E_B6A2_4247_ACCD_F39F749C19D0__INCLUDED_)
#define EA_CC90A19E_B6A2_4247_ACCD_F39F749C19D0__INCLUDED_
class SystemC
{
public:
SystemC();
virtual ~SystemC();
void opeartionC();
};
#endif // !defined(EA_CC90A19E_B6A2_4247_ACCD_F39F749C19D0__INCLUDED_)
================================================
FILE: code/Facade/main.cfp
================================================
<Project version="3.0">
<Name>main</Name>
<Type>CUI</Type>
<TargetName>main</TargetName>
<TargetType>exe</TargetType>
<Folder name="Source Files">
<File>main.cpp</File>
</Folder>
<Folder name="Header Files">
</Folder>
<Folder name="Other Files">
</Folder>
<File>Facade.cpp</File>
<File>Facade.h</File>
<File>SystemA.cpp</File>
<File>SystemA.h</File>
<File>SystemB.cpp</File>
<File>SystemB.h</File>
<File>SystemC.cpp</File>
<File>SystemC.h</File>
<Attribute topline="1" x="1" y="12">main.cpp</Attribute>
<Attribute topline="16" x="2" y="29">Facade.cpp</Attribute>
<Attribute topline="13" x="20" y="26">Facade.h</Attribute>
<Attribute topline="10" x="31" y="27">SystemA.cpp</Attribute>
<Attribute topline="7" x="1" y="1">SystemA.h</Attribute>
<Attribute topline="13" x="21" y="28">SystemB.cpp</Attribute>
<Attribute topline="10" x="21" y="27">SystemC.cpp</Attribute>
<FolderState>111</FolderState>
<DefConfig>mingw5</DefConfig>
<Builder name="mingw5" type="MinGW" version="1.0">
<TargetName>main</TargetName>
<TargetType>exe</TargetType>
<TargetDir>mingw5</TargetDir>
<InterimDir>mingw5</InterimDir>
<IncPaths endslash="0">
<Path>$(CFRoot)\mingw\include</Path>
<Path>$(CFRoot)\mingw\include\c++\3.4.5</Path>
<Path>$(CFRoot)\mingw\lib\gcc\mingw32\3.4.5\include</Path>
<Pattern>*\Include</Pattern>
<Pattern>*\Include\G++</Pattern>
<Pattern>*\Include\c++\?.?.?</Pattern>
</IncPaths>
<LibPaths>
<Path>$(CFRoot)\mingw\lib</Path>
<Path>$(CFRoot)\mingw\mingw32\lib</Path>
<Pattern>*\Lib</Pattern>
</LibPaths>
<ExePaths>
<Path>$(CFRoot)\mingw\bin</Path>
<Path>$(CFRoot)\mingw\mingw32\bin</Path>
<Pattern>*\Bin</Pattern>
</ExePaths>
<AutoDetect>
<Path>$(CFRoot)\mingw</Path>
<Path>C:\MinGW</Path>
<Path>D:\MinGW</Path>
<Path>E:\MinGW</Path>
<Path>F:\MinGW</Path>
<Path>G:\MinGW</Path>
<Path>C:\Dev-Cpp</Path>
<Path>D:\Dev-Cpp</Path>
<Path>E:\Dev-Cpp</Path>
<Path>F:\Dev-Cpp</Path>
<Path>G:\Dev-Cpp</Path>
<Reg>\SOFTWARE\Dev-C++|Install_Dir</Reg>
<Reg>\SOFTWARE\CodeBlocks|Path</Reg>
<Reg>\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MinGW_is1|Inno Setup: App Path</Reg>
<Reg>\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MinGW|InstallLocation</Reg>
</AutoDetect>
<CompilerOptions>
<Category name="C++ Language">
<Option value="-fno-for-scope" desc="Variables extends to the end of the for scope [-fno-for-scop]"/>
<Option value="-fno-default-inline" desc="Do not assume `inline' inside a class scope [-fno-default-inline]"/>
<Option value="-Wold-style-cast" desc="Warn if a C-style cast is used within a C++ program [-Wold-style-cast]"/>
</Category>
<Category name="C Language">
<Option value="-std=c89" desc="Compatible with standard iso9899:1990 (ISO C89) [-std=c89]"/>
<Option value="-std=c99" desc="ISO9899:1999 (ISO C99, this standard may be not yet fully supported) [-std=c99]"/>
<Option value="-std=gnu99" desc="ISO C99 plus GNU extensions [-std=gnu99]"/>
<Option value="-fno-asm" desc="Do not recognize asm, inline or typeof as a keyword [-fno-asm]"/>
<Option value="-fallow-single-precision" desc="Don't promote single precision math operations to double precision [-fallow-single-precision]"/>
</Category>
<Category name="Debugging">
<Option value="-g" desc="Produce debugging information for use by GDB [-g]"/>
</Category>
<Category name="Warnings">
<Option value="-w" desc="Inhibit all warning messages [-w]"/>
<Option value="-Wall" desc="Enable all compiler warnings [-Wall]"/>
<Option value="-Werror" desc="Make all warnings into errors [-Werror]"/>
<Option value="-Wformat" desc="Check calls to printf and scanf, etc. [-Wformat]"/>
<Option value="-Wmain" desc="Warn if the type of `main' is suspicious [-Wmain]"/>
<Option value="-Wreturn-type" desc="Warn if a function is defined with a return-type that defaults to int [-Wreturn-type]"/>
<Option value="-Wunused" desc="Combine all the `-Wunused' options [-Wunused]"/>
<Option value="-Wfloat-equal" desc="Warn if floating point values used in equality comparisons [-Wfloat-equal]"/>
<Option value="-Wunreachable-code" desc="Warn if there is code never be executed [-Wunreachable-code]"/>
</Category>
<Category name="Optimization">
<Option value="-O" desc="Optimize (for speed) [-O]"/>
<Option value="-O1" desc="Optimize more (for speed) [-O1]"/>
<Option value="-O2" desc="Optimize even more (for speed) [-O2]"/>
<Option value="-O3" desc="Optimize fully (for speed) [-O3]"/>
<Option value="-Os" desc="Optimize (for size) [-Os]"/>
</Category>
<RawOptionsDebug enabled="1">
<Default>-g -DDEBUG</Default>
<User>-g -DDEBUG</User>
</RawOptionsDebug>
<RawOptionsRelease enabled="0">
<Default>-O2</Default>
<User>-O2</User>
</RawOptionsRelease>
</CompilerOptions>
<LinkerOptions>
<LibsDebug enabled="1">
<Default>
</Default>
<User>
</User>
</LibsDebug>
<LibsRelease enabled="0">
<Default>
</Default>
<User>
</User>
</LibsRelease>
<RawOptionsDebug enabled="1">
<Default></Default>
<User></User>
</RawOptionsDebug>
<RawOptionsRelease enabled="0">
<Default>-s</Default>
<User>-s</User>
</RawOptionsRelease>
</LinkerOptions>
<Configs>
<BuildLog enabled="0">$(CFRoot)\Build.log</BuildLog>
<LibExt>lib;a</LibExt>
<ObjExt>o;obj</ObjExt>
<ResExt>res</ResExt>
</Configs>
<Commands msghandler="Gcc.mhr">
<Command name="C Compiler" io="1" rdos="0" sys="0">
<Program enabled="1">gcc.exe</Program>
<Parameter enabled="1">"$(FileName)" -c -o "$(Path)$(Name).o" $(CompilerOptions) -I$(IncPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">c</FileExt>
<Target>$(PATH)$(NAME).o</Target>
<TargetType>o</TargetType>
<CurrentDir>$(FilePath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Compiling $(FILENAME)...#81001</MsgID>
</Command>
<Command name="C++ Compiler" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">"$(FileName)" -c -o "$(Path)$(Name).o" $(CompilerOptions) -I$(IncPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">cpp;cxx;c++;cc</FileExt>
<Target>$(PATH)$(NAME).o</Target>
<TargetType>o</TargetType>
<CurrentDir>$(FilePath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Compiling $(FILENAME)...#81001</MsgID>
</Command>
<Command name="Linker(CUI)" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">$(ProjectFiles) -l$(Libs) -o "$(Target)" $(LinkerOptions) -L$(LibPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">o;obj;a;lib;res</FileExt>
<Target>$(Target)</Target>
<TargetType>cui</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Linker(GUI)" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">$(ProjectFiles) -l$(Libs) -o "$(Target)" $(LinkerOptions) -mwindows -L$(LibPaths) -B$(ExePaths)</Parameter>
<FileExt enabled="1">o;obj;a;lib;res</FileExt>
<Target>$(Target)</Target>
<TargetType>gui</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Linker for DLL" io="1" rdos="0" sys="0">
<Program enabled="1">g++.exe</Program>
<Parameter enabled="1">-shared -Wl,--output-def="$(Path)$(Name).def" -Wl,--out-implib="$(Path)$(Name).lib" -Wl,--dll -L$(LibPaths) $(ProjectFiles) -o "$(Target)" $(LinkerOptions) -l$(Libs)</Parameter>
<FileExt enabled="1">o;obj;a;lib;res;def</FileExt>
<Target>$(Target)</Target>
<TargetType>dll</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Linker for Lib" io="1" rdos="0" sys="0">
<Program enabled="1">ar.exe</Program>
<Parameter enabled="1">-r "$(Target)" $(ProjectFiles)</Parameter>
<FileExt enabled="1">o;obj</FileExt>
<Target>$(Target)</Target>
<TargetType>lib</TargetType>
<CurrentDir>$(ProjectPath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Linking...#81002</MsgID>
</Command>
<Command name="Resource Compiler" io="1" rdos="0" sys="0">
<Program enabled="1">windres.exe</Program>
<Parameter enabled="1">-O coff -i "$(ShortFileName)" -o "$(Path)$(Name).res" --include-dir=$(ShortPath) --include-dir=$(IncPaths)</Parameter>
<FileExt enabled="1">rc</FileExt>
<Target>$(PATH)$(NAME).res</Target>
<TargetType>res</TargetType>
<CurrentDir>$(FilePath)</CurrentDir>
<EnvVar></EnvVar>
<MsgID>Compiling $(FILENAME)...#81001</MsgID>
</Command>
<Command name="Debugger" io="0" rdos="0" sys="0">
<Program enabled="0">gdb.exe</Program>
<Parameter enabled="0">gdebug.dll</Parameter>
<FileExt enabled="0">*.*</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81003</MsgID>
</Command>
<Command name="Run Exe" io="0" rdos="0" sys="0">
<Program enabled="0">$(Target)</Program>
<Parameter enabled="0">$(Parameters)</Parameter>
<FileExt enabled="1">exe</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81004</MsgID>
</Command>
<Command name="Run DLL" io="0" rdos="0" sys="0">
<Program enabled="0">$(HostApp)</Program>
<Parameter enabled="0">$(Parameters)</Parameter>
<FileExt enabled="1">dll</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81004</MsgID>
</Command>
<Command name="Run" io="0" rdos="0" sys="0">
<Program enabled="0">$(HostApp)</Program>
<Parameter enabled="0">$(Parameters)</Parameter>
<FileExt enabled="0">:exe;dll</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID>#81004</MsgID>
</Command>
<Command name="Clean Objects" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="1">"$(Path)$(Name).o" $(FileName)</Parameter>
<FileExt enabled="1">c;cpp;cxx;c++;cc</FileExt>
<Target>$(Target)</Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
<Command name="Clean Resource" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="1">"$(Path)$(Name).res" $(FileName)</Parameter>
<FileExt enabled="1">rc</FileExt>
<Target>$(Target)</Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
<Command name="Clean Io" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="0">"$(Path)$(Name).o" -silent</Parameter>
<FileExt enabled="0">*.*</FileExt>
<Target>$(Target)</Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
<Command name="Clean Target" io="1" rdos="0" sys="0">
<Program enabled="0">fdel.exe</Program>
<Parameter enabled="0">"$(Target)"</Parameter>
<FileExt enabled="1">*.*</FileExt>
<Target></Target>
<TargetType></TargetType>
<CurrentDir></CurrentDir>
<EnvVar></EnvVar>
<MsgID></MsgID>
</Command>
</Commands>
<Actions>
<Action name="Compile" depend="0">
<File>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
</File>
<Project>
</Project>
<MsgID>Complete Compile $(FileName): $(Error) error(s), $(Warning) warning(s)\nGenerated $(Target)#81005</MsgID>
<ErrMsgID>Complete Compile $(FileName): $(Error) error(s), $(Warning) warning(s)#81006</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Build" depend="0">
<File>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</File>
<Project>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</Project>
<MsgID>Complete Build $(TargetName): $(Error) error(s), $(Warning) warning(s)\nGenerated $(Target)#81007</MsgID>
<ErrMsgID>Complete Build $(TargetName): $(Error) error(s), $(Warning) warning(s)#81008</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Make" depend="1">
<File>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</File>
<Project>
<Command>"C Compiler""C++ Compiler""Resource Compiler"</Command>
<Command>"Linker(CUI)""Linker(GUI)""Linker for DLL""Linker for Lib"</Command>
</Project>
<MsgID>Complete Make $(TargetName): $(Error) error(s), $(Warning) warning(s)\nGenerated $(Target)#81009</MsgID>
<ErrMsgID>Complete Make $(TargetName): $(Error) error(s), $(Warning) warning(s)#81010</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Run" depend="0">
<File>
<Action>"Make"</Action>
<Command>"Run Exe""Run DLL""Run"</Command>
</File>
<Project>
<Action>"Make"</Action>
<Command>"Run Exe""Run DLL""Run"</Command>
</Project>
<MsgID>#81011</MsgID>
<ErrMsgID>#81012</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Debug" depend="0">
<File>
<Action>"Make"</Action>
<Command>"Debugger"</Command>
</File>
<Project>
<Action>"Make"</Action>
<Command>"Debugger"</Command>
</Project>
<MsgID>#81013</MsgID>
<ErrMsgID>#81014</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
<Action name="Clean" depend="0">
<File>
<Command>"Clean Objects""Clean Resource"</Command>
<Command>"Clean Io"</Command>
<Command>"Clean Target"</Command>
</File>
<Project>
<Command>"Clean Objects""Clean Resource""Clean Io"</Command>
<Command>"Clean Io"</Command>
<Command>"Clean Target"</Command>
</Project>
<MsgID>Complete Clean $(TargetName)#81015</MsgID>
<ErrMsgID>Clean $(TargetName) error#81016</ErrMsgID>
<PreAction></PreAction>
<PostAction con="0"></PostAction>
</Action>
</Actions>
</Builder>
</Project>
================================================
FILE: code/Facade/main.cfpg
================================================
<Projects version="2.0">
<Project active="1">main.cfp</Project>
<File active="1">main.cpp</File>
</Projects>
================================================
FILE: code/Facade/main.cpp
================================================
#include <iostream>
#include "Facade.h"
using namespace std;
int main(int argc, char *argv[])
{
Facade fa;
fa.wrapOpration();
return 0;
}
================================================
FILE: code/FactoryMethod/Client.cpp
================================================
///////////////////////////////////////////////////////////
// Client.cpp
// Implementation of the Class Client
// Created on: 02-十月-2014 10:18:58
// Original author: cl
///////////////////////////////////////////////////////////
#include "Client.h"
Client::Client(){
}
Client::~Client(){
}
================================================
FILE: code/FactoryMethod/Client.h
================================================
///////////////////////////////////////////////////////////
// Client.h
// Implementation of the Class Client
// Created on: 02-十月-2014 10:18:58
// Original author: cl
///////////////////////////////////////////////////////////
#if !defined(EA_18EFCEE9_550F_4132_986C_CB1894F63B40__INCLUDED_)
#define EA_18EFCEE9_550F_4132_986C_CB1894F63B40__INCLUDED_
class Client
{
public:
Client();
virtual ~Client();
};
#endif // !defined(EA_18EFCEE9_550F_4132_986C_CB1894F63B40__INCLUDED_)
================================================
FILE: code/FactoryMethod/ConcreteFactory.cpp
================================================
///////////////////////////////////////////////////////////
// ConcreteFactory.cpp
// Implementation of the Class ConcreteFactory
// Created on: 02-十月-2014 10:18:58
// Original author: colin
///////////////////////////////////////////////////////////
#include "ConcreteFactory.h"
#include "ConcreteProduct.h"
ConcreteFactory::ConcreteFactory(){
}
ConcreteFactory::~ConcreteFactory(){
}
Product* ConcreteFactory::factoryMethod(){
return new ConcreteProduct();
}
================================================
FILE: code/FactoryMethod/ConcreteFactory.h
================================================
///////////////////////////////////////////////////////////
// ConcreteFactory.h
// Implementation of the Class ConcreteFactory
// Created on: 02-十月-2014 10:18:58
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_99AEC7F3_304D_41c6_A35C_A81D7E5B280F__INCLUDED_)
#define EA_99AEC7F3_304D_41c6_A35C_A81D7E5B280F__INCLUDED_
#include "Product.h"
#include "Factory.h"
class ConcreteFactory : public Factory
{
public:
ConcreteFactory();
virtual ~ConcreteFactory();
virtual Product* factoryMethod();
};
#endif // !defined(EA_99AEC7F3_304D_41c6_A35C_A81D7E5B280F__INCLUDED_)
================================================
FILE: code/FactoryMethod/ConcreteProduct.cpp
================================================
///////////////////////////////////////////////////////////
// ConcreteProduct.cpp
// Implementation of the Class ConcreteProduct
// Created on: 02-十月-2014 10:18:58
// Original author: colin
///////////////////////////////////////////////////////////
#include "ConcreteProduct.h"
#include <iostream>
using namespace std;
ConcreteProduct::ConcreteProduct(){
}
ConcreteProduct::~ConcreteProduct(){
}
void ConcreteProduct::use(){
cout << "use prodect A" << endl;
}
================================================
FILE: code/FactoryMethod/ConcreteProduct.h
================================================
///////////////////////////////////////////////////////////
// ConcreteProduct.h
// Implementation of the Class ConcreteProduct
// Created on: 02-十月-2014 10:18:58
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_EF9F81B2_79BC_4b45_BB45_60E30EE545C4__INCLUDED_)
#define EA_EF9F81B2_79BC_4b45_BB45_60E30EE545C4__INCLUDED_
#include "Product.h"
class ConcreteProduct : public Product
{
public:
ConcreteProduct();
virtual ~ConcreteProduct();
virtual void use();
};
#endif // !defined(EA_EF9F81B2_79BC_4b45_BB45_60E30EE545C4__INCLUDED_)
================================================
FILE: code/FactoryMethod/Factory.cpp
================================================
///////////////////////////////////////////////////////////
// Factory.cpp
// Implementation of the Class Factory
// Created on: 02-十月-2014 10:18:59
// Original author: colin
///////////////////////////////////////////////////////////
#include "Factory.h"
#include<stdio.h>
Factory::Factory(){
}
Factory::~Factory(){
}
Product* Factory::factoryMethod(){
return NULL;
}
================================================
FILE: code/FactoryMethod/Factory.h
================================================
///////////////////////////////////////////////////////////
// Factory.h
// Implementation of the Class Factory
// Created on: 02-十月-2014 10:18:59
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_BB1E9945_CCF9_4d5c_8B7D_C3D86C0C2856__INCLUDED_)
#define EA_BB1E9945_CCF9_4d5c_8B7D_C3D86C0C2856__INCLUDED_
#include "Product.h"
class Factory
{
public:
Factory();
virtual ~Factory();
virtual Product* factoryMethod();
};
#endif // !defined(EA_BB1E9945_CCF9_4d5c_8B7D_C3D86C0C2856__INCLUDED_)
================================================
FILE: code/FactoryMethod/Product.cpp
================================================
///////////////////////////////////////////////////////////
// Product.cpp
// Implementation of the Class Product
// Created on: 02-十月-2014 10:19:00
// Original author: colin
///////////////////////////////////////////////////////////
#include "Product.h"
Product::Product(){
}
Product::~Product(){
}
void Product::use(){
}
================================================
FILE: code/FactoryMethod/Product.h
================================================
///////////////////////////////////////////////////////////
// Product.h
// Implementation of the Class Product
// Created on: 02-十月-2014 10:19:00
// Original author: colin
///////////////////////////////////////////////////////////
#if !defined(EA_071D24B8_F0A3_4f19_955A_8F5511036EF0__INCLUDED_)
#define EA_071D24B8_F0A3_4f19_955A_8F5511036EF0__INCLUDED_
class Product
{
public:
Product();
virtual ~Product();
virtual void use();
};
#endif // !defined(EA_071D24B8_F0A3_4f19_955A_8F5511036EF0__INCLUDED_)
================================================
FILE: code/FactoryMethod/main.cfp
================================================
<Project version="3.0">
<Name>main</Name>
<Type>CUI</Type>
<TargetName>main</TargetName>
<TargetType>exe</TargetType>
<Folder name="Source Files">
<File>main.cpp</File>
</Folder>
<Folder name="Header Files">
</Folder>
<Folder name="Other Files">
</Folder>
<File>Client.cpp</File>
<File>Client.h</File>
<File>ConcreteFactory.cpp</File>
<File>ConcreteFactory.h</File>
<File>ConcreteProduct.cpp</File>
<File>ConcreteProduct.h</File>
<File>Factory.cpp</File>
<File>Factory.h</File>
<File>Product.cpp</File>
<File>Product.h</File>
<Attribute topline="1" x="2" y="12">main.cpp</Attribute>
<Attribute topline="4" x="1" y="21">ConcreteFactory.cpp</Attribute>
<Attribute topline="10" x="27" y="21">ConcreteFactory.h</Attribute>
<Attribute topline="13" x="1" y="26">ConcreteProduct.cpp</Attribute>
<Attribute topline="4" x="1" y="1">ConcreteProduct.h</Attribute>
<Attribute topline="14" x="1" y="25">Factory.cpp</Attribute>
<Attribute topline="1" x="10" y="20">Factory.h</Attribute>
<Attribute topline="1" x="21" y="18">Product.h</Attribute>
<FolderState>111</FolderState>
<DefConfig>mingw5</DefConfig>
<Builder name="mingw5" type="MinGW" version="1.0">
<TargetName>main</TargetName>
<TargetType>exe</TargetType>
<TargetDir>mingw5</TargetDir>
<InterimDir>mingw5</InterimDir>
<IncPaths endslash="0">
<Path>$(CFRoot)\mingw\include</Path>
<Path>$(CFRoot)\mingw\include\c++\3.4.5</Path>
<Path>$(CFRoot)\mingw\lib\gcc\mingw32\3.4.5\include</Path>
<Pattern>*\Include</Pattern>
<Pattern>*\Include\G++</Pattern>
<Pattern>*\Include\c++\?.?.?</Pattern>
</IncPaths>
<LibPaths>
<Path>$(CFRoot)\mingw\lib</Path>
<Path>$(CFRoot)\mingw\mingw32\lib</Path>
<Pattern>*\Lib</Pattern>
</LibPaths>
<ExePaths>
<Path>$(CFRoot)\mingw\bin</Path>
<Path>$(CFRoot)\mingw\mingw32\bin</Path>
<Pattern>*\Bin</Pattern>
</ExePaths>
<AutoDetect>
<Path>$(CFRoot)\mingw</Path>
<Path>C:\MinGW</Path>
<Path>D:\MinGW</Path>
<Path>E:\MinGW</Path>
<Path>F:\MinGW</Path>
<Path>G:\MinGW</Path>
<Path>C:\Dev-Cpp</Path>
<Path>D:\Dev-Cpp</Path>
<Path>E:\Dev-Cpp</Path>
<Path>F:\Dev-Cpp</Path>
<Path>G:\Dev-Cpp</Path>
<Reg>\SOFTWARE\Dev-C++|Install_Dir</Reg>
<Reg>\SOFTWARE\CodeBlocks|Path</Reg>
<Reg>\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MinGW_is1|Inno Setup: App Path</Reg>
<Reg>\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MinGW|InstallLocation</Reg>
</AutoDetect>
<CompilerOptions>
<Category name="C++ Language">
<Option value="-fno-for-scope" desc="Variables extends to the end of the for scope [-fno-for-scop]"/>
<Option value="-fno-default-inline" desc="Do not assume `inline' inside a class scope [-fno-default-inline]"/>
<Option value="-Wold-style-cast" desc="Warn if a C-style cast is used within a C++ program [-Wold-style-cast]"/>
</Category>
<Category name="C Language">
<Option value="-std=c89" desc="Compatible with standard iso9899:1990 (ISO C89) [-std=c89]"/>
<Option value="-std=c99" desc="ISO9899:1999 (ISO C99, this standard may be not yet fully supported) [-std=c99]"/>
<Option value="-std=gnu99" desc="ISO C99 plus GNU extensions [-std=gnu99]"/>
<Option value="-fno-asm" desc="Do not recognize asm, inline or typeof as a keyword [-fno-asm]"/>
<Option value="-fallow-single-precision" desc="Don't promote single precision math operations to double precision [-fallow-single-precision]"/>
</Category>
<Category name="Debugging">
<Option value="-g" desc="Produce debugging information for use by GDB [-g]"/>
</Category>
<Category name="Warnings">
<Option value="-w" desc="Inhibit all warning messages [-w]"/>
<Option value="-Wall" desc="Enable all compiler warnings [-Wall]"/>
<Option value="-Werror" desc="Make all warnings into errors [-Werror]"/>
<Option value="-Wformat" desc="Check calls to printf and scanf, etc. [-Wformat]"/>
<Option value="-Wmain" desc="Warn if the type of `main' is suspicious [-Wmain]"/>
<Option value="-Wreturn-type" desc="Warn if a function is defined with a return-type that defaults to int [-Wreturn-type]"/>
<Option value="-Wunused" desc="Combine all the `-Wunused' options [-Wunused]"/>
<Option value="-Wfloat-equal" desc="Warn if floating point values used in equality comparisons [-Wfloat-equal]"/>
<Option value="-Wunreachable-code" desc="Warn if there is code never be executed [-Wunreachable-code]"/>
</Category>
<Category name="Optimization">
<Option value="-O" desc="Optimize (for speed) [-O]"/>
<Option value="-O1" desc="Optimize more (for speed) [-O1]"/>
<Option value="-O2" desc="Optimize even more (for speed) [-O2]"/>
<Option value="-O3" desc="Optimize fully (for speed) [-O3]"/>
<Option value="-Os" desc="Optimize (for size) [-Os]"/>
</Category>
<RawOptionsDebug enabled="1">
<Default>-
gitextract_qiu8ox4r/
├── .gitattributes
├── .gitignore
├── LICENSE
├── Makefile
├── behavioral_patterns/
│ ├── behavioral.rst
│ ├── command.rst
│ ├── mediator.rst
│ ├── observer.rst
│ ├── state.rst
│ └── strategy.rst
├── code/
│ ├── AbstractFactory/
│ │ ├── AbstractFactory.cpp
│ │ ├── AbstractFactory.h
│ │ ├── AbstractProductA.cpp
│ │ ├── AbstractProductA.h
│ │ ├── AbstractProductB.cpp
│ │ ├── AbstractProductB.h
│ │ ├── ConcreteFactory1.cpp
│ │ ├── ConcreteFactory1.h
│ │ ├── ConcreteFactory2.cpp
│ │ ├── ConcreteFactory2.h
│ │ ├── ProductA1.cpp
│ │ ├── ProductA1.h
│ │ ├── ProductA2.cpp
│ │ ├── ProductA2.h
│ │ ├── ProductB1.cpp
│ │ ├── ProductB1.h
│ │ ├── ProductB2.cpp
│ │ ├── ProductB2.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── AbstractFactory.o
│ │ ├── AbstractProductA.o
│ │ ├── AbstractProductB.o
│ │ ├── ConcreteFactory1.o
│ │ ├── ConcreteFactory2.o
│ │ ├── ProductA1.o
│ │ ├── ProductA2.o
│ │ ├── ProductB1.o
│ │ ├── ProductB2.o
│ │ └── main.o
│ ├── Adapter/
│ │ ├── Adaptee.cpp
│ │ ├── Adaptee.h
│ │ ├── Adapter.cpp
│ │ ├── Adapter.h
│ │ ├── Client.cpp
│ │ ├── Client.h
│ │ ├── Target.cpp
│ │ ├── Target.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── Adaptee.o
│ │ ├── Adapter.o
│ │ ├── Target.o
│ │ └── main.o
│ ├── Bridge/
│ │ ├── Abstraction.cpp
│ │ ├── Abstraction.h
│ │ ├── ConcreteImplementorA.cpp
│ │ ├── ConcreteImplementorA.h
│ │ ├── ConcreteImplementorB.cpp
│ │ ├── ConcreteImplementorB.h
│ │ ├── Implementor.cpp
│ │ ├── Implementor.h
│ │ ├── RefinedAbstraction.cpp
│ │ ├── RefinedAbstraction.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── Abstraction.o
│ │ ├── ConcreteImplementorA.o
│ │ ├── ConcreteImplementorB.o
│ │ ├── Implementor.o
│ │ ├── RefinedAbstraction.o
│ │ └── main.o
│ ├── Builder/
│ │ ├── Builder.cpp
│ │ ├── Builder.h
│ │ ├── ConcreteBuilder.cpp
│ │ ├── ConcreteBuilder.h
│ │ ├── Director.cpp
│ │ ├── Director.h
│ │ ├── Product.cpp
│ │ ├── Product.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── Builder.o
│ │ ├── ConcreteBuilder.o
│ │ ├── Director.o
│ │ ├── Product.o
│ │ └── main.o
│ ├── Command/
│ │ ├── Command.cpp
│ │ ├── Command.h
│ │ ├── ConcreteCommand.cpp
│ │ ├── ConcreteCommand.h
│ │ ├── Invoker.cpp
│ │ ├── Invoker.h
│ │ ├── Receiver.cpp
│ │ ├── Receiver.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── Command.o
│ │ ├── ConcreteCommand.o
│ │ ├── Invoker.o
│ │ ├── Receiver.o
│ │ └── main.o
│ ├── Decorator/
│ │ ├── Component.cpp
│ │ ├── Component.h
│ │ ├── ConcreteComponent.cpp
│ │ ├── ConcreteComponent.h
│ │ ├── ConcreteDecoratorA.cpp
│ │ ├── ConcreteDecoratorA.h
│ │ ├── ConcreteDecoratorB.cpp
│ │ ├── ConcreteDecoratorB.h
│ │ ├── Decorator.cpp
│ │ ├── Decorator.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── Component.o
│ │ ├── ConcreteComponent.o
│ │ ├── ConcreteDecoratorA.o
│ │ ├── ConcreteDecoratorB.o
│ │ ├── Decorator.o
│ │ └── main.o
│ ├── Facade/
│ │ ├── Client.cpp
│ │ ├── Client.h
│ │ ├── Facade.cpp
│ │ ├── Facade.h
│ │ ├── SystemA.cpp
│ │ ├── SystemA.h
│ │ ├── SystemB.cpp
│ │ ├── SystemB.h
│ │ ├── SystemC.cpp
│ │ ├── SystemC.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── Facade.o
│ │ ├── SystemA.o
│ │ ├── SystemB.o
│ │ ├── SystemC.o
│ │ └── main.o
│ ├── FactoryMethod/
│ │ ├── Client.cpp
│ │ ├── Client.h
│ │ ├── ConcreteFactory.cpp
│ │ ├── ConcreteFactory.h
│ │ ├── ConcreteProduct.cpp
│ │ ├── ConcreteProduct.h
│ │ ├── Factory.cpp
│ │ ├── Factory.h
│ │ ├── Product.cpp
│ │ ├── Product.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── Client.o
│ │ ├── ConcreteFactory.o
│ │ ├── ConcreteProduct.o
│ │ ├── Factory.o
│ │ ├── Product.o
│ │ └── main.o
│ ├── Flyweight/
│ │ ├── ConcreteFlyweight.cpp
│ │ ├── ConcreteFlyweight.h
│ │ ├── Flyweight.cpp
│ │ ├── Flyweight.h
│ │ ├── FlyweightFactory.cpp
│ │ ├── FlyweightFactory.h
│ │ ├── UnsharedConcreteFlyweight.cpp
│ │ ├── UnsharedConcreteFlyweight.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── ConcreteFlyweight.o
│ │ ├── Flyweight.o
│ │ ├── FlyweightFactory.o
│ │ └── main.o
│ ├── Mediator/
│ │ ├── Colleague.cpp
│ │ ├── Colleague.h
│ │ ├── ConcreteColleagueA.cpp
│ │ ├── ConcreteColleagueA.h
│ │ ├── ConcreteColleagueB.cpp
│ │ ├── ConcreteColleagueB.h
│ │ ├── ConcreteMediator.cpp
│ │ ├── ConcreteMediator.h
│ │ ├── Mediator.cpp
│ │ ├── Mediator.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── Colleague.o
│ │ ├── ConcreteColleagueA.o
│ │ ├── ConcreteColleagueB.o
│ │ ├── ConcreteMediator.o
│ │ ├── Mediator.o
│ │ └── main.o
│ ├── Obeserver/
│ │ ├── ConcreteObeserver.cpp
│ │ ├── ConcreteObeserver.h
│ │ ├── ConcreteSubject.cpp
│ │ ├── ConcreteSubject.h
│ │ ├── Obeserver.cpp
│ │ ├── Obeserver.h
│ │ ├── Subject.cpp
│ │ ├── Subject.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── ConcreteObeserver.o
│ │ ├── ConcreteSubject.o
│ │ ├── Obeserver.o
│ │ ├── Subject.o
│ │ └── main.o
│ ├── Proxy/
│ │ ├── Proxy.cpp
│ │ ├── Proxy.h
│ │ ├── RealSubject.cpp
│ │ ├── RealSubject.h
│ │ ├── Subject.cpp
│ │ ├── Subject.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── Proxy.o
│ │ ├── RealSubject.o
│ │ ├── Subject.o
│ │ └── main.o
│ ├── SimpleFactory/
│ │ ├── ConcreteProductA.cpp
│ │ ├── ConcreteProductA.h
│ │ ├── ConcreteProductB.cpp
│ │ ├── ConcreteProductB.h
│ │ ├── Factory.cpp
│ │ ├── Factory.h
│ │ ├── Product.cpp
│ │ ├── Product.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── ConcreteProductA.o
│ │ ├── ConcreteProductB.o
│ │ ├── Factory.o
│ │ ├── Product.o
│ │ └── main.o
│ ├── Singleton/
│ │ ├── Singleton.cpp
│ │ ├── Singleton.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── Singleton.o
│ │ └── main.o
│ ├── State/
│ │ ├── ConcreteStateA.cpp
│ │ ├── ConcreteStateA.h
│ │ ├── ConcreteStateB.cpp
│ │ ├── ConcreteStateB.h
│ │ ├── Context.cpp
│ │ ├── Context.h
│ │ ├── State.cpp
│ │ ├── State.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ └── mingw5/
│ │ ├── ConcreteStateA.o
│ │ ├── ConcreteStateB.o
│ │ ├── Context.o
│ │ ├── State.o
│ │ └── main.o
│ ├── Strategy/
│ │ ├── ConcreteStrategyA.cpp
│ │ ├── ConcreteStrategyA.h
│ │ ├── ConcreteStrategyB.cpp
│ │ ├── ConcreteStrategyB.h
│ │ ├── Context.cpp
│ │ ├── Context.h
│ │ ├── Strategy.cpp
│ │ ├── Strategy.h
│ │ ├── main.cfp
│ │ ├── main.cfpg
│ │ ├── main.cpp
│ │ ├── main.o
│ │ └── mingw5/
│ │ ├── ConcreteStrategyA.o
│ │ ├── ConcreteStrategyB.o
│ │ ├── Context.o
│ │ ├── Strategy.o
│ │ └── main.o
│ └── main/
│ ├── main.cfp
│ ├── main.cfpg
│ └── main.cpp
├── conf.py
├── creational_patterns/
│ ├── abstract_factory.rst
│ ├── builder.rst
│ ├── creational.rst
│ ├── factory_method.rst
│ ├── simple_factory.rst
│ └── singleton.rst
├── design_patterns.EAP
├── dp_tmp.txt
├── index.rst
├── make.bat
├── read_uml.rst
├── readme.rst
├── sphinx_rtd_theme/
│ ├── __init__.py
│ ├── breadcrumbs.html
│ ├── footer.html
│ ├── layout.html
│ ├── layout_old.html
│ ├── search.html
│ ├── searchbox.html
│ ├── static/
│ │ ├── css/
│ │ │ ├── badge_only.css
│ │ │ ├── font_lato_googleapi.css
│ │ │ └── theme.css
│ │ ├── fonts/
│ │ │ └── FontAwesome.otf
│ │ └── js/
│ │ └── theme.js
│ ├── theme.conf
│ └── versions.html
├── state_diagram.vsd
└── structural_patterns/
├── adapter.rst
├── bridge.rst
├── decorator.rst
├── facade.rst
├── flyweight.rst
├── proxy.rst
└── structural.rst
SYMBOL INDEX (101 symbols across 99 files)
FILE: code/AbstractFactory/AbstractFactory.h
function class (line 13) | class AbstractFactory
FILE: code/AbstractFactory/AbstractProductA.h
function class (line 11) | class AbstractProductA
FILE: code/AbstractFactory/AbstractProductB.h
function class (line 11) | class AbstractProductB
FILE: code/AbstractFactory/ConcreteFactory1.cpp
function AbstractProductA (line 21) | AbstractProductA * ConcreteFactory1::createProductA(){
function AbstractProductB (line 26) | AbstractProductB * ConcreteFactory1::createProductB(){
FILE: code/AbstractFactory/ConcreteFactory1.h
function class (line 16) | class ConcreteFactory1 : public AbstractFactory
FILE: code/AbstractFactory/ConcreteFactory2.cpp
function AbstractProductA (line 21) | AbstractProductA * ConcreteFactory2::createProductA(){
function AbstractProductB (line 26) | AbstractProductB * ConcreteFactory2::createProductB(){
FILE: code/AbstractFactory/ConcreteFactory2.h
function class (line 15) | class ConcreteFactory2 : public AbstractFactory
FILE: code/AbstractFactory/ProductA1.h
function class (line 13) | class ProductA1 : public AbstractProductA
FILE: code/AbstractFactory/ProductA2.h
function class (line 13) | class ProductA2 : public AbstractProductA
FILE: code/AbstractFactory/ProductB1.h
function class (line 13) | class ProductB1 : public AbstractProductB
FILE: code/AbstractFactory/ProductB2.h
function class (line 13) | class ProductB2 : public AbstractProductB
FILE: code/AbstractFactory/main.cpp
function main (line 9) | int main(int argc, char *argv[])
FILE: code/Adapter/Adaptee.h
function class (line 11) | class Adaptee
FILE: code/Adapter/Adapter.h
function class (line 14) | class Adapter : public Target
FILE: code/Adapter/Client.h
function class (line 11) | class Client
FILE: code/Adapter/Target.h
function class (line 11) | class Target
FILE: code/Adapter/main.cpp
function main (line 8) | int main(int argc, char *argv[])
FILE: code/Bridge/Abstraction.h
function class (line 13) | class Abstraction
FILE: code/Bridge/ConcreteImplementorA.h
function class (line 13) | class ConcreteImplementorA : public Implementor
FILE: code/Bridge/ConcreteImplementorB.h
function class (line 13) | class ConcreteImplementorB : public Implementor
FILE: code/Bridge/Implementor.h
function class (line 11) | class Implementor
FILE: code/Bridge/RefinedAbstraction.h
function class (line 13) | class RefinedAbstraction : public Abstraction
FILE: code/Bridge/main.cpp
function main (line 9) | int main(int argc, char *argv[])
FILE: code/Builder/Builder.cpp
function Product (line 40) | Product* Builder::getResult(){
FILE: code/Builder/Builder.h
function class (line 12) | class Builder
FILE: code/Builder/ConcreteBuilder.h
function class (line 13) | class ConcreteBuilder : public Builder
FILE: code/Builder/Director.cpp
function Product (line 16) | Product* Director::constuct(){
FILE: code/Builder/Director.h
function class (line 13) | class Director
FILE: code/Builder/Product.h
function class (line 13) | class Product
FILE: code/Builder/main.cpp
function main (line 9) | int main(int argc, char *argv[])
FILE: code/Command/Command.h
function class (line 11) | class Command
FILE: code/Command/ConcreteCommand.h
function class (line 14) | class ConcreteCommand : public Command
FILE: code/Command/Invoker.h
function class (line 13) | class Invoker
FILE: code/Command/Receiver.h
function class (line 11) | class Receiver
FILE: code/Command/main.cpp
function main (line 8) | int main(int argc, char *argv[])
FILE: code/Decorator/Component.h
function class (line 11) | class Component
FILE: code/Decorator/ConcreteComponent.h
function class (line 13) | class ConcreteComponent : public Component
FILE: code/Decorator/ConcreteDecoratorA.h
function class (line 14) | class ConcreteDecoratorA : public Decorator
FILE: code/Decorator/ConcreteDecoratorB.h
function class (line 14) | class ConcreteDecoratorB : public Decorator
FILE: code/Decorator/Decorator.h
function class (line 13) | class Decorator : public Component
FILE: code/Decorator/main.cpp
function main (line 8) | int main(int argc, char *argv[])
FILE: code/Facade/Client.h
function class (line 11) | class Client
FILE: code/Facade/Facade.h
function class (line 15) | class Facade
FILE: code/Facade/SystemA.h
function class (line 11) | class SystemA
FILE: code/Facade/SystemB.h
function class (line 11) | class SystemB
FILE: code/Facade/SystemC.h
function class (line 11) | class SystemC
FILE: code/Facade/main.cpp
function main (line 5) | int main(int argc, char *argv[])
FILE: code/FactoryMethod/Client.h
function class (line 11) | class Client
FILE: code/FactoryMethod/ConcreteFactory.cpp
function Product (line 20) | Product* ConcreteFactory::factoryMethod(){
FILE: code/FactoryMethod/ConcreteFactory.h
function class (line 14) | class ConcreteFactory : public Factory
FILE: code/FactoryMethod/ConcreteProduct.h
function class (line 13) | class ConcreteProduct : public Product
FILE: code/FactoryMethod/Factory.cpp
function Product (line 22) | Product* Factory::factoryMethod(){
FILE: code/FactoryMethod/Factory.h
function class (line 13) | class Factory
FILE: code/FactoryMethod/Product.h
function class (line 11) | class Product
FILE: code/FactoryMethod/main.cpp
function main (line 7) | int main(int argc, char *argv[])
FILE: code/Flyweight/ConcreteFlyweight.h
function class (line 15) | class ConcreteFlyweight : public Flyweight
FILE: code/Flyweight/Flyweight.h
function class (line 11) | class Flyweight
FILE: code/Flyweight/FlyweightFactory.cpp
function Flyweight (line 23) | Flyweight* FlyweightFactory::getFlyweight(string str){
FILE: code/Flyweight/FlyweightFactory.h
function class (line 16) | class FlyweightFactory
FILE: code/Flyweight/UnsharedConcreteFlyweight.h
function class (line 13) | class UnsharedConcreteFlyweight : public Flyweight
FILE: code/Flyweight/main.cpp
function main (line 7) | int main(int argc, char *argv[])
FILE: code/Mediator/Colleague.h
function class (line 15) | class Colleague
FILE: code/Mediator/ConcreteColleagueA.h
function class (line 13) | class ConcreteColleagueA : public Colleague
FILE: code/Mediator/ConcreteColleagueB.h
function class (line 13) | class ConcreteColleagueB : public Colleague
FILE: code/Mediator/ConcreteMediator.h
function class (line 16) | class ConcreteMediator : public Mediator
FILE: code/Mediator/Mediator.h
function class (line 18) | class Mediator
FILE: code/Mediator/main.cpp
function main (line 8) | int main(int argc, char *argv[])
FILE: code/Obeserver/ConcreteObeserver.h
function class (line 14) | class ConcreteObeserver : public Obeserver
FILE: code/Obeserver/ConcreteSubject.h
function class (line 13) | class ConcreteSubject : public Subject
FILE: code/Obeserver/Obeserver.h
function class (line 13) | class Obeserver
FILE: code/Obeserver/Subject.h
function class (line 15) | class Subject
FILE: code/Obeserver/main.cpp
function main (line 9) | int main(int argc, char *argv[])
FILE: code/Proxy/Proxy.h
function class (line 14) | class Proxy : public Subject
FILE: code/Proxy/RealSubject.h
function class (line 13) | class RealSubject : public Subject
FILE: code/Proxy/Subject.h
function class (line 11) | class Subject
FILE: code/Proxy/main.cpp
function main (line 7) | int main(int argc, char *argv[])
FILE: code/SimpleFactory/ConcreteProductA.h
function class (line 13) | class ConcreteProductA : public Product
FILE: code/SimpleFactory/ConcreteProductB.h
function class (line 13) | class ConcreteProductB : public Product
FILE: code/SimpleFactory/Factory.cpp
function Product (line 24) | Product* Factory::createProduct(string proname){
FILE: code/SimpleFactory/Factory.h
function class (line 15) | class Factory
FILE: code/SimpleFactory/Product.h
function class (line 11) | class Product
FILE: code/SimpleFactory/main.cpp
function main (line 7) | int main(int argc, char *argv[])
FILE: code/Singleton/Singleton.cpp
function Singleton (line 21) | Singleton* Singleton::getInstance(){
FILE: code/Singleton/Singleton.h
function class (line 11) | class Singleton
FILE: code/Singleton/main.cpp
function main (line 5) | int main(int argc, char *argv[])
FILE: code/State/ConcreteStateA.cpp
function State (line 21) | State * ConcreteStateA::Instance()
FILE: code/State/ConcreteStateA.h
function class (line 13) | class ConcreteStateA : public State
FILE: code/State/ConcreteStateB.cpp
function State (line 19) | State * ConcreteStateB::Instance()
FILE: code/State/ConcreteStateB.h
function class (line 13) | class ConcreteStateB : public State
FILE: code/State/Context.h
function class (line 13) | class Context
FILE: code/State/State.h
function class (line 13) | class State
FILE: code/State/main.cpp
function main (line 8) | int main(int argc, char *argv[])
FILE: code/Strategy/ConcreteStrategyA.h
function class (line 13) | class ConcreteStrategyA : public Strategy
FILE: code/Strategy/ConcreteStrategyB.h
function class (line 13) | class ConcreteStrategyB : public Strategy
FILE: code/Strategy/Context.h
function class (line 13) | class Context
FILE: code/Strategy/Strategy.h
function class (line 11) | class Strategy
FILE: code/Strategy/main.cpp
function main (line 9) | int main(int argc, char *argv[])
FILE: code/main/main.cpp
function main (line 5) | int main(int argc, char *argv[])
FILE: sphinx_rtd_theme/__init__.py
function get_html_theme_path (line 14) | def get_html_theme_path():
Condensed preview — 320 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (597K chars).
[
{
"path": ".gitattributes",
"chars": 483,
"preview": "# Auto detect text files and perform LF normalization\n* text=auto\n\n# Custom for Visual Studio\n*.cs diff=csharp\n*.sln"
},
{
"path": ".gitignore",
"chars": 2652,
"preview": "#################\n## Eclipse\n#################\n\n_build/\n\n*.pydevproject\n.project\n.metadata\nbin/\ntmp/\n*.tmp\n*.bak\n*.swp\n*"
},
{
"path": "LICENSE",
"chars": 179,
"preview": "版权说明\n=====================\n\n\n本书所有源代码及图片可自由分享,包括用于商业用途;\n\n由于部分章节内容使用到刘伟的课件《java设计模式》(互联网分享),所以本书\n文字内容不可用于商业目的(可在互联网自由分享);\n"
},
{
"path": "Makefile",
"chars": 6758,
"preview": "# Makefile for Sphinx documentation\n#\n\n# You can set these variables from the command line.\nSPHINXOPTS =\nSPHINXBUILD "
},
{
"path": "behavioral_patterns/behavioral.rst",
"chars": 912,
"preview": ".. _behavioral:\n\n行为型模式\n====================\n\n\n行为型模式(Behavioral Pattern)是对在不同的对象之间划分责任和算法的抽象化。\n\n行为型模式不仅仅关注类和对象的结构,而且重点关注它"
},
{
"path": "behavioral_patterns/command.rst",
"chars": 3409,
"preview": ".. _command:\n\n命令模式\n====================\n\n.. contents:: 目录\n\n模式动机\n--------------------\n在软件设计中,我们经常需要向某些对象发送请求,但是并不知道请求的接收者"
},
{
"path": "behavioral_patterns/mediator.rst",
"chars": 3708,
"preview": ".. _mediator:\n\n中介者模式\n====================\n\n.. contents:: 目录\n\n模式动机\n--------------------\n- 在用户与用户直接聊天的设计方案中,用户对象之间存在很强的关联性"
},
{
"path": "behavioral_patterns/observer.rst",
"chars": 3455,
"preview": ".. _observer:\n\n观察者模式\n====================\n\n.. contents:: 目录\n\n模式动机\n--------------------\n建立一种对象与对象之间的依赖关系,一个对象发生改变时将自动通知其他"
},
{
"path": "behavioral_patterns/state.rst",
"chars": 4042,
"preview": ".. _state:\n\n状态模式\n====================\n\n.. contents:: 目录\n\n模式动机\n--------------------\n- 在很多情况下,一个对象的行为取决于一个或多个动态变化的属性,这样的属性"
},
{
"path": "behavioral_patterns/strategy.rst",
"chars": 3428,
"preview": ".. _strategy:\n\n策略模式\n====================\n\n.. contents:: 目录\n\n模式动机\n--------------------\n- 完成一项任务,往往可以有多种不同的方式,每一种方式称为一个策略,"
},
{
"path": "code/AbstractFactory/AbstractFactory.cpp",
"chars": 371,
"preview": "///////////////////////////////////////////////////////////\n// AbstractFactory.cpp\n// Implementation of the Class Abst"
},
{
"path": "code/AbstractFactory/AbstractFactory.h",
"chars": 699,
"preview": "///////////////////////////////////////////////////////////\n// AbstractFactory.h\n// Implementation of the Class Abstra"
},
{
"path": "code/AbstractFactory/AbstractProductA.cpp",
"chars": 381,
"preview": "///////////////////////////////////////////////////////////\n// AbstractProductA.cpp\n// Implementation of the Class Abs"
},
{
"path": "code/AbstractFactory/AbstractProductA.h",
"chars": 572,
"preview": "///////////////////////////////////////////////////////////\n// AbstractProductA.h\n// Implementation of the Class Abstr"
},
{
"path": "code/AbstractFactory/AbstractProductB.cpp",
"chars": 381,
"preview": "///////////////////////////////////////////////////////////\n// AbstractProductB.cpp\n// Implementation of the Class Abs"
},
{
"path": "code/AbstractFactory/AbstractProductB.h",
"chars": 572,
"preview": "///////////////////////////////////////////////////////////\n// AbstractProductB.h\n// Implementation of the Class Abstr"
},
{
"path": "code/AbstractFactory/ConcreteFactory1.cpp",
"chars": 591,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteFactory1.cpp\n// Implementation of the Class Con"
},
{
"path": "code/AbstractFactory/ConcreteFactory1.h",
"chars": 755,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteFactory1.h\n// Implementation of the Class Concr"
},
{
"path": "code/AbstractFactory/ConcreteFactory2.cpp",
"chars": 593,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteFactory2.cpp\n// Implementation of the Class Con"
},
{
"path": "code/AbstractFactory/ConcreteFactory2.h",
"chars": 754,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteFactory2.h\n// Implementation of the Class Concr"
},
{
"path": "code/AbstractFactory/ProductA1.cpp",
"chars": 431,
"preview": "///////////////////////////////////////////////////////////\n// ProductA1.cpp\n// Implementation of the Class ProductA1\n"
},
{
"path": "code/AbstractFactory/ProductA1.h",
"chars": 582,
"preview": "///////////////////////////////////////////////////////////\n// ProductA1.h\n// Implementation of the Class ProductA1\n//"
},
{
"path": "code/AbstractFactory/ProductA2.cpp",
"chars": 434,
"preview": "///////////////////////////////////////////////////////////\n// ProductA2.cpp\n// Implementation of the Class ProductA2\n"
},
{
"path": "code/AbstractFactory/ProductA2.h",
"chars": 582,
"preview": "///////////////////////////////////////////////////////////\n// ProductA2.h\n// Implementation of the Class ProductA2\n//"
},
{
"path": "code/AbstractFactory/ProductB1.cpp",
"chars": 433,
"preview": "///////////////////////////////////////////////////////////\n// ProductB1.cpp\n// Implementation of the Class ProductB1\n"
},
{
"path": "code/AbstractFactory/ProductB1.h",
"chars": 582,
"preview": "///////////////////////////////////////////////////////////\n// ProductB1.h\n// Implementation of the Class ProductB1\n//"
},
{
"path": "code/AbstractFactory/ProductB2.cpp",
"chars": 434,
"preview": "///////////////////////////////////////////////////////////\n// ProductB2.cpp\n// Implementation of the Class ProductB2\n"
},
{
"path": "code/AbstractFactory/ProductB2.h",
"chars": 582,
"preview": "///////////////////////////////////////////////////////////\n// ProductB2.h\n// Implementation of the Class ProductB2\n//"
},
{
"path": "code/AbstractFactory/main.cfp",
"chars": 15513,
"preview": "<Project version=\"3.0\">\n<Name>main</Name>\n<Type>CUI</Type>\n<TargetName>main</TargetName>\n<TargetType>exe</TargetType>\n<F"
},
{
"path": "code/AbstractFactory/main.cfpg",
"chars": 111,
"preview": "<Projects version=\"2.0\">\n\t<Project active=\"1\">main.cfp</Project>\n\t<File active=\"1\">main.cpp</File>\n</Projects>\n"
},
{
"path": "code/AbstractFactory/main.cpp",
"chars": 662,
"preview": "#include <iostream>\n#include \"AbstractFactory.h\"\n#include \"AbstractProductA.h\"\n#include \"AbstractProductB.h\"\n#include \"C"
},
{
"path": "code/Adapter/Adaptee.cpp",
"chars": 464,
"preview": "///////////////////////////////////////////////////////////\n// Adaptee.cpp\n// Implementation of the Class Adaptee\n// "
},
{
"path": "code/Adapter/Adaptee.h",
"chars": 527,
"preview": "///////////////////////////////////////////////////////////\n// Adaptee.h\n// Implementation of the Class Adaptee\n// Cr"
},
{
"path": "code/Adapter/Adapter.cpp",
"chars": 414,
"preview": "///////////////////////////////////////////////////////////\n// Adapter.cpp\n// Implementation of the Class Adapter\n// "
},
{
"path": "code/Adapter/Adapter.h",
"chars": 633,
"preview": "///////////////////////////////////////////////////////////\n// Adapter.h\n// Implementation of the Class Adapter\n// Cr"
},
{
"path": "code/Adapter/Client.cpp",
"chars": 310,
"preview": "///////////////////////////////////////////////////////////\n// Client.cpp\n// Implementation of the Class Client\n// Cr"
},
{
"path": "code/Adapter/Client.h",
"chars": 496,
"preview": "///////////////////////////////////////////////////////////\n// Client.h\n// Implementation of the Class Client\n// Crea"
},
{
"path": "code/Adapter/Target.cpp",
"chars": 428,
"preview": "///////////////////////////////////////////////////////////\n// Target.cpp\n// Implementation of the Class Target\n// Cr"
},
{
"path": "code/Adapter/Target.h",
"chars": 522,
"preview": "///////////////////////////////////////////////////////////\n// Target.h\n// Implementation of the Class Target\n// Crea"
},
{
"path": "code/Adapter/main.cfp",
"chars": 14470,
"preview": "<Project version=\"3.0\">\n<Name>main</Name>\n<Type>CUI</Type>\n<TargetName>main</TargetName>\n<TargetType>exe</TargetType>\n<F"
},
{
"path": "code/Adapter/main.cfpg",
"chars": 111,
"preview": "<Projects version=\"2.0\">\n\t<Project active=\"1\">main.cfp</Project>\n\t<File active=\"1\">main.cpp</File>\n</Projects>\n"
},
{
"path": "code/Adapter/main.cpp",
"chars": 247,
"preview": "#include <iostream>\n#include \"Adapter.h\"\n#include \"Adaptee.h\"\n#include \"Target.h\"\n\nusing namespace std;\n\nint main(int ar"
},
{
"path": "code/Bridge/Abstraction.cpp",
"chars": 462,
"preview": "///////////////////////////////////////////////////////////\n// Abstraction.cpp\n// Implementation of the Class Abstract"
},
{
"path": "code/Bridge/Abstraction.h",
"chars": 641,
"preview": "///////////////////////////////////////////////////////////\n// Abstraction.h\n// Implementation of the Class Abstractio"
},
{
"path": "code/Bridge/ConcreteImplementorA.cpp",
"chars": 553,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteImplementorA.cpp\n// Implementation of the Class"
},
{
"path": "code/Bridge/ConcreteImplementorA.h",
"chars": 644,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteImplementorA.h\n// Implementation of the Class C"
},
{
"path": "code/Bridge/ConcreteImplementorB.cpp",
"chars": 554,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteImplementorB.cpp\n// Implementation of the Class"
},
{
"path": "code/Bridge/ConcreteImplementorB.h",
"chars": 644,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteImplementorB.h\n// Implementation of the Class C"
},
{
"path": "code/Bridge/Implementor.cpp",
"chars": 387,
"preview": "///////////////////////////////////////////////////////////\n// Implementor.cpp\n// Implementation of the Class Implemen"
},
{
"path": "code/Bridge/Implementor.h",
"chars": 552,
"preview": "///////////////////////////////////////////////////////////\n// Implementor.h\n// Implementation of the Class Implemento"
},
{
"path": "code/Bridge/RefinedAbstraction.cpp",
"chars": 632,
"preview": "///////////////////////////////////////////////////////////\n// RefinedAbstraction.cpp\n// Implementation of the Class R"
},
{
"path": "code/Bridge/RefinedAbstraction.h",
"chars": 670,
"preview": "///////////////////////////////////////////////////////////\n// RefinedAbstraction.h\n// Implementation of the Class Ref"
},
{
"path": "code/Bridge/main.cfp",
"chars": 14852,
"preview": "<Project version=\"3.0\">\n<Name>main</Name>\n<Type>CUI</Type>\n<TargetName>main</TargetName>\n<TargetType>exe</TargetType>\n<F"
},
{
"path": "code/Bridge/main.cfpg",
"chars": 111,
"preview": "<Projects version=\"2.0\">\n\t<Project active=\"1\">main.cfp</Project>\n\t<File active=\"1\">main.cpp</File>\n</Projects>\n"
},
{
"path": "code/Bridge/main.cpp",
"chars": 458,
"preview": "#include <iostream>\n#include \"ConcreteImplementorA.h\"\n#include \"ConcreteImplementorB.h\"\n#include \"RefinedAbstraction.h\"\n"
},
{
"path": "code/Builder/Builder.cpp",
"chars": 494,
"preview": "///////////////////////////////////////////////////////////\n// Builder.cpp\n// Implementation of the Class Builder\n// "
},
{
"path": "code/Builder/Builder.h",
"chars": 669,
"preview": "///////////////////////////////////////////////////////////\n// Builder.h\n// Implementation of the Class Builder\n// Cr"
},
{
"path": "code/Builder/ConcreteBuilder.cpp",
"chars": 596,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteBuilder.cpp\n// Implementation of the Class Conc"
},
{
"path": "code/Builder/ConcreteBuilder.h",
"chars": 665,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteBuilder.h\n// Implementation of the Class Concre"
},
{
"path": "code/Builder/Director.cpp",
"chars": 539,
"preview": "///////////////////////////////////////////////////////////\n// Director.cpp\n// Implementation of the Class Director\n//"
},
{
"path": "code/Builder/Director.h",
"chars": 640,
"preview": "///////////////////////////////////////////////////////////\n// Director.h\n// Implementation of the Class Director\n// "
},
{
"path": "code/Builder/Product.cpp",
"chars": 580,
"preview": "///////////////////////////////////////////////////////////\n// Product.cpp\n// Implementation of the Class Product\n// "
},
{
"path": "code/Builder/Product.h",
"chars": 677,
"preview": "///////////////////////////////////////////////////////////\n// Product.h\n// Implementation of the Class Product\n// Cr"
},
{
"path": "code/Builder/main.cfp",
"chars": 14682,
"preview": "<Project version=\"3.0\">\n<Name>main</Name>\n<Type>CUI</Type>\n<TargetName>main</TargetName>\n<TargetType>exe</TargetType>\n<F"
},
{
"path": "code/Builder/main.cfpg",
"chars": 111,
"preview": "<Projects version=\"2.0\">\n\t<Project active=\"1\">main.cfp</Project>\n\t<File active=\"1\">main.cpp</File>\n</Projects>\n"
},
{
"path": "code/Builder/main.cpp",
"chars": 370,
"preview": "#include <iostream>\n#include \"ConcreteBuilder.h\"\n#include \"Director.h\"\n#include \"Builder.h\"\n#include \"Product.h\"\n\nusing "
},
{
"path": "code/Command/Command.cpp",
"chars": 350,
"preview": "///////////////////////////////////////////////////////////\n// Command.cpp\n// Implementation of the Class Command\n// "
},
{
"path": "code/Command/Command.h",
"chars": 527,
"preview": "///////////////////////////////////////////////////////////\n// Command.h\n// Implementation of the Class Command\n// Cr"
},
{
"path": "code/Command/ConcreteCommand.cpp",
"chars": 564,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteCommand.cpp\n// Implementation of the Class Conc"
},
{
"path": "code/Command/ConcreteCommand.h",
"chars": 682,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteCommand.h\n// Implementation of the Class Concre"
},
{
"path": "code/Command/Invoker.cpp",
"chars": 481,
"preview": "///////////////////////////////////////////////////////////\n// Invoker.cpp\n// Implementation of the Class Invoker\n// "
},
{
"path": "code/Command/Invoker.h",
"chars": 588,
"preview": "///////////////////////////////////////////////////////////\n// Invoker.h\n// Implementation of the Class Invoker\n// Cr"
},
{
"path": "code/Command/Receiver.cpp",
"chars": 427,
"preview": "///////////////////////////////////////////////////////////\n// Receiver.cpp\n// Implementation of the Class Receiver\n//"
},
{
"path": "code/Command/Receiver.h",
"chars": 523,
"preview": "///////////////////////////////////////////////////////////\n// Receiver.h\n// Implementation of the Class Receiver\n// "
},
{
"path": "code/Command/main.cfp",
"chars": 14676,
"preview": "<Project version=\"3.0\">\n<Name>main</Name>\n<Type>CUI</Type>\n<TargetName>main</TargetName>\n<TargetType>exe</TargetType>\n<F"
},
{
"path": "code/Command/main.cfpg",
"chars": 111,
"preview": "<Projects version=\"2.0\">\n\t<Project active=\"1\">main.cfp</Project>\n\t<File active=\"1\">main.cpp</File>\n</Projects>\n"
},
{
"path": "code/Command/main.cpp",
"chars": 386,
"preview": "#include <iostream>\n#include \"ConcreteCommand.h\"\n#include \"Invoker.h\"\n#include \"Receiver.h\"\n\nusing namespace std;\n\nint m"
},
{
"path": "code/Decorator/Component.cpp",
"chars": 368,
"preview": "///////////////////////////////////////////////////////////\n// Component.cpp\n// Implementation of the Class Component\n"
},
{
"path": "code/Decorator/Component.h",
"chars": 539,
"preview": "///////////////////////////////////////////////////////////\n// Component.h\n// Implementation of the Class Component\n//"
},
{
"path": "code/Decorator/ConcreteComponent.cpp",
"chars": 524,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteComponent.cpp\n// Implementation of the Class Co"
},
{
"path": "code/Decorator/ConcreteComponent.h",
"chars": 614,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteComponent.h\n// Implementation of the Class Conc"
},
{
"path": "code/Decorator/ConcreteDecoratorA.cpp",
"chars": 628,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteDecoratorA.cpp\n// Implementation of the Class C"
},
{
"path": "code/Decorator/ConcreteDecoratorA.h",
"chars": 686,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteDecoratorA.h\n// Implementation of the Class Con"
},
{
"path": "code/Decorator/ConcreteDecoratorB.cpp",
"chars": 635,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteDecoratorB.cpp\n// Implementation of the Class C"
},
{
"path": "code/Decorator/ConcreteDecoratorB.h",
"chars": 686,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteDecoratorB.h\n// Implementation of the Class Con"
},
{
"path": "code/Decorator/Decorator.cpp",
"chars": 425,
"preview": "///////////////////////////////////////////////////////////\n// Decorator.cpp\n// Implementation of the Class Decorator\n"
},
{
"path": "code/Decorator/Decorator.h",
"chars": 627,
"preview": "///////////////////////////////////////////////////////////\n// Decorator.h\n// Implementation of the Class Decorator\n//"
},
{
"path": "code/Decorator/main.cfp",
"chars": 14954,
"preview": "<Project version=\"3.0\">\n<Name>main</Name>\n<Type>CUI</Type>\n<TargetName>main</TargetName>\n<TargetType>exe</TargetType>\n<F"
},
{
"path": "code/Decorator/main.cfpg",
"chars": 111,
"preview": "<Projects version=\"2.0\">\n\t<Project active=\"1\">main.cfp</Project>\n\t<File active=\"1\">main.cpp</File>\n</Projects>\n"
},
{
"path": "code/Decorator/main.cpp",
"chars": 460,
"preview": "#include <iostream>\n#include \"ConcreteComponent.h\"\n#include \"ConcreteDecoratorA.h\"\n#include \"ConcreteDecoratorB.h\"\n#incl"
},
{
"path": "code/Facade/Client.cpp",
"chars": 310,
"preview": "///////////////////////////////////////////////////////////\n// Client.cpp\n// Implementation of the Class Client\n// Cr"
},
{
"path": "code/Facade/Client.h",
"chars": 496,
"preview": "///////////////////////////////////////////////////////////\n// Client.h\n// Implementation of the Class Client\n// Crea"
},
{
"path": "code/Facade/Facade.cpp",
"chars": 560,
"preview": "///////////////////////////////////////////////////////////\n// Facade.cpp\n// Implementation of the Class Facade\n// Cr"
},
{
"path": "code/Facade/Facade.h",
"chars": 655,
"preview": "///////////////////////////////////////////////////////////\n// Facade.h\n// Implementation of the Class Facade\n// Crea"
},
{
"path": "code/Facade/SystemA.cpp",
"chars": 423,
"preview": "///////////////////////////////////////////////////////////\n// SystemA.cpp\n// Implementation of the Class SystemA\n// "
},
{
"path": "code/Facade/SystemA.h",
"chars": 522,
"preview": "///////////////////////////////////////////////////////////\n// SystemA.h\n// Implementation of the Class SystemA\n// Cr"
},
{
"path": "code/Facade/SystemB.cpp",
"chars": 424,
"preview": "///////////////////////////////////////////////////////////\n// SystemB.cpp\n// Implementation of the Class SystemB\n// "
},
{
"path": "code/Facade/SystemB.h",
"chars": 522,
"preview": "///////////////////////////////////////////////////////////\n// SystemB.h\n// Implementation of the Class SystemB\n// Cr"
},
{
"path": "code/Facade/SystemC.cpp",
"chars": 423,
"preview": "///////////////////////////////////////////////////////////\n// SystemC.cpp\n// Implementation of the Class SystemC\n// "
},
{
"path": "code/Facade/SystemC.h",
"chars": 522,
"preview": "///////////////////////////////////////////////////////////\n// SystemC.h\n// Implementation of the Class SystemC\n// Cr"
},
{
"path": "code/Facade/main.cfp",
"chars": 14522,
"preview": "<Project version=\"3.0\">\n<Name>main</Name>\n<Type>CUI</Type>\n<TargetName>main</TargetName>\n<TargetType>exe</TargetType>\n<F"
},
{
"path": "code/Facade/main.cfpg",
"chars": 111,
"preview": "<Projects version=\"2.0\">\n\t<Project active=\"1\">main.cfp</Project>\n\t<File active=\"1\">main.cpp</File>\n</Projects>\n"
},
{
"path": "code/Facade/main.cpp",
"chars": 144,
"preview": "#include <iostream>\n#include \"Facade.h\"\nusing namespace std;\n\nint main(int argc, char *argv[])\n{\n\tFacade fa;\n\tfa.wrapOpr"
},
{
"path": "code/FactoryMethod/Client.cpp",
"chars": 307,
"preview": "///////////////////////////////////////////////////////////\n// Client.cpp\n// Implementation of the Class Client\n// Cr"
},
{
"path": "code/FactoryMethod/Client.h",
"chars": 493,
"preview": "///////////////////////////////////////////////////////////\n// Client.h\n// Implementation of the Class Client\n// Crea"
},
{
"path": "code/FactoryMethod/ConcreteFactory.cpp",
"chars": 479,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteFactory.cpp\n// Implementation of the Class Conc"
},
{
"path": "code/FactoryMethod/ConcreteFactory.h",
"chars": 637,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteFactory.h\n// Implementation of the Class Concre"
},
{
"path": "code/FactoryMethod/ConcreteProduct.cpp",
"chars": 484,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteProduct.cpp\n// Implementation of the Class Conc"
},
{
"path": "code/FactoryMethod/ConcreteProduct.h",
"chars": 602,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteProduct.h\n// Implementation of the Class Concre"
},
{
"path": "code/FactoryMethod/Factory.cpp",
"chars": 391,
"preview": "///////////////////////////////////////////////////////////\n// Factory.cpp\n// Implementation of the Class Factory\n// "
},
{
"path": "code/FactoryMethod/Factory.h",
"chars": 559,
"preview": "///////////////////////////////////////////////////////////\n// Factory.h\n// Implementation of the Class Factory\n// Cr"
},
{
"path": "code/FactoryMethod/Product.cpp",
"chars": 346,
"preview": "///////////////////////////////////////////////////////////\n// Product.cpp\n// Implementation of the Class Product\n// "
},
{
"path": "code/FactoryMethod/Product.h",
"chars": 523,
"preview": "///////////////////////////////////////////////////////////\n// Product.h\n// Implementation of the Class Product\n// Cr"
},
{
"path": "code/FactoryMethod/main.cfp",
"chars": 14691,
"preview": "<Project version=\"3.0\">\n<Name>main</Name>\n<Type>CUI</Type>\n<TargetName>main</TargetName>\n<TargetType>exe</TargetType>\n<F"
},
{
"path": "code/FactoryMethod/main.cfpg",
"chars": 111,
"preview": "<Projects version=\"2.0\">\n\t<Project active=\"1\">main.cfp</Project>\n\t<File active=\"1\">main.cpp</File>\n</Projects>\n"
},
{
"path": "code/FactoryMethod/main.cpp",
"chars": 283,
"preview": "#include \"Factory.h\"\n#include \"ConcreteFactory.h\"\n#include \"Product.h\"\n#include <iostream>\nusing namespace std;\n\nint mai"
},
{
"path": "code/Flyweight/ConcreteFlyweight.cpp",
"chars": 569,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteFlyweight.cpp\n// Implementation of the Class Co"
},
{
"path": "code/Flyweight/ConcreteFlyweight.h",
"chars": 705,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteFlyweight.h\n// Implementation of the Class Conc"
},
{
"path": "code/Flyweight/Flyweight.cpp",
"chars": 368,
"preview": "///////////////////////////////////////////////////////////\n// Flyweight.cpp\n// Implementation of the Class Flyweight\n"
},
{
"path": "code/Flyweight/Flyweight.h",
"chars": 539,
"preview": "///////////////////////////////////////////////////////////\n// Flyweight.h\n// Implementation of the Class Flyweight\n//"
},
{
"path": "code/Flyweight/FlyweightFactory.cpp",
"chars": 811,
"preview": "///////////////////////////////////////////////////////////\n// FlyweightFactory.cpp\n// Implementation of the Class Fly"
},
{
"path": "code/Flyweight/FlyweightFactory.h",
"chars": 713,
"preview": "///////////////////////////////////////////////////////////\n// FlyweightFactory.h\n// Implementation of the Class Flywe"
},
{
"path": "code/Flyweight/UnsharedConcreteFlyweight.cpp",
"chars": 496,
"preview": "///////////////////////////////////////////////////////////\n// UnsharedConcreteFlyweight.cpp\n// Implementation of the "
},
{
"path": "code/Flyweight/UnsharedConcreteFlyweight.h",
"chars": 679,
"preview": "///////////////////////////////////////////////////////////\n// UnsharedConcreteFlyweight.h\n// Implementation of the Cl"
},
{
"path": "code/Flyweight/main.cfp",
"chars": 14493,
"preview": "<Project version=\"3.0\">\n<Name>main</Name>\n<Type>CUI</Type>\n<TargetName>main</TargetName>\n<TargetType>exe</TargetType>\n<F"
},
{
"path": "code/Flyweight/main.cfpg",
"chars": 111,
"preview": "<Projects version=\"2.0\">\n\t<Project active=\"1\">main.cfp</Project>\n\t<File active=\"1\">main.cpp</File>\n</Projects>\n"
},
{
"path": "code/Flyweight/main.cpp",
"chars": 426,
"preview": "#include <iostream>\n#include \"ConcreteFlyweight.h\"\n#include \"FlyweightFactory.h\"\n#include \"Flyweight.h\"\nusing namespace "
},
{
"path": "code/Mediator/Colleague.cpp",
"chars": 607,
"preview": "///////////////////////////////////////////////////////////\n// Colleague.cpp\n// Implementation of the Class Colleague\n"
},
{
"path": "code/Mediator/Colleague.h",
"chars": 734,
"preview": "///////////////////////////////////////////////////////////\n// Colleague.h\n// Implementation of the Class Colleague\n//"
},
{
"path": "code/Mediator/ConcreteColleagueA.cpp",
"chars": 693,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteColleagueA.cpp\n// Implementation of the Class C"
},
{
"path": "code/Mediator/ConcreteColleagueA.h",
"chars": 683,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteColleagueA.h\n// Implementation of the Class Con"
},
{
"path": "code/Mediator/ConcreteColleagueB.cpp",
"chars": 699,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteColleagueB.cpp\n// Implementation of the Class C"
},
{
"path": "code/Mediator/ConcreteColleagueB.h",
"chars": 682,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteColleagueB.h\n// Implementation of the Class Con"
},
{
"path": "code/Mediator/ConcreteMediator.cpp",
"chars": 997,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteMediator.cpp\n// Implementation of the Class Con"
},
{
"path": "code/Mediator/ConcreteMediator.h",
"chars": 837,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteMediator.h\n// Implementation of the Class Concr"
},
{
"path": "code/Mediator/Mediator.cpp",
"chars": 458,
"preview": "///////////////////////////////////////////////////////////\n// Mediator.cpp\n// Implementation of the Class Mediator\n//"
},
{
"path": "code/Mediator/Mediator.h",
"chars": 725,
"preview": "///////////////////////////////////////////////////////////\n// Mediator.h\n// Implementation of the Class Mediator\n// "
},
{
"path": "code/Mediator/main.cfp",
"chars": 14951,
"preview": "<Project version=\"3.0\">\n<Name>main</Name>\n<Type>CUI</Type>\n<TargetName>main</TargetName>\n<TargetType>exe</TargetType>\n<F"
},
{
"path": "code/Mediator/main.cfpg",
"chars": 111,
"preview": "<Projects version=\"2.0\">\n\t<Project active=\"1\">main.cfp</Project>\n\t<File active=\"1\">main.cpp</File>\n</Projects>\n"
},
{
"path": "code/Mediator/main.cpp",
"chars": 520,
"preview": "#include <iostream>\n#include \"ConcreteColleagueA.h\"\n#include \"ConcreteMediator.h\"\n#include \"ConcreteColleagueB.h\"\n\nusing"
},
{
"path": "code/Obeserver/ConcreteObeserver.cpp",
"chars": 664,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteObeserver.cpp\n// Implementation of the Class Co"
},
{
"path": "code/Obeserver/ConcreteObeserver.h",
"chars": 728,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteObeserver.h\n// Implementation of the Class Conc"
},
{
"path": "code/Obeserver/ConcreteSubject.cpp",
"chars": 482,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteSubject.cpp\n// Implementation of the Class Conc"
},
{
"path": "code/Obeserver/ConcreteSubject.h",
"chars": 659,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteSubject.h\n// Implementation of the Class Concre"
},
{
"path": "code/Obeserver/Obeserver.cpp",
"chars": 323,
"preview": "///////////////////////////////////////////////////////////\n// Obeserver.cpp\n// Implementation of the Class Obeserver\n"
},
{
"path": "code/Obeserver/Obeserver.h",
"chars": 564,
"preview": "///////////////////////////////////////////////////////////\n// Obeserver.h\n// Implementation of the Class Obeserver\n//"
},
{
"path": "code/Obeserver/Subject.cpp",
"chars": 756,
"preview": "///////////////////////////////////////////////////////////\n// Subject.cpp\n// Implementation of the Class Subject\n// "
},
{
"path": "code/Obeserver/Subject.h",
"chars": 785,
"preview": "///////////////////////////////////////////////////////////\n// Subject.h\n// Implementation of the Class Subject\n// Cr"
},
{
"path": "code/Obeserver/main.cfp",
"chars": 14722,
"preview": "<Project version=\"3.0\">\n<Name>main</Name>\n<Type>CUI</Type>\n<TargetName>main</TargetName>\n<TargetType>exe</TargetType>\n<F"
},
{
"path": "code/Obeserver/main.cfpg",
"chars": 111,
"preview": "<Projects version=\"2.0\">\n\t<Project active=\"1\">main.cfp</Project>\n\t<File active=\"1\">main.cpp</File>\n</Projects>\n"
},
{
"path": "code/Obeserver/main.cpp",
"chars": 588,
"preview": "#include <iostream>\n#include \"Subject.h\"\n#include \"Obeserver.h\"\n#include \"ConcreteObeserver.h\"\n#include \"ConcreteSubject"
},
{
"path": "code/Proxy/Proxy.cpp",
"chars": 719,
"preview": "///////////////////////////////////////////////////////////\n// Proxy.cpp\n// Implementation of the Class Proxy\n// Crea"
},
{
"path": "code/Proxy/Proxy.h",
"chars": 656,
"preview": "///////////////////////////////////////////////////////////\n// Proxy.h\n// Implementation of the Class Proxy\n// Create"
},
{
"path": "code/Proxy/RealSubject.cpp",
"chars": 459,
"preview": "///////////////////////////////////////////////////////////\n// RealSubject.cpp\n// Implementation of the Class RealSubj"
},
{
"path": "code/Proxy/RealSubject.h",
"chars": 578,
"preview": "///////////////////////////////////////////////////////////\n// RealSubject.h\n// Implementation of the Class RealSubjec"
},
{
"path": "code/Proxy/Subject.cpp",
"chars": 350,
"preview": "///////////////////////////////////////////////////////////\n// Subject.cpp\n// Implementation of the Class Subject\n// "
},
{
"path": "code/Proxy/Subject.h",
"chars": 527,
"preview": "///////////////////////////////////////////////////////////\n// Subject.h\n// Implementation of the Class Subject\n// Cr"
},
{
"path": "code/Proxy/main.cfp",
"chars": 14360,
"preview": "<Project version=\"3.0\">\n<Name>main</Name>\n<Type>CUI</Type>\n<TargetName>main</TargetName>\n<TargetType>exe</TargetType>\n<F"
},
{
"path": "code/Proxy/main.cfpg",
"chars": 111,
"preview": "<Projects version=\"2.0\">\n\t<Project active=\"1\">main.cfp</Project>\n\t<File active=\"1\">main.cpp</File>\n</Projects>\n"
},
{
"path": "code/Proxy/main.cpp",
"chars": 169,
"preview": "#include <iostream>\n#include \"RealSubject.h\"\n#include \"Proxy.h\"\n\nusing namespace std;\n\nint main(int argc, char *argv[])\n"
},
{
"path": "code/SimpleFactory/ConcreteProductA.cpp",
"chars": 507,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteProductA.cpp\n// Implementation of the Class Con"
},
{
"path": "code/SimpleFactory/ConcreteProductA.h",
"chars": 608,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteProductA.h\n// Implementation of the Class Concr"
},
{
"path": "code/SimpleFactory/ConcreteProductB.cpp",
"chars": 507,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteProductB.cpp\n// Implementation of the Class Con"
},
{
"path": "code/SimpleFactory/ConcreteProductB.h",
"chars": 608,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteProductB.h\n// Implementation of the Class Concr"
},
{
"path": "code/SimpleFactory/Factory.cpp",
"chars": 571,
"preview": "///////////////////////////////////////////////////////////\n// Factory.cpp\n// Implementation of the Class Factory\n// "
},
{
"path": "code/SimpleFactory/Factory.h",
"chars": 612,
"preview": "///////////////////////////////////////////////////////////\n// Factory.h\n// Implementation of the Class Factory\n// Cr"
},
{
"path": "code/SimpleFactory/Product.cpp",
"chars": 317,
"preview": "///////////////////////////////////////////////////////////\n// Product.cpp\n// Implementation of the Class Product\n// "
},
{
"path": "code/SimpleFactory/Product.h",
"chars": 528,
"preview": "///////////////////////////////////////////////////////////\n// Product.h\n// Implementation of the Class Product\n// Cr"
},
{
"path": "code/SimpleFactory/main.cfp",
"chars": 14705,
"preview": "<Project version=\"3.0\">\n<Name>main</Name>\n<Type>CUI</Type>\n<TargetName>main</TargetName>\n<TargetType>exe</TargetType>\n<F"
},
{
"path": "code/SimpleFactory/main.cfpg",
"chars": 111,
"preview": "<Projects version=\"2.0\">\n\t<Project active=\"1\">main.cfp</Project>\n\t<File active=\"1\">main.cpp</File>\n</Projects>\n"
},
{
"path": "code/SimpleFactory/main.cpp",
"chars": 215,
"preview": "#include <iostream>\n#include \"Factory.h\"\n#include \"Product.h\"\n\nusing namespace std;\n\nint main(int argc, char *argv[])\n{\n"
},
{
"path": "code/Singleton/Singleton.cpp",
"chars": 629,
"preview": "///////////////////////////////////////////////////////////\n// Singleton.cpp\n// Implementation of the Class Singleton\n"
},
{
"path": "code/Singleton/Singleton.h",
"chars": 640,
"preview": "///////////////////////////////////////////////////////////\n// Singleton.h\n// Implementation of the Class Singleton\n//"
},
{
"path": "code/Singleton/main.cfp",
"chars": 14141,
"preview": "<Project version=\"3.0\">\n<Name>main</Name>\n<Type>CUI</Type>\n<TargetName>main</TargetName>\n<TargetType>exe</TargetType>\n<F"
},
{
"path": "code/Singleton/main.cfpg",
"chars": 111,
"preview": "<Projects version=\"2.0\">\n\t<Project active=\"1\">main.cfp</Project>\n\t<File active=\"1\">main.cpp</File>\n</Projects>\n"
},
{
"path": "code/Singleton/main.cpp",
"chars": 186,
"preview": "#include <iostream>\n#include \"Singleton.h\"\nusing namespace std;\n\nint main(int argc, char *argv[])\n{\n\tSingleton * sg = Si"
},
{
"path": "code/State/ConcreteStateA.cpp",
"chars": 778,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteStateA.cpp\n// Implementation of the Class Concr"
},
{
"path": "code/State/ConcreteStateA.h",
"chars": 673,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteStateA.h\n// Implementation of the Class Concret"
},
{
"path": "code/State/ConcreteStateB.cpp",
"chars": 782,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteStateB.cpp\n// Implementation of the Class Concr"
},
{
"path": "code/State/ConcreteStateB.h",
"chars": 671,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteStateB.h\n// Implementation of the Class Concret"
},
{
"path": "code/State/Context.cpp",
"chars": 507,
"preview": "///////////////////////////////////////////////////////////\n// Context.cpp\n// Implementation of the Class Context\n// "
},
{
"path": "code/State/Context.h",
"chars": 597,
"preview": "///////////////////////////////////////////////////////////\n// Context.h\n// Implementation of the Class Context\n// Cr"
},
{
"path": "code/State/State.cpp",
"chars": 344,
"preview": "///////////////////////////////////////////////////////////\n// State.cpp\n// Implementation of the Class State\n// Crea"
},
{
"path": "code/State/State.h",
"chars": 543,
"preview": "///////////////////////////////////////////////////////////\n// State.h\n// Implementation of the Class State\n// Create"
},
{
"path": "code/State/main.cfp",
"chars": 14690,
"preview": "<Project version=\"3.0\">\n<Name>main</Name>\n<Type>CUI</Type>\n<TargetName>main</TargetName>\n<TargetType>exe</TargetType>\n<F"
},
{
"path": "code/State/main.cfpg",
"chars": 111,
"preview": "<Projects version=\"2.0\">\n\t<Project active=\"1\">main.cfp</Project>\n\t<File active=\"1\">main.cpp</File>\n</Projects>\n"
},
{
"path": "code/State/main.cpp",
"chars": 341,
"preview": "#include <iostream>\n#include \"Context.h\"\n#include \"ConcreteStateA.h\"\n#include \"ConcreteStateB.h\"\n\nusing namespace std;\n\n"
},
{
"path": "code/Strategy/ConcreteStrategyA.cpp",
"chars": 503,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteStrategyA.cpp\n// Implementation of the Class Co"
},
{
"path": "code/Strategy/ConcreteStrategyA.h",
"chars": 620,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteStrategyA.h\n// Implementation of the Class Conc"
},
{
"path": "code/Strategy/ConcreteStrategyB.cpp",
"chars": 507,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteStrategyB.cpp\n// Implementation of the Class Co"
},
{
"path": "code/Strategy/ConcreteStrategyB.h",
"chars": 620,
"preview": "///////////////////////////////////////////////////////////\n// ConcreteStrategyB.h\n// Implementation of the Class Conc"
},
{
"path": "code/Strategy/Context.cpp",
"chars": 434,
"preview": "///////////////////////////////////////////////////////////\n// Context.cpp\n// Implementation of the Class Context\n// "
},
{
"path": "code/Strategy/Context.h",
"chars": 614,
"preview": "///////////////////////////////////////////////////////////\n// Context.h\n// Implementation of the Class Context\n// Cr"
},
{
"path": "code/Strategy/Strategy.cpp",
"chars": 360,
"preview": "///////////////////////////////////////////////////////////\n// Strategy.cpp\n// Implementation of the Class Strategy\n//"
},
{
"path": "code/Strategy/Strategy.h",
"chars": 534,
"preview": "///////////////////////////////////////////////////////////\n// Strategy.h\n// Implementation of the Class Strategy\n// "
},
{
"path": "code/Strategy/main.cfp",
"chars": 14595,
"preview": "<Project version=\"3.0\">\n<Name>main</Name>\n<Type>CUI</Type>\n<TargetName>main</TargetName>\n<TargetType>exe</TargetType>\n<F"
},
{
"path": "code/Strategy/main.cfpg",
"chars": 111,
"preview": "<Projects version=\"2.0\">\n\t<Project active=\"1\">main.cfp</Project>\n\t<File active=\"1\">main.cpp</File>\n</Projects>\n"
},
{
"path": "code/Strategy/main.cpp",
"chars": 693,
"preview": "#include <iostream>\n#include \"Context.h\"\n#include \"ConcreteStrategyA.h\"\n#include \"ConcreteStrategyB.h\"\n#include \"Strateg"
},
{
"path": "code/main/main.cfp",
"chars": 13974,
"preview": "<Project version=\"3.0\">\n<Name>main</Name>\n<Type>CUI</Type>\n<TargetName>main</TargetName>\n<TargetType>exe</TargetType>\n<F"
},
{
"path": "code/main/main.cfpg",
"chars": 111,
"preview": "<Projects version=\"2.0\">\n\t<Project active=\"1\">main.cfp</Project>\n\t<File active=\"1\">main.cpp</File>\n</Projects>\n"
}
]
// ... and 120 more files (download for full content)
About this extraction
This page contains the full source code of the me115/design_patterns GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 320 files (526.4 KB), approximately 190.7k tokens, and a symbol index with 101 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.