添加prototype设计模式

master
a7458969 2020-05-18 21:34:05 +08:00
parent 929c964164
commit 858356d508
2 changed files with 27 additions and 18 deletions

View File

@ -20,8 +20,7 @@
</component> </component>
<component name="CMakeRunConfigurationManager" shouldGenerate="true" shouldDeleteObsolete="true"> <component name="CMakeRunConfigurationManager" shouldGenerate="true" shouldDeleteObsolete="true">
<generated> <generated>
<config projectName="generallib" targetName="General" /> <config projectName="General" targetName="General" />
<config projectName="generallib" targetName="generallib" />
</generated> </generated>
</component> </component>
<component name="CMakeSettings" AUTO_RELOAD="true"> <component name="CMakeSettings" AUTO_RELOAD="true">
@ -86,21 +85,24 @@
<recent name="D:\project\c++\generallib\src\encrypt" /> <recent name="D:\project\c++\generallib\src\encrypt" />
</key> </key>
</component> </component>
<component name="RunManager" selected="CMake Application.General"> <component name="RunDashboard">
<configuration name="General" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="generallib" TARGET_NAME="General" CONFIG_NAME="Debug"> <option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager">
<configuration name="General" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS_2="true" PROJECT_NAME="General" TARGET_NAME="General" CONFIG_NAME="Debug">
<method v="2"> <method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" /> <option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method> </method>
</configuration> </configuration>
<configuration name="generallib" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="generallib" TARGET_NAME="generallib" CONFIG_NAME="Debug">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
<list>
<item itemvalue="CMake Application.generallib" />
<item itemvalue="CMake Application.General" />
</list>
</component> </component>
<component name="SvnConfiguration"> <component name="SvnConfiguration">
<configuration /> <configuration />
@ -174,12 +176,13 @@
<map> <map>
<entry key="MAIN"> <entry key="MAIN">
<value> <value>
<State /> <State>
<option name="COLUMN_ORDER" />
</State>
</value> </value>
</entry> </entry>
</map> </map>
</option> </option>
<option name="oldMeFiltersMigrated" value="true" />
</component> </component>
<component name="WindowStateProjectService"> <component name="WindowStateProjectService">
<state x="361" y="110" key="#New_File_Extensions" timestamp="1589793685936"> <state x="361" y="110" key="#New_File_Extensions" timestamp="1589793685936">

View File

@ -13,18 +13,24 @@ public:
return nullptr; return nullptr;
} }
}; };
template<typename T>
class CloneAble{
public:
virtual T* Clone(){
}
}
template<typename T> template<typename T>
class Prototype{ class Prototype{
public: public:
Prototype(T ){ Prototype(CloneAble<T> *){
} }
virtual T*GetProduct(){ virtual T*GetProduct(){
return mProto->Clone();
} }
private: private:
T *mProto; CloneAble<T> *mProto;
Prototype(){} Prototype(){}
}; };
#endif //GENERAL_FACTORY_HPP #endif //GENERAL_FACTORY_HPP