This commit is contained in:
flykhan 2024-02-06 17:21:37 +08:00
parent 858f7203b4
commit 986eea7a92
74 changed files with 3441 additions and 0 deletions

61
DesignPatterns.pro Normal file
View File

@ -0,0 +1,61 @@
QT += core
QT -= gui
CONFIG += c++11
TARGET = DesignPatterns
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
include(factorypattern/factorypattern.pri)#工厂模式
include(singletonpattern/singletonpattern.pri)#单例模式
include(proxypattern/proxypattern.pri)#代理模式
include(templatepattern/templatepattern.pri)#模版模式
include(strategypattern/strategypattern.pri)#策略模式
include(flyweightpattern/flyweightpattern.pri)#享元模式
include(visitorpattern/visitorpattern.pri)#访问者模式
include(mediatorpattern/mediatorpattern.pri)#中介者模式
include(observerpattern/observerpattern.pri)#观察者模式
include(statepattern/statepattern.pri)#状态模式
include(commandpattern/commandpattern.pri)#命令模式
include(decoratorpattern/decoratorpattern.pri)#装饰模式
include(bridgepattern/bridgepattern.pri)#桥接模式
include(iteratorpattern/iteratorpattern.pri)#迭代器模式
include(compositepattern/compositepattern.pri)#组合模式
include(facadepattern/facadepattern.pri)#外观模式
include(adapterpattern/adapterpattern.pri)#适配器模式
include(abstractfactorypattern/abstractfactorypattern.pri)#抽象工厂模式
include(builderpattern/builderpattern.pri)#建造者模式
include(prototypepattern/prototypepattern.pri)#原型模式
include(interpreterpattern/interpreterpattern.pri)#解释器模式
include(chainofresponsibilitypattern/chainofresponsibilitypattern.pri)#责任链模式
include(mementopattern/mementopattern.pri)#备忘录模式

318
DesignPatterns.pro.user Normal file
View File

@ -0,0 +1,318 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.2.1, 2024-02-06T17:09:19. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{f6048ee0-a648-46d2-9ec4-234de25ff265}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">System</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap"/>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.8.0 MSVC2013 32bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.8.0 MSVC2013 32bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.58.win32_msvc2013_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/liubo/Desktop/VSCode Projects/build-DesignPatterns-Desktop_Qt_5_8_0_MSVC2013_32bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清理</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/liubo/Desktop/VSCode Projects/build-DesignPatterns-Desktop_Qt_5_8_0_MSVC2013_32bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清理</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/liubo/Desktop/VSCode Projects/build-DesignPatterns-Desktop_Qt_5_8_0_MSVC2013_32bit-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">true</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清理</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Profile</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">在本地部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">-1</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">DesignPatterns</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/Users/liubo/Desktop/VSCode Projects/DesignPatterns/DesignPatterns.pro</value>
<value type="bool" key="QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath">true</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">DesignPatterns.pro</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default"></value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">18</value>
</data>
<data>
<variable>Version</variable>
<value type="int">18</value>
</data>
</qtcreator>

View File

@ -0,0 +1,78 @@
#include "interface.h"
#include <string>
class AbstractFactory
{
public:
AbstractFactory()
{
cout << "create AbstractFactory" << endl;
}
virtual ~AbstractFactory(){}
virtual Shape * getShape(string type) = 0;
virtual Color * getColor(string type) = 0;
};
class ShapeFactory: public AbstractFactory
{
public:
ShapeFactory()
{
cout << "create ShapeFactory" << endl;
}
Shape * getShape(string type)
{
if (type.compare("Circle") == 0)
{
return new Circle();
}
else if (type.compare("Square") == 0)
{
return new Square();
}
else if (type.compare("Rectangle") == 0)
{
return new Rectangle();
}
else
{
return nullptr;
}
}
Color * getColor(string type)
{
return nullptr;
}
};
class ColorFactory: public AbstractFactory
{
public:
ColorFactory()
{
cout << "create ColorFactory" << endl;
}
Color *getColor(string type)
{
if (type.compare("Red") == 0)
{
return new Red();
}
else if (type.compare("Green") == 0)
{
return new Green();
}
else if (type.compare("Blue") == 0)
{
return new Blue();
}
else
{
return nullptr;
}
}
Shape * getShape(string type)
{
return nullptr;
}
};

View File

@ -0,0 +1,4 @@
HEADERS += \
$$PWD/interface.h \
$$PWD/abstractfactory.h \
$$PWD/factoryproducer.h

View File

@ -0,0 +1,22 @@
#include "abstractfactory.h"
class FactoryProducer
{
public:
FactoryProducer(){}
AbstractFactory *getFactory(string type)
{
if (type.compare("ShapeFactory") == 0)
{
return new ShapeFactory();
}
else if (type.compare("ColorFactory") == 0)
{
return new ColorFactory();
}
else
{
return nullptr;
}
}
};

View File

@ -0,0 +1,103 @@
#include <iostream>
using namespace std;
class Shape
{
public:
Shape()
{
cout << "create Shape" << endl;
}
virtual ~Shape(){}
virtual void draw() = 0;
};
class Circle: public Shape
{
public:
Circle()
{
cout << "create Circle" << endl;
}
void draw()
{
cout << "draw Circle" << endl;
}
};
class Square: public Shape
{
public:
Square()
{
cout << "create Square" << endl;
}
void draw()
{
cout << "draw Square" << endl;
}
};
class Rectangle: public Shape
{
public:
Rectangle()
{
cout << "create Rectangle" << endl;
}
void draw()
{
cout << "draw Rectangle" << endl;
}
};
class Color
{
public:
Color()
{
cout << "create Color" << endl;
}
virtual ~Color(){}
virtual void fill() = 0;
};
class Red: public Color
{
public:
Red()
{
cout << "create Red" << endl;
}
void fill()
{
cout << "fill Red" << endl;
}
};
class Green: public Color
{
public:
Green()
{
cout << "create Green" << endl;
}
void fill()
{
cout << "fill Green" << endl;
}
};
class Blue: public Color
{
public:
Blue()
{
cout << "create Blue" << endl;
}
void fill()
{
cout << "fill Blue" << endl;
}
};

View File

@ -0,0 +1,3 @@
HEADERS += \
$$PWD/first_interface.h \
$$PWD/second_interface.h

View File

@ -0,0 +1,38 @@
#include <string>
#include <iostream>
using namespace std;
class AdvancedMediaPlayer
{
public:
AdvancedMediaPlayer(){}
virtual ~AdvancedMediaPlayer(){}
virtual void playVlc(string fileName) = 0;
virtual void playMp4(string fileName) = 0;
};
class VlcPlayer: public AdvancedMediaPlayer
{
public:
void playVlc(string fileName)
{
cout << "Playing vlc file. Name: " + fileName << endl;
}
void playMp4(string fileName)
{
cout << fileName + " do nothing" << endl;
}
};
class Mp4Player: public AdvancedMediaPlayer
{
public:
void playVlc(string fileName)
{
cout << fileName + " do nothing" << endl;
}
void playMp4(string fileName)
{
cout << "Playing mp4 file. Name: " + fileName << endl;
}
};

View File

@ -0,0 +1,64 @@
#include "first_interface.h"
class MediaPlayer
{
public:
MediaPlayer(){}
virtual ~MediaPlayer(){}
virtual void play(string audioType, string fileName) = 0;
};
class MediaAdapter: public MediaPlayer
{
public:
MediaAdapter(string audioType)
{
if (audioType == "vlc")
{
player = new VlcPlayer();
}
else if(audioType == "mp4")
{
player = new Mp4Player();
}
else
{
player = nullptr;
}
}
void play(string audioType, string fileName)
{
if (audioType == "vlc")
{
player->playVlc(fileName);
}
else if(audioType == "mp4")
{
player->playMp4(fileName);
}
}
public:
AdvancedMediaPlayer *player;
};
class AudioPlayer: public MediaPlayer
{
public:
void play(string audioType, string fileName)
{
if (audioType == "mp3")
{
cout << "Playing mp3 file. Name: " + fileName << endl;
}
else if(audioType == "mp4" || audioType == "vlc")
{
MediaAdapter * adapter = new MediaAdapter(audioType);
adapter->play(audioType, fileName);
}
else
{
cout << "Invalid media. " + audioType + " format not supported";
}
}
};

474
bin/Makefile Normal file
View File

@ -0,0 +1,474 @@
#############################################################################
# Makefile for building: DesignPatterns
# Generated by qmake (3.0) (Qt 5.7.1)
# Project: ..\DesignPatterns.pro
# Template: app
# Command: D:\Qt5.7.1-64\5.7\msvc2015_64\bin\qmake.exe -spec win32-msvc2015 -o Makefile ..\DesignPatterns.pro
#############################################################################
MAKEFILE = Makefile
first: release
install: release-install
uninstall: release-uninstall
QMAKE = D:\Qt5.7.1-64\5.7\msvc2015_64\bin\qmake.exe
DEL_FILE = del
CHK_DIR_EXISTS= if not exist
MKDIR = mkdir
COPY = copy /y
COPY_FILE = copy /y
COPY_DIR = xcopy /s /q /y /i
INSTALL_FILE = copy /y
INSTALL_PROGRAM = copy /y
INSTALL_DIR = xcopy /s /q /y /i
DEL_FILE = del
SYMLINK = $(QMAKE) -install ln -f -s
DEL_DIR = rmdir
MOVE = move
SUBTARGETS = \
release \
debug
release: FORCE
@set MAKEFLAGS=$(MAKEFLAGS)
$(MAKE) -f $(MAKEFILE).Release
release-make_first: FORCE
@set MAKEFLAGS=$(MAKEFLAGS)
$(MAKE) -f $(MAKEFILE).Release
release-all: FORCE
@set MAKEFLAGS=$(MAKEFLAGS)
$(MAKE) -f $(MAKEFILE).Release all
release-clean: FORCE
@set MAKEFLAGS=$(MAKEFLAGS)
$(MAKE) -f $(MAKEFILE).Release clean
release-distclean: FORCE
@set MAKEFLAGS=$(MAKEFLAGS)
$(MAKE) -f $(MAKEFILE).Release distclean
release-install: FORCE
@set MAKEFLAGS=$(MAKEFLAGS)
$(MAKE) -f $(MAKEFILE).Release install
release-uninstall: FORCE
@set MAKEFLAGS=$(MAKEFLAGS)
$(MAKE) -f $(MAKEFILE).Release uninstall
debug: FORCE
@set MAKEFLAGS=$(MAKEFLAGS)
$(MAKE) -f $(MAKEFILE).Debug
debug-make_first: FORCE
@set MAKEFLAGS=$(MAKEFLAGS)
$(MAKE) -f $(MAKEFILE).Debug
debug-all: FORCE
@set MAKEFLAGS=$(MAKEFLAGS)
$(MAKE) -f $(MAKEFILE).Debug all
debug-clean: FORCE
@set MAKEFLAGS=$(MAKEFLAGS)
$(MAKE) -f $(MAKEFILE).Debug clean
debug-distclean: FORCE
@set MAKEFLAGS=$(MAKEFLAGS)
$(MAKE) -f $(MAKEFILE).Debug distclean
debug-install: FORCE
@set MAKEFLAGS=$(MAKEFLAGS)
$(MAKE) -f $(MAKEFILE).Debug install
debug-uninstall: FORCE
@set MAKEFLAGS=$(MAKEFLAGS)
$(MAKE) -f $(MAKEFILE).Debug uninstall
Makefile: ..\DesignPatterns.pro D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\win32-msvc2015\qmake.conf D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\spec_pre.prf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\common\angle.conf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\common\msvc-base.conf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\common\msvc-desktop.conf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\qconfig.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dcore.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dcore_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dextras.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dextras_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dinput.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dinput_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dlogic.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dlogic_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dquick.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dquick_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dquickextras.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dquickextras_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dquickinput.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dquickinput_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dquickrender.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dquickrender_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3drender.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3drender_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_axbase.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_axbase_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_axcontainer.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_axcontainer_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_axserver.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_axserver_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_bluetooth.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_bluetooth_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_bootstrap_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_charts.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_charts_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_clucene_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_concurrent.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_concurrent_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_core.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_core_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_datavisualization.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_datavisualization_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_dbus.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_dbus_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_designer.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_designer_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_designercomponents_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_gamepad.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_gamepad_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_gui.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_gui_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_help.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_help_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_location.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_location_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_multimedia.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_multimedia_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_multimediawidgets.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_multimediawidgets_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_network.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_network_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_nfc.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_nfc_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_opengl.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_opengl_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_openglextensions.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_openglextensions_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_packetprotocol_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_platformsupport_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_positioning.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_positioning_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_printsupport.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_printsupport_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_purchasing.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_purchasing_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_qml.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_qml_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_qmldebug_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_qmldevtools_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_qmltest.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_qmltest_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_qtmultimediaquicktools_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_quick.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_quick_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_quickcontrols2.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_quickcontrols2_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_quickparticles_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_quicktemplates2_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_quickwidgets.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_quickwidgets_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_script.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_script_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_scripttools.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_scripttools_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_scxml.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_scxml_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_sensors.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_sensors_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_serialbus.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_serialbus_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_serialport.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_serialport_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_sql.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_sql_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_svg.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_svg_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_testlib.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_testlib_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_uiplugin.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_uitools.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_uitools_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_webchannel.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_webchannel_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_webengine.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_webengine_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_webenginecore.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_webenginecore_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_webenginecoreheaders_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_webenginewidgets.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_webenginewidgets_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_websockets.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_websockets_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_webview.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_webview_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_widgets.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_widgets_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_winextras.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_winextras_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_xml.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_xml_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_xmlpatterns.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_xmlpatterns_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_zlib_private.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\qt_functions.prf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\qt_config.prf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\win32\qt_config.prf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\win32-msvc2015\qmake.conf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\spec_post.prf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\exclusive_builds.prf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\toolchain.prf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\default_pre.prf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\win32\default_pre.prf \
..\factorypattern\factorypattern.pri \
..\singletonpattern\singletonpattern.pri \
..\proxypattern\proxypattern.pri \
..\templatepattern\templatepattern.pri \
..\strategypattern\strategypattern.pri \
..\flyweightpattern\flyweightpattern.pri \
..\visitorpattern\visitorpattern.pri \
..\mediatorpattern\mediatorpattern.pri \
..\observerpattern\observerpattern.pri \
..\statepattern\statepattern.pri \
..\commandpattern\commandpattern.pri \
..\decoratorpattern\decoratorpattern.pri \
..\bridgepattern\bridgepattern.pri \
..\iteratorpattern\iteratorpattern.pri \
..\compositepattern\compositepattern.pri \
..\facadepattern\facadepattern.pri \
..\adapterpattern\adapterpattern.pri \
..\abstractfactorypattern\abstractfactorypattern.pri \
..\builderpattern\builderpattern.pri \
..\prototypepattern\prototypepattern.pri \
..\interpreterpattern\interpreterpattern.pri \
..\chainofresponsibilitypattern\chainofresponsibilitypattern.pri \
..\mementopattern\mementopattern.pri \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\resolve_config.prf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\exclusive_builds_post.prf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\default_post.prf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\win32\console.prf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\win32\rtti.prf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\precompile_header.prf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\warn_on.prf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\qt.prf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\resources.prf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\moc.prf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\file_copies.prf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\testcase_targets.prf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\exceptions.prf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\yacc.prf \
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\lex.prf \
..\DesignPatterns.pro \
D:\Qt5.7.1-64\5.7\msvc2015_64\lib\Qt5Core.prl
$(QMAKE) -spec win32-msvc2015 -o Makefile ..\DesignPatterns.pro
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\spec_pre.prf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\common\angle.conf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\common\msvc-base.conf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\common\msvc-desktop.conf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\qconfig.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dcore.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dcore_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dextras.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dextras_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dinput.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dinput_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dlogic.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dlogic_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dquick.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dquick_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dquickextras.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dquickextras_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dquickinput.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dquickinput_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dquickrender.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3dquickrender_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3drender.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_3drender_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_axbase.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_axbase_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_axcontainer.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_axcontainer_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_axserver.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_axserver_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_bluetooth.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_bluetooth_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_bootstrap_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_charts.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_charts_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_clucene_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_concurrent.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_concurrent_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_core.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_core_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_datavisualization.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_datavisualization_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_dbus.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_dbus_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_designer.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_designer_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_designercomponents_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_gamepad.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_gamepad_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_gui.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_gui_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_help.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_help_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_location.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_location_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_multimedia.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_multimedia_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_multimediawidgets.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_multimediawidgets_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_network.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_network_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_nfc.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_nfc_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_opengl.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_opengl_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_openglextensions.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_openglextensions_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_packetprotocol_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_platformsupport_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_positioning.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_positioning_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_printsupport.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_printsupport_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_purchasing.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_purchasing_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_qml.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_qml_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_qmldebug_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_qmldevtools_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_qmltest.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_qmltest_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_qtmultimediaquicktools_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_quick.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_quick_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_quickcontrols2.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_quickcontrols2_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_quickparticles_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_quicktemplates2_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_quickwidgets.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_quickwidgets_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_script.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_script_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_scripttools.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_scripttools_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_scxml.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_scxml_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_sensors.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_sensors_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_serialbus.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_serialbus_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_serialport.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_serialport_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_sql.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_sql_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_svg.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_svg_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_testlib.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_testlib_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_uiplugin.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_uitools.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_uitools_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_webchannel.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_webchannel_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_webengine.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_webengine_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_webenginecore.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_webenginecore_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_webenginecoreheaders_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_webenginewidgets.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_webenginewidgets_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_websockets.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_websockets_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_webview.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_webview_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_widgets.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_widgets_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_winextras.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_winextras_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_xml.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_xml_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_xmlpatterns.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_xmlpatterns_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\modules\qt_lib_zlib_private.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\qt_functions.prf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\qt_config.prf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\win32\qt_config.prf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\win32-msvc2015\qmake.conf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\spec_post.prf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\exclusive_builds.prf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\toolchain.prf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\default_pre.prf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\win32\default_pre.prf:
..\factorypattern\factorypattern.pri:
..\singletonpattern\singletonpattern.pri:
..\proxypattern\proxypattern.pri:
..\templatepattern\templatepattern.pri:
..\strategypattern\strategypattern.pri:
..\flyweightpattern\flyweightpattern.pri:
..\visitorpattern\visitorpattern.pri:
..\mediatorpattern\mediatorpattern.pri:
..\observerpattern\observerpattern.pri:
..\statepattern\statepattern.pri:
..\commandpattern\commandpattern.pri:
..\decoratorpattern\decoratorpattern.pri:
..\bridgepattern\bridgepattern.pri:
..\iteratorpattern\iteratorpattern.pri:
..\compositepattern\compositepattern.pri:
..\facadepattern\facadepattern.pri:
..\adapterpattern\adapterpattern.pri:
..\abstractfactorypattern\abstractfactorypattern.pri:
..\builderpattern\builderpattern.pri:
..\prototypepattern\prototypepattern.pri:
..\interpreterpattern\interpreterpattern.pri:
..\chainofresponsibilitypattern\chainofresponsibilitypattern.pri:
..\mementopattern\mementopattern.pri:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\resolve_config.prf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\exclusive_builds_post.prf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\default_post.prf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\win32\console.prf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\win32\rtti.prf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\precompile_header.prf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\warn_on.prf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\qt.prf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\resources.prf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\moc.prf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\file_copies.prf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\testcase_targets.prf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\exceptions.prf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\yacc.prf:
D:\Qt5.7.1-64\5.7\msvc2015_64\mkspecs\features\lex.prf:
..\DesignPatterns.pro:
D:\Qt5.7.1-64\5.7\msvc2015_64\lib\Qt5Core.prl:
qmake: FORCE
@$(QMAKE) -spec win32-msvc2015 -o Makefile ..\DesignPatterns.pro
qmake_all: FORCE
make_first: release-make_first debug-make_first FORCE
all: release-all debug-all FORCE
clean: release-clean debug-clean FORCE
-$(DEL_FILE) DesignPatterns.exp
distclean: release-distclean debug-distclean FORCE
-$(DEL_FILE) Makefile
-$(DEL_FILE) DesignPatterns.lib
release-mocclean:
@set MAKEFLAGS=$(MAKEFLAGS)
$(MAKE) -f $(MAKEFILE).Release mocclean
debug-mocclean:
@set MAKEFLAGS=$(MAKEFLAGS)
$(MAKE) -f $(MAKEFILE).Debug mocclean
mocclean: release-mocclean debug-mocclean
release-mocables:
@set MAKEFLAGS=$(MAKEFLAGS)
$(MAKE) -f $(MAKEFILE).Release mocables
debug-mocables:
@set MAKEFLAGS=$(MAKEFLAGS)
$(MAKE) -f $(MAKEFILE).Debug mocables
mocables: release-mocables debug-mocables
check: first
benchmark: first
FORCE:
$(MAKEFILE).Release: Makefile
$(MAKEFILE).Debug: Makefile

208
bin/Makefile.Debug Normal file

File diff suppressed because one or more lines are too long

208
bin/Makefile.Release Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

BIN
bin/release/main.obj Normal file

Binary file not shown.

View File

@ -0,0 +1,3 @@
HEADERS += \
$$PWD/first_interface.h \
$$PWD/second_interface.h

View File

@ -0,0 +1,28 @@
#include <iostream>
using namespace std;
class DrawApi
{
public:
DrawApi(){}
virtual ~DrawApi(){}
virtual void drawCircle(int radius, int x, int y) = 0;
};
class RedCircle: public DrawApi
{
public:
void drawCircle(int radius, int x, int y)
{
cout << "drawing circle [ color: red, radius: " << radius << ", x: " << x << ", y: " << y << " ]" << endl;
}
};
class GreenCircle: public DrawApi
{
public:
void drawCircle(int radius, int x, int y)
{
cout << "drawing circle [ color: green, radius: " << radius << ", x: " << x << ", y: " << y << " ]" << endl;
}
};

View File

@ -0,0 +1,36 @@
#include "first_interface.h"
class Shape
{
public:
virtual ~Shape(){}
DrawApi *getDrawApi()
{
return this->drawApi;
}
virtual void draw() = 0;
protected:
DrawApi *drawApi;
Shape(DrawApi *drawApi): drawApi(drawApi){}
};
class Circle: public Shape
{
public:
Circle(int radius, int x, int y, DrawApi *drawApi): Shape(drawApi)
{
this->x = x;
this->y = y;
this->radius = radius;
}
void draw()
{
getDrawApi()->drawCircle(radius, x, y);
}
private:
int x;
int y;
int radius;
};

View File

@ -0,0 +1,5 @@
HEADERS += \
$$PWD/packinterface.h \
$$PWD/foodinterface.h \
$$PWD/meal.h \
$$PWD/meakbuilder.h

View File

@ -0,0 +1,86 @@
#include "packinterface.h"
#include <string>
class Food
{
public:
Food(){}
virtual ~Food(){}
virtual Packing *getPack() = 0;
virtual string getName() = 0;
virtual float getPrice() = 0;
};
class Burger: public Food
{
public:
Packing *getPack()
{
return new Wrapper();
}
virtual string getName() = 0;
virtual float getPrice() = 0;
};
class ColdDrink: public Food
{
public:
Packing *getPack()
{
return new Bottle();
}
virtual string getName() = 0;
virtual float getPrice() = 0;
};
class VegBurger: public Burger
{
public:
string getName()
{
return "Veg Burger";
}
float getPrice()
{
return 25.0f;
}
};
class ChickenBurger: public Burger
{
public:
string getName()
{
return "Chicken Burger";
}
float getPrice()
{
return 50.5f;
}
};
class Coke: public ColdDrink
{
public:
string getName()
{
return "Coke";
}
float getPrice()
{
return 30.0f;
}
};
class Pepsi: public ColdDrink
{
public:
string getName()
{
return "Pepsi";
}
float getPrice()
{
return 35.0f;
}
};

View File

@ -0,0 +1,20 @@
#include "meal.h"
class MealBuilder
{
public:
Meal *prepareVegMeal ()
{
Meal * meal = new Meal();
meal->addFoodToVector(new VegBurger());
meal->addFoodToVector(new Coke());
return meal;
}
Meal *prepareNonVegMeal ()
{
Meal * meal = new Meal();
meal->addFoodToVector(new ChickenBurger());
meal->addFoodToVector(static_cast<ColdDrink *>(new Pepsi()));
return meal;
}
};

37
builderpattern/meal.h Normal file
View File

@ -0,0 +1,37 @@
#include "foodinterface.h"
#include <vector>
class Meal
{
public:
Meal()
{
vec.reserve(255);
}
void addFoodToVector(Food * food)
{
vec.push_back(food);
}
float getCost()
{
float ret = 0.0;
for(auto &food: vec)
{
ret += food->getPrice();
}
return ret;
}
void showFoods()
{
for(auto &food: vec)
{
cout << "--------------------------" << endl;
cout << food->getName() << endl;
cout << food->getPack()->pack() << endl;
cout << food->getPrice() << endl;
}
}
public:
std::vector<Food *> vec;
};

View File

@ -0,0 +1,28 @@
#include <iostream>
using namespace std;
class Packing
{
public:
Packing(){}
virtual ~Packing(){}
virtual string pack() = 0;
};
class Wrapper: public Packing
{
public:
string pack()
{
return "Wrapper";
}
};
class Bottle: public Packing
{
public:
string pack()
{
return "Bottle";
}
};

View File

@ -0,0 +1,2 @@
HEADERS += \
$$PWD/interface.h

View File

@ -0,0 +1,81 @@
#include <string>
#include <iostream>
#include <assert.h>
using namespace std;
class AbstractLogger
{
public:
static const int INFO = 1;
static const int DEBUG = 2;
static const int ERROR = 3;
AbstractLogger()
{
nextLogger = nullptr;
}
virtual ~AbstractLogger(){}
void setNextLogger(AbstractLogger *next)
{
nextLogger = next;
}
void logMessage(int level, string message)
{
if(this->level <= level)
{
write(message);
}
else
{
assert(nextLogger != nullptr);
nextLogger->write(message);
}
}
virtual void write(string message) = 0;
protected:
int level;
AbstractLogger *nextLogger;
};
class ConsoleLogger: public AbstractLogger
{
public:
ConsoleLogger(int level)
{
this->level = level;
cout << "init ConsoleLogger" << endl;
}
void write(string message)
{
cout << "Standard Console::Logger: " + message << endl;
}
};
class ErrorLogger: public AbstractLogger
{
public:
ErrorLogger(int level)
{
this->level = level;
cout << "init ErrorLogger" << endl;
}
void write(string message)
{
cout << "Error Console::Logger: " + message << endl;
}
};
class FileLogger: public AbstractLogger
{
public:
FileLogger(int level)
{
this->level = level;
cout << "init FileLogger" << endl;
}
void write(string message)
{
cout << "File::Logger: " + message << endl;
}
};

22
commandpattern/broker.h Normal file
View File

@ -0,0 +1,22 @@
#include <vector>
#include "interface.h"
class Broker
{
public:
void addOrder(Order *order)
{
vector.push_back(order);
}
void executeAllOrder()
{
for(auto it : vector)
{
it->execute();
}
vector.clear();
}
private:
std::vector<Order *> vector;
};

View File

@ -0,0 +1,4 @@
HEADERS += \
$$PWD/stock.h \
$$PWD/interface.h \
$$PWD/broker.h

View File

@ -0,0 +1,34 @@
#include "stock.h"
class Order
{
public:
Order(){}
virtual ~Order(){}
virtual void execute() = 0;
};
class BuyStock: public Order
{
public:
BuyStock(Stock *stock) : stock(stock){}
void execute()
{
stock->buy();
}
private:
Stock *stock;
};
class SellStock: public Order
{
public:
SellStock(Stock *stock) : stock(stock){}
void execute()
{
stock->sell();
}
private:
Stock *stock;
};

20
commandpattern/stock.h Normal file
View File

@ -0,0 +1,20 @@
#include <string>
#include <iostream>
using namespace std;
class Stock
{
public:
void buy()
{
cout << "Stock [ Name: " + name + ", Quantity: " + std::to_string(quantity) + " ] bought" << endl;
}
void sell()
{
cout << "Stock [ Name: " + name + ", Quantity: " + std::to_string(quantity) + " ] sold" << endl;
}
private:
string name = "test";
int quantity = 10;
};

View File

@ -0,0 +1,2 @@
HEADERS += \
$$PWD/employee.h

View File

@ -0,0 +1,35 @@
#include <string>
#include <vector>
#include <iostream>
using namespace std;
class Employee
{
public:
Employee(string name, string department, int salary)
{
this->name = name;
this->department = department;
this->salary = salary;
cout << "Employee name: " + name << ", department: " + department << ", salary: " << salary << endl;
}
void add(Employee *employee)
{
vector.push_back(employee);
}
std::vector<Employee*> getVector()
{
return this->vector;
}
string getDetails()
{
string ret = "Employee name: " + name + ", department: " + department + ", salary: " + std::to_string(salary);
return ret;
}
private:
string name;
string department;
int salary;
std::vector<Employee *> vector;
};

View File

@ -0,0 +1,3 @@
HEADERS += \
$$PWD/first_interface.h \
$$PWD/second_interface.h

View File

@ -0,0 +1,28 @@
#include <iostream>
using namespace std;
class Shape
{
public:
Shape(){}
virtual ~Shape(){}
virtual void draw() = 0;
};
class Rectangle: public Shape
{
public:
void draw()
{
cout << "draw Rectangle" << endl;
}
};
class Circle: public Shape
{
public:
void draw()
{
cout << "draw Circle" << endl;
}
};

View File

@ -0,0 +1,33 @@
#include "first_interface.h"
class ShapeDecorator
{
public:
ShapeDecorator(Shape *shape)
{
this->shape = shape;
}
virtual ~ShapeDecorator(){}
virtual void draw()
{
shape->draw();
}
protected:
Shape *shape;
};
class RedShapeDecorator: public ShapeDecorator
{
public:
RedShapeDecorator(Shape *shape) : ShapeDecorator(shape){}
void setRedBorder()
{
cout << "Border color: Red" << endl;
}
void draw()
{
shape->draw();
setRedBorder();
}
};

View File

@ -0,0 +1,3 @@
HEADERS += \
$$PWD/interface.h \
$$PWD/shapemaker.h

37
facadepattern/interface.h Normal file
View File

@ -0,0 +1,37 @@
#include <iostream>
using namespace std;
class Shape
{
public:
Shape(){}
virtual ~Shape(){}
virtual void draw() = 0;
};
class Square: public Shape
{
public:
void draw()
{
cout << "draw Square" << endl;
}
};
class Circle: public Shape
{
public:
void draw()
{
cout << "draw Circle" << endl;
}
};
class Rectangle: public Shape
{
public:
void draw()
{
cout << "draw Rectangle" << endl;
}
};

View File

@ -0,0 +1,29 @@
#include "interface.h"
class ShapeMaker
{
public:
ShapeMaker()
{
this->circle = new Circle();
this->square = new Square();
this->rectangle = new Rectangle();
}
void drawCircle()
{
circle->draw();
}
void drawSquare()
{
square->draw();
}
void drawRectangle()
{
rectangle->draw();
}
private:
Shape *circle;
Shape *square;
Shape *rectangle;
};

View File

@ -0,0 +1,3 @@
HEADERS += \
$$PWD/interface.h \
$$PWD/shapefactory.h

View File

@ -0,0 +1,52 @@
#include <iostream>
using namespace std;
class Shape
{
public:
Shape()
{
cout << "create Shape" << endl;
}
virtual ~Shape(){}
virtual void draw() = 0;
};
class Circle : public Shape
{
public:
Circle()
{
cout << "create Circle" << endl;
}
void draw()
{
cout << "draw Circle" << endl;
}
};
class Square: public Shape
{
public:
Square()
{
cout << "create Square" << endl;
}
void draw()
{
cout << "draw Square" << endl;
}
};
class Rectangle: public Shape
{
public:
Rectangle()
{
cout << "create Rectangle" << endl;
}
void draw()
{
cout << "draw Rectangle" << endl;
}
};

View File

@ -0,0 +1,26 @@
#include "interface.h"
class ShapeFactory
{
public:
ShapeFactory(){}
Shape* getShape(string type)
{
if (type.compare("Circle") == 0)
{
return new Circle();
}
else if (type.compare("Square") == 0)
{
return new Square();
}
else if (type.compare("Rectangle") == 0)
{
return new Rectangle();
}
else
{
return nullptr;
}
}
};

View File

@ -0,0 +1,3 @@
HEADERS += \
$$PWD/interface.h \
$$PWD/shapefactory.h

View File

@ -0,0 +1,42 @@
#include <string>
#include <iostream>
using namespace std;
class Shape
{
public:
Shape(){}
virtual ~Shape(){}
virtual void draw() = 0;
};
class Circle : public Shape
{
public:
Circle(string color) : color(color){}
void setX(int x)
{
this->x = x;
cout << "set x success" << endl;
}
void setY(int y)
{
this->y = y;
cout << "set y success" << endl;
}
void setRadius(int radius)
{
this->radius = radius;
cout << "set radius success" << endl;
}
void draw()
{
cout << "draw Circle [color: " + color + ", x: " + std::to_string(x) + ", y: " + std::to_string(y) + ", radius: " + std::to_string(radius) + "]" << endl << endl;
}
private:
int x;
int y;
int radius;
string color;
};

View File

@ -0,0 +1,23 @@
#include "interface.h"
#include <map>
class ShapeFactory
{
public:
std::map<string, Shape*> map;
auto getCircle(string color)->Shape*
{
auto iter = map.find(color);
if (iter != map.end())
{
return iter->second;
}
else
{
Shape *circle = new Circle(color);
map.insert(std::make_pair(color, circle));
cout << "Creating circle of color : " + color << endl;
return circle;
}
}
};

View File

@ -0,0 +1,65 @@
#include <string>
#include <iostream>
using namespace std;
class Expression
{
public:
Expression(){}
virtual ~Expression(){}
virtual bool interpret(string context) = 0;
};
class TerminalExpression: public Expression
{
public:
TerminalExpression(string data) : data(data)
{
cout << "init TerminalExpression" << endl;
}
bool interpret(string context)
{
if(context.find(data) != string::npos)
{
return true;
}
return false;
}
private:
string data;
};
class OrExpression: public Expression
{
public:
OrExpression(Expression *exp1, Expression *exp2) : exp1(exp1), exp2(exp2)
{
cout << "init OrExpression" << endl;
}
bool interpret(string context)
{
return exp1->interpret(context) || exp2->interpret(context);
}
private:
Expression *exp1 = nullptr;
Expression *exp2 = nullptr;
};
class AndExpression: public Expression
{
public:
AndExpression(Expression *exp1, Expression *exp2) : exp1(exp1), exp2(exp2)
{
cout << "init AndExpression" << endl;
}
bool interpret(string context)
{
return exp1->interpret(context) && exp2->interpret(context);
}
private:
Expression *exp1 = nullptr;
Expression *exp2 = nullptr;
};

View File

@ -0,0 +1,2 @@
HEADERS += \
$$PWD/interface.h

View File

@ -0,0 +1,61 @@
#include <string>
#include <vector>
#include <iostream>
using namespace std;
class Iterator
{
public:
Iterator(){}
virtual ~Iterator(){}
virtual bool hasNext() = 0;
virtual string next() = 0;
};
class NameIterator: public Iterator
{
public:
NameIterator(size_t index, std::vector<string> vector) : index(index), vector(vector){}
bool hasNext()
{
if(index < vector.size() - 1)
{
return true;
}
return false;
}
string next()
{
if(this->hasNext())
{
return vector.at(index++);
}
return nullptr;
}
private:
size_t index;
std::vector<string> vector;
};
class Container
{
public:
Container(){}
virtual ~Container(){}
virtual Iterator* getIterator() = 0;
};
class NameRepository: public Container
{
public:
NameRepository(size_t index, std::vector<string> vector) : index(index), vector(vector){}
Iterator* getIterator()
{
return new NameIterator(index, vector);
}
private:
size_t index;
std::vector<string> vector;
};

View File

@ -0,0 +1,2 @@
HEADERS += \
$$PWD/interface.h

331
main.cpp Normal file
View File

@ -0,0 +1,331 @@
//#include "factorypattern/shapefactory.h"
//#include "proxypattern/interface.h"
//#include "templatepattern/interface.h"
//#include "strategypattern/context.h"
//#include "flyweightpattern/shapefactory.h"
//#include "visitorpattern/son.h"
//#include "mediatorpattern/usr.h"
//#include "observerpattern/subject.h"
//#include "statepattern/interface.h"
//#include "commandpattern/broker.h"
//#include "decoratorpattern/second_interface.h"
//#include "bridgepattern/second_interface.h"
//#include "iteratorpattern/interface.h"
//#include "compositepattern/employee.h"
//#include "facadepattern/shapemaker.h"
//#include "adapterpattern/second_interface.h"
//#include "abstractfactorypattern/factoryproducer.h"
//#include "builderpattern/meakbuilder.h"
//#include "prototypepattern/interface.h"
//#include "interpreterpattern/interface.h"
#include "chainofresponsibilitypattern/interface.h"
#include "mementopattern/originator.h"
#include "mementopattern/caretaker.h"
int main()
{
//工厂模式
/*
ShapeFactory shapeFactory;
Circle *circle = static_cast<Circle*>(shapeFactory.getShape("Circle"));
circle->draw();
cout << endl;
Square *square = static_cast<Square*>(shapeFactory.getShape("Square"));
square->draw();
cout << endl;
Rectangle *rectangle = static_cast<Rectangle*>(shapeFactory.getShape("Rectangle"));
rectangle->draw();
*/
//代理模式
/*
Image *image = new ProxyImage("maoye.jpg");
image->display();
*/
//模板模式
/*
Game *game = new Cricket();
game->play();
cout << endl;
game = new Football();
game->play();
*/
//策略模式
/*
Strategy *operationAdd = new OperationAdd();
Strategy *operationSubstract = new OperationSubstract();
Strategy *operationMultiply = new OperationMultiply();
Context *context = new Context(operationAdd);
cout << "10 + 5 = " << context->executeStrategy(10, 5) << endl;
context = new Context(operationSubstract);
cout << "10 - 5 = " << context->executeStrategy(10, 5) << endl;
context = new Context(operationMultiply);
cout << "10 * 5 = " << context->executeStrategy(10, 5) << endl;
*/
//享元模式
/*
ShapeFactory shapeFactory;
string array[] = { "Red", "Blue", "Red", "Yellow", "Blue" };
for (auto color : array)
{
int x = rand() % 100;
int y = rand() % 100;
int radius = rand() % 100;
Circle *circle = static_cast<Circle*>(shapeFactory.getCircle(color));
circle->setX(x);
circle->setY(y);
circle->setRadius(radius);
circle->draw();
}
*/
//访问者模式
/*
ComputerPartDisplayVisitor *cp = new ComputerPartDisplayVisitor();
ComputerPart *computer = new Computer();
ComputerPart *mouse = new Mouse();
ComputerPart *keyboard = new Keyboard();
ComputerPart *monitor = new Monitor();
computer->accept(cp);
cout << endl;
mouse->accept(cp);
keyboard->accept(cp);
monitor->accept(cp);
*/
//中介者模式
/*
User *user1 = new User("Billy");
User *user2 = new User("Kitty");
User *user3 = new User("Alice");
cout << endl;
user1->showMessage("hello");
user2->showMessage("world");
user3->showMessage("!");
*/
//观察者模式
/*
Subject *subject = new Subject(10);
Observer *binaryObserver = new BinaryObserver();
Observer *octalObserver = new OctalObserver();
Observer *hexaObserver = new HexaObserver();
subject->attach(binaryObserver);
subject->attach(octalObserver);
subject->attach(hexaObserver);
cout << subject->getState() << endl;
subject->setState(20);
cout << subject->getState() << endl;
*/
//状态模式
/*
Context *context = new Context();
State *startState = new StartState();
startState->doAction(context);
cout << context->getState()->getString() << endl;
State *stopState = new StopState();
stopState->doAction(context);
cout << context->getState()->getString() << endl;
*/
//命令模式
/*
Stock *stock = new Stock();
Order * buyStock = new BuyStock(stock);
Order * sellStock = new SellStock(stock);
Broker * broker = new Broker();
broker->addOrder(buyStock);
broker->addOrder(sellStock);
broker->executeAllOrder();
*/
//装饰模式
/*
Shape *circle = new Circle();
ShapeDecorator *redCircle = new RedShapeDecorator(new Circle());
ShapeDecorator *redRectangle = new RedShapeDecorator(new Rectangle());
circle->draw();
cout << endl;
redCircle->draw();
cout << endl;
redRectangle->draw();
*/
//桥接模式
/*
DrawApi *redDrawApi = new RedCircle();
DrawApi *greenDrawApi = new GreenCircle();
Shape *redCircle = new Circle(100, 10, 10, redDrawApi);
Shape *greenCircle = new Circle(100, 10, 10, greenDrawApi);
redCircle->draw();
greenCircle->draw();
*/
//迭代器模式
/*
std::vector<string> vector;
vector.push_back("Billy");
vector.push_back("Alice");
vector.push_back("Kitty");
vector.push_back("Ben");
vector.push_back("Jason");
vector.push_back("Jack");
vector.push_back("Miss");
NameRepository *nameRepository = new NameRepository(0, vector);
for(Iterator *iterator = nameRepository->getIterator(); iterator->hasNext();)
{
cout << iterator->next() << endl;
}
*/
//组合模式
/*
Employee *CEO = new Employee("Billy", "CEO", 50000);
Employee *vice_president = new Employee("Killy", "vice_president", 40000);
Employee *lead_engineer = new Employee("Ben", "lead_engineer", 40000);
Employee *marketing_manager1 = new Employee("Jason", "marketing_manager1", 30000);
Employee *marketing_manager2 = new Employee("Jon", "marketing_manager2", 30000);
Employee *artisan1 = new Employee("Alice", "artisan1", 10000);
Employee *artisan2 = new Employee("Sam", "artisan2", 10000);
CEO->add(vice_president);
CEO->add(lead_engineer);
vice_president->add(marketing_manager1);
vice_president->add(marketing_manager2);
lead_engineer->add(artisan1);
lead_engineer->add(artisan2);
cout << endl << "CEO: " << CEO->getDetails() << endl;
for (auto employee : CEO->getVector())
{
cout << endl << "Leader: " << employee->getDetails() << endl;
cout << "Employee: " << endl;
for (auto e : employee->getVector())
{
cout << e->getDetails() << endl;
}
}
*/
//外观模式
/*
ShapeMaker shapeMaker;
shapeMaker.drawCircle();
shapeMaker.drawSquare();
shapeMaker.drawRectangle();
*/
//适配器模式
/*
AudioPlayer *audioPlayer = new AudioPlayer();
audioPlayer->play("mp3", "beyond the horizon.mp3");
audioPlayer->play("mp4", "alone.mp4");
audioPlayer->play("vlc", "far far away.vlc");
audioPlayer->play("avi", "mind me.avi");
*/
//抽象工厂模式
/*
FactoryProducer factoryProducer;
AbstractFactory * shapeFactory = factoryProducer.getFactory("ShapeFactory");
AbstractFactory * colorFactory = factoryProducer.getFactory("ColorFactory");
cout << endl;
Shape * circle = shapeFactory->getShape("Circle");
circle->draw();
cout << endl;
Shape * square = shapeFactory->getShape("Square");
square->draw();
cout << endl;
Shape * rectangle = shapeFactory->getShape("Rectangle");
rectangle->draw();
cout << endl;
Color * red = colorFactory->getColor("Red");
red->fill();
cout << endl;
Color * green = colorFactory->getColor("Green");
green->fill();
cout << endl;
Color * blue = colorFactory->getColor("Blue");
blue->fill();
*/
//建造者模式
/*
MealBuilder * mealBuilder = new MealBuilder();
Meal * vegMeal = mealBuilder->prepareVegMeal();
cout << "Veg Meal" << endl;
vegMeal->showFoods();
cout << "Total Cost: " << vegMeal->getCost() << endl;
Meal * nonVegMeal = mealBuilder->prepareNonVegMeal();
cout << "\n\nNon-Veg Meal" << endl;
nonVegMeal->showFoods();
cout << "Total Cost: " << nonVegMeal->getCost() << endl;
*/
//原型模式
/*
Shape *circle1 = new Circle("circle");
circle1->test();
cout << endl;
Shape *circle2 = circle1->clone();
circle2->test();
cout << endl;
if (circle1 == circle2)
{
cout << "same" << endl;
}
else
{
cout << "different" << endl;
}
*/
//解析器模式
/*
Expression *robert = new TerminalExpression("Robert");
Expression *john = new TerminalExpression("John");
Expression *isMale = new OrExpression(robert, john);
Expression *julie = new TerminalExpression("Julie");
Expression *married = new TerminalExpression("Married");
Expression *isMarriedWoman = new AndExpression(julie, married);
string ret1 = isMale->interpret("John") ? "true" : "false";
string ret2 = isMarriedWoman->interpret("Married Julie") ? "true" : "false";
cout << endl;
cout << "John is male? " + ret1 << endl;
cout << "Julie is a married women? " + ret2 << endl;
*/
//责任链模式
AbstractLogger *errorLogger = new ErrorLogger(AbstractLogger::ERROR);
AbstractLogger *fileLogger = new FileLogger(AbstractLogger::DEBUG);
AbstractLogger *consoleLogger = new ConsoleLogger(AbstractLogger::INFO);
cout << endl;
errorLogger->setNextLogger(fileLogger);
fileLogger->setNextLogger(consoleLogger);
errorLogger->logMessage(AbstractLogger::INFO, "This is an information");
errorLogger->logMessage(AbstractLogger::DEBUG, "This is an debug level information");
errorLogger->logMessage(AbstractLogger::ERROR, "This is an error information");
cout << endl;
fileLogger->logMessage(AbstractLogger::INFO, "This is an information");
fileLogger->logMessage(AbstractLogger::DEBUG, "This is an debug level information");
fileLogger->logMessage(AbstractLogger::ERROR, "This is an error information");
//备忘录模式
/*
Originator *originator = new Originator();
Caretaker *caretaker = new Caretaker();
originator->setState("state #1");
caretaker->add(originator->saveStateToMemento());
originator->setState("state #2");
caretaker->add(originator->saveStateToMemento());
originator->setState("state #3");
caretaker->add(originator->saveStateToMemento());
originator->setState("state #4");
caretaker->add(originator->saveStateToMemento());
originator->setState("state #5");
caretaker->add(originator->saveStateToMemento());
cout << endl;
for(size_t i = 0; i < caretaker->getVectorLength(); i++)
{
originator->getStateFromMemento(caretaker->getMemento(i));
cout << "current state: " + originator->getState() << endl;
}
*/
return 0;
}

View File

@ -0,0 +1,25 @@
#include <string>
#include <ctime>
#include <iostream>
using namespace std;
class ChatRoom
{
public:
void showMessage(string name, string message)
{
time_t setTime;
time(&setTime);
tm* ptm = localtime(&setTime);
std::string time = std::to_string(ptm->tm_year + 1900)
+ "/"
+ std::to_string(ptm->tm_mon + 1)
+ "/"
+ std::to_string(ptm->tm_mday)
+ " "
+ std::to_string(ptm->tm_hour) + ":"
+ std::to_string(ptm->tm_min) + ":"
+ std::to_string(ptm->tm_sec);
cout << time + " [ " + name + " ] : " + message << endl;
}
};

View File

@ -0,0 +1,3 @@
HEADERS += \
$$PWD/chatroom.h \
$$PWD/usr.h

26
mediatorpattern/usr.h Normal file
View File

@ -0,0 +1,26 @@
#include "chatroom.h"
class User
{
public:
User(string name) : name(name)
{
cout << "init user " + name << endl;
}
string getName()
{
return this->name;
}
void setName(string name)
{
this->name = name;
}
void showMessage(string message)
{
ChatRoom chatRoom;
chatRoom.showMessage(this->name, message);
}
private:
string name;
};

View File

@ -0,0 +1,22 @@
#include "memento.h"
#include <vector>
class Caretaker
{
public:
void add(Memento *memento)
{
vector.push_back(memento);
}
Memento *getMemento(size_t index)
{
return vector.at(index);
}
size_t getVectorLength()
{
return vector.size();
}
private:
std::vector<Memento *> vector;
};

20
mementopattern/memento.h Normal file
View File

@ -0,0 +1,20 @@
#pragma once
#include <string>
#include <iostream>
using namespace std;
class Memento
{
public:
Memento(string state) : state(state)
{
cout << "init Memento " + state << endl;
}
string getState()
{
return this->state;
}
private:
string state;
};

View File

@ -0,0 +1,4 @@
HEADERS += \
$$PWD/memento.h \
$$PWD/originator.h \
$$PWD/caretaker.h

View File

@ -0,0 +1,25 @@
#include "memento.h"
class Originator
{
public:
void setState(string state)
{
this->state = state;
}
string getState()
{
return this->state;
}
Memento *saveStateToMemento()
{
return new Memento(this->state);
}
void getStateFromMemento(Memento *memento)
{
this->state = memento->getState();
}
private:
string state;
};

View File

@ -0,0 +1,37 @@
#include <iostream>
using namespace std;
class Observer
{
public:
Observer(){}
virtual ~Observer(){}
virtual void update() = 0;
};
class BinaryObserver: public Observer
{
public:
void update()
{
cout << "BinaryObserver update" << endl;
}
};
class OctalObserver: public Observer
{
public:
void update()
{
cout << "OctalObserver update" << endl;
}
};
class HexaObserver: public Observer
{
public:
void update()
{
cout << "HexaObserver update" << endl;
}
};

View File

@ -0,0 +1,3 @@
HEADERS += \
$$PWD/interface.h \
$$PWD/subject.h

37
observerpattern/subject.h Normal file
View File

@ -0,0 +1,37 @@
#include <vector>
#include "interface.h"
class Subject
{
public:
Subject(size_t state) : state(state) {}
size_t getState()
{
return this->state;
}
void setState(size_t state)
{
this->state = state;
notifyAllObservers();
}
void attach(Observer *observer)
{
vector.push_back(observer);
}
void notifyAllObservers()
{
for(auto itor : vector)
{
itor->update();
}
}
private:
std::vector<Observer*> vector;
size_t state;
};

View File

@ -0,0 +1,40 @@
#include <string>
#include <iostream>
using namespace std;
class Shape
{
public:
Shape()
{
cout << "create Shape" << endl;
}
virtual ~Shape(){}
virtual Shape *clone() = 0;
virtual void test() = 0;
};
class Circle: public Shape
{
public:
Circle(string type) : type(type)
{
cout << "create Circle" << endl;
}
~Circle(){}
Circle(const Circle& circle)
{
this->type = circle.type;
}
Shape *clone()
{
return new Circle(*this);
}
void test()
{
cout << "type: " << type << endl;
}
private:
string type;
};

View File

@ -0,0 +1,2 @@
HEADERS += \
$$PWD/interface.h

52
proxypattern/interface.h Normal file
View File

@ -0,0 +1,52 @@
#include <string>
#include <iostream>
using namespace std;
class Image
{
public:
Image(){}
virtual ~Image(){}
virtual void display() = 0;
};
class RealImage : public Image
{
public:
RealImage(string fileName) : fileName(fileName)
{
loadFromDisk(fileName);
}
void loadFromDisk(string fileName)
{
cout << "Loading " + fileName << endl;
}
void display()
{
cout << "Displaying " + fileName << endl;
}
private:
string fileName;
};
class ProxyImage : public Image
{
public:
ProxyImage(string fileName) : fileName(fileName)
{
realImage = nullptr;
}
void display()
{
if (realImage == nullptr)
{
realImage = new RealImage(fileName);
}
realImage->display();
}
private:
RealImage *realImage;
string fileName;
};

View File

@ -0,0 +1,2 @@
HEADERS += \
$$PWD/interface.h

View File

@ -0,0 +1,83 @@
#include <iostream>
#include <mutex>
using namespace std;
//懒汉式
/*
class SingleObject
{
private:
SingleObject()
{
cout << "create SingleObject" << endl;
}
static SingleObject *instance;
public:
static SingleObject *getInstance()
{
if (instance == nullptr)
{
instance = new SingleObject();
}
return instance;
}
};
SingleObject *SingleObject::instance = nullptr;
*/
//饿汉式
/*
class SingleObject
{
private:
SingleObject()
{
cout << "create SingleObject" << endl;
}
public:
static SingleObject *getInstance()
{
static SingleObject instance;
return &instance;
}
}
*/
//多线程加锁
class SingleObject
{
private:
SingleObject()
{
cout << "create SingleObject" << endl;
}
static SingleObject *instance;
static mutex *my_mutext;
public:
static SingleObject *getInstance()
{
if(instance == nullptr)
{
my_mutext->lock();
instance = new SingleObject();
my_mutext->unlock();
}
return instance;
}
void test()
{
cout << "hello world" << endl;
}
};
SingleObject *SingleObject::instance = nullptr;
mutex *SingleObject::my_mutext = new mutex();

View File

@ -0,0 +1,2 @@
HEADERS += \
$$PWD/singletonpattern.h

21
statepattern/context.h Normal file
View File

@ -0,0 +1,21 @@
class State;
class Context
{
public:
Context()
{
state = nullptr;
}
void setState(State *state)
{
this->state = state;
}
State*getState()
{
return this->state;
}
private:
State *state;
};

41
statepattern/interface.h Normal file
View File

@ -0,0 +1,41 @@
#include "context.h"
#include <string>
#include <iostream>
using namespace std;
class State
{
public:
State(){}
virtual ~State(){}
virtual void doAction(Context *context) = 0;
virtual string getString() = 0;
};
class StartState: public State
{
public:
void doAction(Context *context)
{
cout << "Player is in start state" << endl;
context->setState(this);
}
string getString()
{
return "Start State";
}
};
class StopState: public State
{
public:
void doAction(Context *context)
{
cout << "Player is in stop state" << endl;
context->setState(this);
}
string getString()
{
return "Stop State";
}
};

View File

@ -0,0 +1,6 @@
HEADERS += \
$$PWD/memento.h \
$$PWD/originator.h \
$$PWD/caretaker.h \
$$PWD/context.h \
$$PWD/interface.h

14
strategypattern/context.h Normal file
View File

@ -0,0 +1,14 @@
#include "interface.h"
class Context
{
public:
Context(Strategy *strategy) : strategy(strategy){}
int executeStrategy(int num1, int num2)
{
return strategy->doOperation(num1, num2);
}
private:
Strategy *strategy;
};

View File

@ -0,0 +1,34 @@
class Strategy
{
public:
Strategy(){}
virtual ~Strategy(){}
virtual int doOperation(int num1, int num2) = 0;
};
class OperationAdd : public Strategy
{
public:
int doOperation(int num1, int num2)
{
return num1 + num2;
}
};
class OperationSubstract: public Strategy
{
public:
int doOperation(int num1, int num2)
{
return num1 - num2;
}
};
class OperationMultiply: public Strategy
{
public:
int doOperation(int num1, int num2)
{
return num1 * num2;
}
};

View File

View File

@ -0,0 +1,52 @@
#include <iostream>
using namespace std;
class Game
{
public:
Game(){}
virtual ~Game(){}
virtual void initialize() = 0;
virtual void startPlay() = 0;
virtual void endPlay() = 0;
virtual void play() final
{
initialize();
startPlay();
endPlay();
}
};
class Cricket : public Game
{
public:
void initialize()
{
cout << "Cricket Game Initialized Start playing" << endl;
}
void startPlay()
{
cout << "Cricket Game Started Enjoy the game" << endl;
}
void endPlay()
{
cout << "Cricket Game Finished" << endl;
}
};
class Football : public Game
{
public:
void initialize()
{
cout << "Football Game Initialized Start playing" << endl;
}
void startPlay()
{
cout << "Football Game Started Enjoy the game" << endl;
}
void endPlay()
{
cout << "Football Game Finished" << endl;
}
};

View File

@ -0,0 +1,2 @@
HEADERS += \
$$PWD/interface.h

26
visitorpattern/father.h Normal file
View File

@ -0,0 +1,26 @@
#include <iostream>
using namespace std;
class Computer;
class Mouse;
class Keyboard;
class Monitor;
class ComputerPartVisitor
{
public:
ComputerPartVisitor(){}
virtual ~ComputerPartVisitor(){}
virtual void visit(Computer*computer) = 0;
virtual void visit(Mouse *mouse) = 0;
virtual void visit(Keyboard *keyboard) = 0;
virtual void visit(Monitor *monitor) = 0;
};
class ComputerPart
{
public:
ComputerPart(){}
virtual ~ComputerPart(){}
virtual void accept(ComputerPartVisitor *computerPartVisitor) = 0;
virtual string getString() = 0;
};

92
visitorpattern/son.h Normal file
View File

@ -0,0 +1,92 @@
#include "father.h"
#include <vector>
#include <string>
class Keyboard : public ComputerPart
{
public:
void accept(ComputerPartVisitor *computerPartVisitor)
{
computerPartVisitor->visit(this);
}
string getString()
{
return "Displaying Keyboard";
}
};
class Monitor: public ComputerPart
{
public:
void accept(ComputerPartVisitor *computerPartVisitor)
{
computerPartVisitor->visit(this);
}
string getString()
{
return "Displaying Monitor";
}
};
class Mouse: public ComputerPart
{
public:
void accept(ComputerPartVisitor *computerPartVisitor)
{
computerPartVisitor->visit(this);
}
string getString()
{
return "Displaying Mouse";
}
};
class Computer: public ComputerPart
{
public:
Computer()
{
ComputerPart *keyboard = new Keyboard();
ComputerPart *monitor = new Monitor();
ComputerPart *mouse = new Mouse();
vector.push_back(keyboard);
vector.push_back(monitor);
vector.push_back(mouse);
}
void accept(ComputerPartVisitor *computerPartVisitor)
{
for(size_t i = 0; i < vector.size(); i++)
{
vector.at(i)->accept(computerPartVisitor);
}
computerPartVisitor->visit(this);
}
string getString()
{
return "Displaying Computer";
}
private:
std::vector<ComputerPart *> vector;
};
class ComputerPartDisplayVisitor: public ComputerPartVisitor
{
public:
void visit(Computer *computer)
{
cout << computer->getString() << endl;
}
void visit(Mouse *mouse)
{
cout << mouse->getString() << endl;
}
void visit(Keyboard *keyboard)
{
cout << keyboard->getString() << endl;
}
void visit(Monitor *monitor)
{
cout << monitor->getString() << endl;
}
};

View File

@ -0,0 +1,3 @@
HEADERS += \
$$PWD/father.h \
$$PWD/son.h