Skip to content

Commit

Permalink
add Template folder
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredtao committed Oct 19, 2018
1 parent 2ba9544 commit 70c5203
Show file tree
Hide file tree
Showing 34 changed files with 137 additions and 1 deletion.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ enable_testing()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
add_subdirectory(code)

add_subdirectory(Template)
14 changes: 14 additions & 0 deletions Template/Behavior/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FILE(GLOB_RECURSE newList *.h)
set(dirList "")
foreach(arg ${newList})
get_filename_component(dirPath ${arg} PATH)
get_filename_component(folderName ${dirPath} NAME)
set(dirList ${dirList} ${folderName})
endforeach()
LIST(REMOVE_DUPLICATES dirList)
foreach(subDir ${dirList})
add_subdirectory(${subDir})
endforeach()



3 changes: 3 additions & 0 deletions Template/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_subdirectory(Behavior)
add_subdirectory(Create)
add_subdirectory(Struct)
14 changes: 14 additions & 0 deletions Template/Create/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FILE(GLOB_RECURSE newList *.hpp)
set(dirList "")
foreach(arg ${newList})
get_filename_component(dirPath ${arg} PATH)
get_filename_component(folderName ${dirPath} NAME)
set(dirList ${dirList} ${folderName})
endforeach()
LIST(REMOVE_DUPLICATES dirList)
foreach(subDir ${dirList})
add_subdirectory(${subDir})
endforeach()



6 changes: 6 additions & 0 deletions Template/Create/SingleTon/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
get_filename_component(tarName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER TemplatePattern)
19 changes: 19 additions & 0 deletions Template/Create/SingleTon/SingleTon.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once
template <class T>
class SingleTon
{
public:
static T &GetInstance()
{
static T t;
return t;
}
virtual ~SingleTon() {}
SingleTon(const SingleTon &) = delete;
SingleTon(SingleTon &&) = delete;
SingleTon &operator=(const SingleTon &) = delete;
SingleTon &operator=(SingleTon &&) = delete;

protected:
SingleTon() {}
};
40 changes: 40 additions & 0 deletions Template/Create/SingleTon/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "SingleTon.hpp"
#include <chrono>
#include <iostream>
#include <string>
#include <thread>
#include <vector>
using namespace std;
class App : public SingleTon<App>
{
friend class SingleTon<App>;

public:
~App() {}
void showName()
{
cout << "name " << endl;
}

protected:
App() {}
};
void show(int n)
{
this_thread::sleep_for(chrono::milliseconds(n));
cout << &App::GetInstance() << endl;
}
int main()
{
std::vector<std::thread> threadList;
const int N = 10;
for (int i = 0; i < N; ++i)
{
threadList.push_back(thread(show, N - i));
}
for (int i = 0; i < N; ++i)
{
threadList[i].join();
}
return 0;
}
14 changes: 14 additions & 0 deletions Template/Struct/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FILE(GLOB_RECURSE newList *.h)
set(dirList "")
foreach(arg ${newList})
get_filename_component(dirPath ${arg} PATH)
get_filename_component(folderName ${dirPath} NAME)
set(dirList ${dirList} ${folderName})
endforeach()
LIST(REMOVE_DUPLICATES dirList)
foreach(subDir ${dirList})
add_subdirectory(${subDir})
endforeach()



1 change: 1 addition & 0 deletions code/Behavior/Command/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER "DesignPattern")
1 change: 1 addition & 0 deletions code/Behavior/Interpreter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER "DesignPattern")
1 change: 1 addition & 0 deletions code/Behavior/Iterator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER "DesignPattern")
1 change: 1 addition & 0 deletions code/Behavior/Mediator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER "DesignPattern")
1 change: 1 addition & 0 deletions code/Behavior/Memento/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER "DesignPattern")
1 change: 1 addition & 0 deletions code/Behavior/Observer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER "DesignPattern")
1 change: 1 addition & 0 deletions code/Behavior/ResponsibilityChain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER "DesignPattern")
1 change: 1 addition & 0 deletions code/Behavior/State/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER "DesignPattern")
1 change: 1 addition & 0 deletions code/Behavior/Strategy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER "DesignPattern")
1 change: 1 addition & 0 deletions code/Behavior/TemplateMethod/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER "DesignPattern")
1 change: 1 addition & 0 deletions code/Behavior/Visitor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER "DesignPattern")
1 change: 1 addition & 0 deletions code/Create/AbstractFactory/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER "DesignPattern")
1 change: 1 addition & 0 deletions code/Create/Builder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER "DesignPattern")
1 change: 1 addition & 0 deletions code/Create/FactoryMethod/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER "DesignPattern")
1 change: 1 addition & 0 deletions code/Create/Prototype/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER "DesignPattern")
1 change: 1 addition & 0 deletions code/Create/Singleton/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER "DesignPattern")
2 changes: 1 addition & 1 deletion code/Create/Singleton/SingleTon.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class SingleTon
}
SingleTon(const SingleTon &) = delete;
SingleTon &operator=(const SingleTon &) = delete;
virtual ~SingleTon() {}

protected:
SingleTon() {}
virtual ~SingleTon() {}
};
1 change: 1 addition & 0 deletions code/Create/Singleton_Practise/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER "DesignPattern")
1 change: 1 addition & 0 deletions code/Struct/Adapter_01/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER "DesignPattern")
1 change: 1 addition & 0 deletions code/Struct/Adapter_02/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER "DesignPattern")
1 change: 1 addition & 0 deletions code/Struct/Bridge/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER "DesignPattern")
1 change: 1 addition & 0 deletions code/Struct/Composite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER "DesignPattern")
1 change: 1 addition & 0 deletions code/Struct/Decorator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER "DesignPattern")
1 change: 1 addition & 0 deletions code/Struct/Facade/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER "DesignPattern")
1 change: 1 addition & 0 deletions code/Struct/FlyWeight/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER "DesignPattern")
1 change: 1 addition & 0 deletions code/Struct/Proxy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aux_source_directory(. SRC)
file(GLOB_RECURSE CURRENT_HEADERS *.h *.hpp)
add_executable(${tarName} ${SRC} ${CURRENT_HEADERS})
add_test(NAME ${tarName} COMMAND ${tarName})
set_target_properties(${tarName} PROPERTIES FOLDER "DesignPattern")

0 comments on commit 70c5203

Please sign in to comment.