no message
parent
858356d508
commit
204218c71b
|
@ -19,12 +19,13 @@ public:
|
|||
virtual T* Clone(){
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class Prototype{
|
||||
public:
|
||||
Prototype(CloneAble<T> *){
|
||||
|
||||
Prototype(CloneAble<T> *s){
|
||||
mProto = s->Clone();
|
||||
}
|
||||
virtual T*GetProduct(){
|
||||
return mProto->Clone();
|
||||
|
|
|
@ -10,4 +10,4 @@ link_libraries(libGeneral.a)
|
|||
link_libraries(ws2_32)
|
||||
link_libraries(${CMAKE_CURRENT_SOURCE_DIR}/../third/lib/libevent.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)
|
|
@ -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)
|
|
@ -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();
|
||||
}
|
Loading…
Reference in New Issue