From 980f48959c40f7ab09ac04917e85dae623626b92 Mon Sep 17 00:00:00 2001 From: Florent Denef Date: Sat, 23 Jan 2021 15:13:08 +0100 Subject: [PATCH] Beginning the design of the program. It could change in the future. --- CMakeLists.txt | 32 ++++++++++++++++++++++------ class_diagram.puml | 46 +++++++++++++++++++++++++++++++++++++++++ include/cache_files.hpp | 15 ++++++++++++++ include/information.hpp | 14 +++++++++++++ include/network.hpp | 15 ++++++++++++++ src/cache_files.cpp | 1 + src/network.cpp | 1 + 7 files changed, 118 insertions(+), 6 deletions(-) create mode 100644 class_diagram.puml create mode 100644 include/cache_files.hpp create mode 100644 include/information.hpp create mode 100644 include/network.hpp create mode 100644 src/cache_files.cpp create mode 100644 src/network.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ec9704..6613e8f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,23 +8,35 @@ set(CMAKE_CXX_COMPILER_LAUNCHER ccache) find_package(Boost REQUIRED COMPONENTS system) find_package(OpenSSL REQUIRED) +find_package(OpenMP REQUIRED) include_directories(${Boost_INCLUDE_DIR} ${OpenSSL_INCLUDE_DIR}) +set(COMPILE_DEFINITIONS + $<$:_GLIBCXX_DEBUG> + BOOST_ASIO_NO_DEPRECATED + BOOST_ASIO_NO_TS_EXECUTORS + #[[_FORTIFY_SOURCE=2]] + ) + set(COMPILE_FLAGS -pipe -march=skylake # change to native or your architecture. -mtune=skylake # same as above - -mrdrnd + -mrdseed # be careful about this, this is linked to the x86 architecture. + -mrdrnd # same as above + -stdlib=libc++ + -Wpedantic -Wall -Wextra - -Wpessimizing-move - -Wredundant-move + -Wmove + -Wopenmp -funroll-loops -flto=thin -fwhole-program-vtables -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free ) set(LINKER_OPTIONS PRIVATE -Wl,--sort-common,--as-needed + -stdlib=libc++ -flto=thin -fwhole-program-vtables -fuse-ld=gold @@ -32,16 +44,24 @@ set(LINKER_OPTIONS set(LINKER_FLAGS jemalloc + ${Boost_LIBRARIES} + OpenSSL::SSL + OpenMP::OpenMP_CXX ) file(GLOB HEADERS includes/*.hpp) set(FILES - main.cpp) + main.cpp + src/network.cpp + include/information.hpp + src/cache_files.cpp + include/cache_files.hpp + ) add_executable(GeminiServer ${FILES}) target_precompile_headers(GeminiServer PRIVATE ${HEADERS}) -target_compile_definitions(GeminiServer PRIVATE _GLIBCXX_DEBUG BOOST_ASIO_NO_DEPRECATED BOOST_ASIO_NO_TS_EXECUTORS) +target_compile_definitions(GeminiServer PRIVATE ${COMPILE_DEFINITIONS}) target_compile_options(GeminiServer PRIVATE ${COMPILE_FLAGS}) target_link_options(GeminiServer ${LINKER_OPTIONS}) -target_link_libraries(GeminiServer ${Boost_LIBRARIES} ${LINKER_FLAGS} OpenSSL::SSL) \ No newline at end of file +target_link_libraries(GeminiServer ${LINKER_FLAGS}) \ No newline at end of file diff --git a/class_diagram.puml b/class_diagram.puml new file mode 100644 index 0000000..b8b2a18 --- /dev/null +++ b/class_diagram.puml @@ -0,0 +1,46 @@ +@startuml + + +Configuration ..> "produces" Information +Network ..> "uses" TaskRequest +Network ..> "uses" Information +TaskRequest ..> "uses" Information +TaskRequest ..> "uses" CacheFiles + +class TaskRequest { +- request: string +} + +class Network { +- context: io_context +- ssl: ssl::stream + ++ Network() ++ Network(&&) ++ operator=(&&) +} + +class Configuration { ++ filename: const string + ++ Configuration(string filename) ++ create_infos(): Information +} + +class Information { ++ enable_cache: const bool ++ cache_size: const int ++ ssl_pem_path: const path ++ ssl_cert_path: const path +} + +class CacheFiles { +- files: unordered_set +- content: unordered_map + ++ CacheFiles() ++ get_files(): files ++ get_content(): content +} + +@enduml \ No newline at end of file diff --git a/include/cache_files.hpp b/include/cache_files.hpp new file mode 100644 index 0000000..9aa1a0d --- /dev/null +++ b/include/cache_files.hpp @@ -0,0 +1,15 @@ +#ifndef GEMINISERVER_CACHE_FILES_HPP +#define GEMINISERVER_CACHE_FILES_HPP + + +namespace gemini { + /** + * \brief This class is used to store the files in cache. + */ + class CacheFiles { + + }; +} + + +#endif //GEMINISERVER_CACHE_FILES_HPP diff --git a/include/information.hpp b/include/information.hpp new file mode 100644 index 0000000..9afee52 --- /dev/null +++ b/include/information.hpp @@ -0,0 +1,14 @@ +#ifndef GEMINISERVER_INFORMATION_HPP +#define GEMINISERVER_INFORMATION_HPP + +namespace gemini { + /** + * \brief This struct is used to store information inside, used by any other class/struct. + */ + struct Information { + + }; +} + + +#endif //GEMINISERVER_INFORMATION_HPP diff --git a/include/network.hpp b/include/network.hpp new file mode 100644 index 0000000..7abfb51 --- /dev/null +++ b/include/network.hpp @@ -0,0 +1,15 @@ +#ifndef GEMINISERVER_NETWORK_HPP +#define GEMINISERVER_NETWORK_HPP + + +namespace gemini { + /** + * \brief This is class is used for all the network things for the server. + */ + class Network { + + }; +} + + +#endif //GEMINISERVER_NETWORK_HPP diff --git a/src/cache_files.cpp b/src/cache_files.cpp new file mode 100644 index 0000000..9366e7e --- /dev/null +++ b/src/cache_files.cpp @@ -0,0 +1 @@ +#include "../include/cache_files.hpp" diff --git a/src/network.cpp b/src/network.cpp new file mode 100644 index 0000000..89891d4 --- /dev/null +++ b/src/network.cpp @@ -0,0 +1 @@ +#include "../include/network.hpp"