no message

master
a7458969 2020-05-19 00:53:46 +08:00
parent 858356d508
commit 204218c71b
4 changed files with 39 additions and 4 deletions

View File

@ -19,12 +19,13 @@ public:
virtual T* Clone(){ virtual T* Clone(){
} }
} };
template<typename T> template<typename T>
class Prototype{ class Prototype{
public: public:
Prototype(CloneAble<T> *){ Prototype(CloneAble<T> *s){
mProto = s->Clone();
} }
virtual T*GetProduct(){ virtual T*GetProduct(){
return mProto->Clone(); return mProto->Clone();

View File

@ -10,4 +10,4 @@ link_libraries(libGeneral.a)
link_libraries(ws2_32) link_libraries(ws2_32)
link_libraries(${CMAKE_CURRENT_SOURCE_DIR}/../third/lib/libevent.a) link_libraries(${CMAKE_CURRENT_SOURCE_DIR}/../third/lib/libevent.a)
link_libraries(${CMAKE_CURRENT_SOURCE_DIR}/../third/lib/libevent_core.a) link_libraries(${CMAKE_CURRENT_SOURCE_DIR}/../third/lib/libevent_core.a)
add_executable(tcptest src/tcpclient_test.cpp) add_executable(tcptest src/tcpclient_test.cpp src/patterntest/pattern_test.cpp)

View File

@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.15)
project(pattern_test)
message("current dir" ../..)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../general/obj/inc/third/include)
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../../general/obj/inc/)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../general/obj/inc/third/include)
message("shit" ${CMAKE_CURRENT_SOURCE_DIR}/../../../general/obj/inc/)
message("shit" ${CMAKE_CURRENT_SOURCE_DIR}/../../../general/obj/inc/third/include)
add_executable(pattern_test pattern_test.cpp)

View File

@ -0,0 +1,22 @@
//
// Created by 29019 on 2020/5/18.
//
#include "factory.hpp"
class Product :public CloneAble<Product>{
public:
Product *Clone(){
Product *ret = new Product;
ret->mAttribute1 = this->mAttribute1;
ret->mAttribute2 = this->mAttribute2;
return ret;
}
private:
int mAttribute1;
char mAttribute2;
};
int main(){
Product z;
Prototype<Product> x(&z);
x.GetProduct();
}