瀏覽代碼

Merge branch 'modulize' of public/ls-standard-library into development

Lynar Studios - Public Repositories 2 年之前
父節點
當前提交
fae3395b7f
共有 3 個文件被更改,包括 294 次插入60 次删除
  1. 271 21
      CMakeLists.txt
  2. 21 37
      README.md
  3. 2 2
      test/TestHelper.hpp

+ 271 - 21
CMakeLists.txt

@@ -1,3 +1,11 @@
+####################################################################################################################
+####################################################################################################################
+####################################################################################################################
+# General
+####################################################################################################################
+####################################################################################################################
+####################################################################################################################
+
 ##########################################################
 # Basic
 ##########################################################
@@ -17,11 +25,33 @@ set(MODULE_NAME_TIME ls_std_time)
 # Options
 ##########################################################
 
-option(LS_STD_BUILD_WITH_TESTS "Build project with tests..." OFF)
+option(LS_STD_BUILD_WITH_TESTS "Build project with tests..." ON)
 option(LS_STD_BUILD_STATIC "Build ls_std static library..." ON)
 option(LS_STD_BUILD_SHARED "Build ls_std shared library..." OFF)
 option(LS_STD_BUILD_MODULE "Build ls_std module library..." OFF)
 
+set(TARGET_COUNTER 0)
+
+if (${LS_STD_BUILD_STATIC})
+    math(EXPR TARGET_COUNTER "${TARGET_COUNTER} + 1")
+    message("${PROJECT_NAME}: [Goal] static library")
+endif ()
+
+if (${LS_STD_BUILD_SHARED})
+    math(EXPR TARGET_COUNTER "${TARGET_COUNTER} + 1")
+    message("${PROJECT_NAME}: [Goal] shared library")
+endif ()
+
+if (${LS_STD_BUILD_MODULE})
+    math(EXPR TARGET_COUNTER "${TARGET_COUNTER} + 1")
+    message("${PROJECT_NAME}: [Goal] module library")
+endif ()
+
+if (TARGET_COUNTER GREATER 1)
+    message("${PROJECT_NAME}: [Error] only one goal supported at the same time!")
+    return()
+endif ()
+
 ##########################################################
 # Compiler Settings
 ##########################################################
@@ -55,9 +85,13 @@ if (${LS_STD_BUILD_WITH_TESTS})
     add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/test/lib/googletest-1.8.1)
 endif ()
 
-##########################################################
-# Source Files
-##########################################################
+####################################################################################################################
+####################################################################################################################
+####################################################################################################################
+# Source Files Modularization
+####################################################################################################################
+####################################################################################################################
+####################################################################################################################
 
 set(SOURCE_FILES_BOXING
         ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/boxing/Boolean.cpp
@@ -112,6 +146,14 @@ set(SOURCE_FILES_LOGIC
 set(SOURCE_FILES_TIME
         ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/time/Date.cpp)
 
+####################################################################################################################
+####################################################################################################################
+####################################################################################################################
+# Test Files Modularization
+####################################################################################################################
+####################################################################################################################
+####################################################################################################################
+
 if (${LS_STD_BUILD_WITH_TESTS})
     set(TEST_FILES_BOXING
             ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/boxing/BooleanTest.cpp
@@ -193,6 +235,14 @@ if (${LS_STD_BUILD_WITH_TESTS})
             ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/time/DateTest.cpp)
 endif ()
 
+####################################################################################################################
+####################################################################################################################
+####################################################################################################################
+# Test Suite Builds
+####################################################################################################################
+####################################################################################################################
+####################################################################################################################
+
 ##########################################################
 # Build Tests (boxing)
 ##########################################################
@@ -257,7 +307,7 @@ if (${LS_STD_BUILD_WITH_TESTS})
 endif ()
 
 ##########################################################
-# Build Tests
+# Build Tests (all)
 ##########################################################
 
 if (${LS_STD_BUILD_WITH_TESTS})
@@ -273,6 +323,14 @@ if (${LS_STD_BUILD_WITH_TESTS})
             ${TEST_FILES_TIME})
 endif ()
 
+####################################################################################################################
+####################################################################################################################
+####################################################################################################################
+# Build Library Binaries
+####################################################################################################################
+####################################################################################################################
+####################################################################################################################
+
 ##########################################################
 # Build Library (boxing)
 ##########################################################
@@ -305,6 +363,16 @@ if (${LS_STD_BUILD_STATIC})
     set_target_properties("${MODULE_NAME_CORE}" PROPERTIES DEBUG_POSTFIX "_d")
 endif ()
 
+if (${LS_STD_BUILD_SHARED})
+    add_library("${MODULE_NAME_CORE}" SHARED ${SOURCE_FILES_CORE})
+    set_target_properties("${MODULE_NAME_CORE}" PROPERTIES DEBUG_POSTFIX "_d")
+endif ()
+
+if (${LS_STD_BUILD_MODULE})
+    add_library("${MODULE_NAME_CORE}" MODULE ${SOURCE_FILES_CORE})
+    set_target_properties("${MODULE_NAME_CORE}" PROPERTIES DEBUG_POSTFIX "_d")
+endif ()
+
 ##########################################################
 # Build Library (encoding)
 ##########################################################
@@ -316,6 +384,16 @@ if (${LS_STD_BUILD_STATIC})
     set_target_properties("${MODULE_NAME_ENCODING}" PROPERTIES DEBUG_POSTFIX "_d")
 endif ()
 
+if (${LS_STD_BUILD_SHARED})
+    add_library("${MODULE_NAME_ENCODING}" SHARED ${SOURCE_FILES_ENCODING})
+    set_target_properties("${MODULE_NAME_ENCODING}" PROPERTIES DEBUG_POSTFIX "_d")
+endif ()
+
+if (${LS_STD_BUILD_MODULE})
+    add_library("${MODULE_NAME_ENCODING}" MODULE ${SOURCE_FILES_ENCODING})
+    set_target_properties("${MODULE_NAME_ENCODING}" PROPERTIES DEBUG_POSTFIX "_d")
+endif ()
+
 ##########################################################
 # Build Library (event)
 ##########################################################
@@ -327,6 +405,16 @@ if (${LS_STD_BUILD_STATIC})
     set_target_properties("${MODULE_NAME_EVENT}" PROPERTIES DEBUG_POSTFIX "_d")
 endif ()
 
+if (${LS_STD_BUILD_SHARED})
+    add_library("${MODULE_NAME_EVENT}" SHARED ${SOURCE_FILES_EVENT})
+    set_target_properties("${MODULE_NAME_EVENT}" PROPERTIES DEBUG_POSTFIX "_d")
+endif ()
+
+if (${LS_STD_BUILD_MODULE})
+    add_library("${MODULE_NAME_EVENT}" MODULE ${SOURCE_FILES_EVENT})
+    set_target_properties("${MODULE_NAME_EVENT}" PROPERTIES DEBUG_POSTFIX "_d")
+endif ()
+
 ##########################################################
 # Build Library (io)
 ##########################################################
@@ -338,6 +426,16 @@ if (${LS_STD_BUILD_STATIC})
     set_target_properties("${MODULE_NAME_IO}" PROPERTIES DEBUG_POSTFIX "_d")
 endif ()
 
+if (${LS_STD_BUILD_SHARED})
+    add_library("${MODULE_NAME_IO}" SHARED ${SOURCE_FILES_IO})
+    set_target_properties("${MODULE_NAME_IO}" PROPERTIES DEBUG_POSTFIX "_d")
+endif ()
+
+if (${LS_STD_BUILD_MODULE})
+    add_library("${MODULE_NAME_IO}" MODULE ${SOURCE_FILES_IO})
+    set_target_properties("${MODULE_NAME_IO}" PROPERTIES DEBUG_POSTFIX "_d")
+endif ()
+
 ##########################################################
 # Build Library (logic)
 ##########################################################
@@ -349,6 +447,16 @@ if (${LS_STD_BUILD_STATIC})
     set_target_properties("${MODULE_NAME_LOGIC}" PROPERTIES DEBUG_POSTFIX "_d")
 endif ()
 
+if (${LS_STD_BUILD_SHARED})
+    add_library("${MODULE_NAME_LOGIC}" SHARED ${SOURCE_FILES_LOGIC})
+    set_target_properties("${MODULE_NAME_LOGIC}" PROPERTIES DEBUG_POSTFIX "_d")
+endif ()
+
+if (${LS_STD_BUILD_MODULE})
+    add_library("${MODULE_NAME_LOGIC}" MODULE ${SOURCE_FILES_LOGIC})
+    set_target_properties("${MODULE_NAME_LOGIC}" PROPERTIES DEBUG_POSTFIX "_d")
+endif ()
+
 ##########################################################
 # Build Library (time)
 ##########################################################
@@ -360,11 +468,29 @@ if (${LS_STD_BUILD_STATIC})
     set_target_properties("${MODULE_NAME_TIME}" PROPERTIES DEBUG_POSTFIX "_d")
 endif ()
 
+if (${LS_STD_BUILD_SHARED})
+    add_library("${MODULE_NAME_TIME}" SHARED ${SOURCE_FILES_TIME})
+    set_target_properties("${MODULE_NAME_TIME}" PROPERTIES DEBUG_POSTFIX "_d")
+endif ()
+
+if (${LS_STD_BUILD_MODULE})
+    add_library("${MODULE_NAME_TIME}" MODULE ${SOURCE_FILES_TIME})
+    set_target_properties("${MODULE_NAME_TIME}" PROPERTIES DEBUG_POSTFIX "_d")
+endif ()
+
+####################################################################################################################
+####################################################################################################################
+####################################################################################################################
+# Test Suite: Static Linking
+####################################################################################################################
+####################################################################################################################
+####################################################################################################################
+
 ##########################################################
-# Linking (boxing)
+# Static Linking (boxing)
 ##########################################################
 
-if (${LS_STD_BUILD_WITH_TESTS})
+if (${LS_STD_BUILD_WITH_TESTS} AND ${LS_STD_BUILD_STATIC})
     message("${MODULE_NAME_BOXING}: Linking libraries for test application...")
     target_link_libraries(${MODULE_NAME_BOXING}_test
             gtest
@@ -375,10 +501,10 @@ if (${LS_STD_BUILD_WITH_TESTS})
 endif ()
 
 ##########################################################
-# Linking (core)
+# Static Linking (core)
 ##########################################################
 
-if (${LS_STD_BUILD_WITH_TESTS})
+if (${LS_STD_BUILD_WITH_TESTS} AND ${LS_STD_BUILD_STATIC})
     message("${MODULE_NAME_CORE}: Linking libraries for test application...")
     target_link_libraries(${MODULE_NAME_CORE}_test
             gtest
@@ -388,10 +514,10 @@ if (${LS_STD_BUILD_WITH_TESTS})
 endif ()
 
 ##########################################################
-# Linking (encoding)
+# Static Linking (encoding)
 ##########################################################
 
-if (${LS_STD_BUILD_WITH_TESTS})
+if (${LS_STD_BUILD_WITH_TESTS} AND ${LS_STD_BUILD_STATIC})
     message("${MODULE_NAME_ENCODING}: Linking libraries for test application...")
     target_link_libraries(${MODULE_NAME_ENCODING}_test
             gtest
@@ -402,10 +528,10 @@ if (${LS_STD_BUILD_WITH_TESTS})
 endif ()
 
 ##########################################################
-# Linking (event)
+# Static Linking (event)
 ##########################################################
 
-if (${LS_STD_BUILD_WITH_TESTS})
+if (${LS_STD_BUILD_WITH_TESTS} AND ${LS_STD_BUILD_STATIC})
     message("${MODULE_NAME_EVENT}: Linking libraries for test application...")
     target_link_libraries(${MODULE_NAME_EVENT}_test
             gtest
@@ -416,10 +542,10 @@ if (${LS_STD_BUILD_WITH_TESTS})
 endif ()
 
 ##########################################################
-# Linking (io)
+# Static Linking (io)
 ##########################################################
 
-if (${LS_STD_BUILD_WITH_TESTS})
+if (${LS_STD_BUILD_WITH_TESTS} AND ${LS_STD_BUILD_STATIC})
     message("${MODULE_NAME_IO}: Linking libraries for test application...")
     target_link_libraries(${MODULE_NAME_IO}_test
             gtest
@@ -430,10 +556,10 @@ if (${LS_STD_BUILD_WITH_TESTS})
 endif ()
 
 ##########################################################
-# Linking (logic)
+# Static Linking (logic)
 ##########################################################
 
-if (${LS_STD_BUILD_WITH_TESTS})
+if (${LS_STD_BUILD_WITH_TESTS} AND ${LS_STD_BUILD_STATIC})
     message("${MODULE_NAME_LOGIC}: Linking libraries for test application...")
     target_link_libraries(${MODULE_NAME_LOGIC}_test
             gtest
@@ -444,10 +570,10 @@ if (${LS_STD_BUILD_WITH_TESTS})
 endif ()
 
 ##########################################################
-# Linking (time)
+# Static Linking (time)
 ##########################################################
 
-if (${LS_STD_BUILD_WITH_TESTS})
+if (${LS_STD_BUILD_WITH_TESTS} AND ${LS_STD_BUILD_STATIC})
     message("${MODULE_NAME_TIME}: Linking libraries for test application...")
     target_link_libraries(${MODULE_NAME_TIME}_test
             gtest
@@ -458,10 +584,134 @@ if (${LS_STD_BUILD_WITH_TESTS})
 endif ()
 
 ##########################################################
-# Linking
+# Static Linking (all)
 ##########################################################
 
-if (${LS_STD_BUILD_WITH_TESTS})
+if (${LS_STD_BUILD_WITH_TESTS} AND ${LS_STD_BUILD_STATIC})
+    message("${PROJECT_NAME}: Linking libraries for test application...")
+    target_link_libraries(${PROJECT_NAME}_test
+            gtest
+            gmock
+            gtest_main
+            "${MODULE_NAME_CORE}"
+            "${MODULE_NAME_BOXING}"
+            "${MODULE_NAME_ENCODING}"
+            "${MODULE_NAME_EVENT}"
+            "${MODULE_NAME_IO}"
+            "${MODULE_NAME_LOGIC}"
+            "${MODULE_NAME_TIME}")
+endif ()
+
+####################################################################################################################
+####################################################################################################################
+####################################################################################################################
+# Test Suite: Dynamic Linking
+####################################################################################################################
+####################################################################################################################
+####################################################################################################################
+
+##########################################################
+# Dynamic Linking (boxing)
+##########################################################
+
+if (${LS_STD_BUILD_WITH_TESTS} AND ${LS_STD_BUILD_SHARED})
+    message("${MODULE_NAME_BOXING}: Linking libraries for test application...")
+    target_link_libraries(${MODULE_NAME_BOXING}_test
+            gtest
+            gmock
+            gtest_main
+            "${MODULE_NAME_BOXING}"
+            "${MODULE_NAME_CORE}")
+endif ()
+
+##########################################################
+# Dynamic Linking (core)
+##########################################################
+
+if (${LS_STD_BUILD_WITH_TESTS} AND ${LS_STD_BUILD_SHARED})
+    message("${MODULE_NAME_CORE}: Linking libraries for test application...")
+    target_link_libraries(${MODULE_NAME_CORE}_test
+            gtest
+            gmock
+            gtest_main
+            "${MODULE_NAME_CORE}")
+endif ()
+
+##########################################################
+# Dynamic Linking (encoding)
+##########################################################
+
+if (${LS_STD_BUILD_WITH_TESTS} AND ${LS_STD_BUILD_SHARED})
+    message("${MODULE_NAME_ENCODING}: Linking libraries for test application...")
+    target_link_libraries(${MODULE_NAME_ENCODING}_test
+            gtest
+            gmock
+            gtest_main
+            "${MODULE_NAME_ENCODING}"
+            "${MODULE_NAME_CORE}")
+endif ()
+
+##########################################################
+# Dynamic Linking (event)
+##########################################################
+
+if (${LS_STD_BUILD_WITH_TESTS} AND ${LS_STD_BUILD_SHARED})
+    message("${MODULE_NAME_EVENT}: Linking libraries for test application...")
+    target_link_libraries(${MODULE_NAME_EVENT}_test
+            gtest
+            gmock
+            gtest_main
+            "${MODULE_NAME_EVENT}"
+            "${MODULE_NAME_CORE}")
+endif ()
+
+##########################################################
+# Dynamic Linking (io)
+##########################################################
+
+if (${LS_STD_BUILD_WITH_TESTS} AND ${LS_STD_BUILD_SHARED})
+    message("${MODULE_NAME_IO}: Linking libraries for test application...")
+    target_link_libraries(${MODULE_NAME_IO}_test
+            gtest
+            gmock
+            gtest_main
+            "${MODULE_NAME_IO}"
+            "${MODULE_NAME_CORE}")
+endif ()
+
+##########################################################
+# Dynamic Linking (logic)
+##########################################################
+
+if (${LS_STD_BUILD_WITH_TESTS} AND ${LS_STD_BUILD_SHARED})
+    message("${MODULE_NAME_LOGIC}: Linking libraries for test application...")
+    target_link_libraries(${MODULE_NAME_LOGIC}_test
+            gtest
+            gmock
+            gtest_main
+            "${MODULE_NAME_LOGIC}"
+            "${MODULE_NAME_CORE}")
+endif ()
+
+##########################################################
+# Dynamic Linking (time)
+##########################################################
+
+if (${LS_STD_BUILD_WITH_TESTS} AND ${LS_STD_BUILD_SHARED})
+    message("${MODULE_NAME_TIME}: Linking libraries for test application...")
+    target_link_libraries(${MODULE_NAME_TIME}_test
+            gtest
+            gmock
+            gtest_main
+            "${MODULE_NAME_TIME}"
+            "${MODULE_NAME_CORE}")
+endif ()
+
+##########################################################
+# Dynamic Linking (all)
+##########################################################
+
+if (${LS_STD_BUILD_WITH_TESTS} AND ${LS_STD_BUILD_SHARED})
     message("${PROJECT_NAME}: Linking libraries for test application...")
     target_link_libraries(${PROJECT_NAME}_test
             gtest

+ 21 - 37
README.md

@@ -1,55 +1,36 @@
 # Lynar Studios - Standard Library 2022.1.0 #
 
-This is a cross-platform standard library written in C++ offering functionalities you'd usually miss in C++ standard library, especially if you'd search for cross-platform implementations. This library has been tested on __Windows__, __Linux__ and __MacOS__ systems.
+This is a cross-platform standard library written in C++ offering functionalities you'd usually miss in C++'s standard template library (STL), especially if you'd search for cross-platform implementations. This library has been tested on __Windows__, __Linux__ and __MacOS__ systems.
+Following a modularized approach the following submodules are defined in scope of this library, which are independent:
  
 #### Boxing ####
 
-This library provides boxing classes for primitive data types (e.g. string, int, long, float...) to add additional functionalities for each one of them.
- 
-#### File ####
-
-To handle file operations - or to receive information of a file - this library provides an own __File__ class implementation, which can also be passed to library implemented input or output stream classes.
-
-#### Base ####
-
-This is a collection of very basic functionalities like a base __Class__ which provides minimal reflection like class name. Also, you have the possibility with this collection to fetch this libraries version or even handle own versions for your project.
-
-#### Time ####
-
-A __Date__ class comes with this collection, which you can use to represent a date and doing operations on it. 
-
-#### Logic ####
-
-This collection of classes provides some nice functionalities to support your project with some nice logical features, like state machines and observer pattern supporting classes.
-
-#### Serialization ####
-
-Serialization is very important nowadays to persist data. This library offers a serializable interface, which can then be implemented in your project.  
-In addition to that there is already JSON serialization-based implementation for some public library classes.
+This library module provides boxing classes for primitive data types (e.g. string, int, long, float...) to add additional functionalities for each one of them.
 
-#### JSON ####
+#### Core ####
 
-This library uses a transitive JSON dependency, which is in line with our license model. Many thanks to __Niels Lohmann__ for writing this nice little library.
+The core module is a base module providing a base __Class__, exceptions, data types and interfaces. Usually the other submodules are dependent on this module. 
 
-#### XML ####
+#### Encoding ####
 
-To handle XML files this library has an own XML parser implementation, which uses modern C++ features, such as shared pointers.
+To encode a byte field (e.g. binaries) for transfer the __Base64__ encoding / decoding functionality is being provided by this submodule as a first feature.
 
-#### Logger ####
+#### Event ####
 
-For logging functionality you might need for your project there is a __Logger__ class coming with this library, which is also able to handle different log level.
+This submodule comes with an __Event__ class, as well as with handlers and managers to provide an intuitive event managing for your application.
 
-#### Event Handling ####
+#### IO ####
 
-With this first implemented milestone of event handling this library provides functionalities for creating and firing events.
+To handle file operations - or to receive information of a file - this library submodule provides an own __File__ class implementation, which can also be passed to library implemented input or output stream classes.  
+Additionally __XML__ and __KV__ parsing functionalities are provided by this submodule.
 
-#### Exception ####
+#### Logic ####
 
-This library provides some basic exceptions which can be used in your project to create awareness of certain error behaviour.
+Functionalities provided by this submodule support your project with some nice logical features. The first one being provided by it is a state machine.
 
-#### KV ####
+#### Time ####
 
-A key value file offers the possibility to store simple information pairs in a file. This library provides parsing functionalities for __.kv__ files.
+A __Date__ class comes with this submodule, which you can use to represent a date and do operations on it. 
 
 ### Changelog ###
 
@@ -59,11 +40,14 @@ A key value file offers the possibility to store simple information pairs in a f
 
 #### Improvements ####
 
-- TBA
+- modularization has been improved by restructuring library files, which would result into having submodules - __there is no central header or binary file anymore__ - instead submodules can be linked independently now (e.g. using __ls_std_event.hpp__ and linking __libls_std_event.so__)
+- there is a cmake guard now to ensure that only one goal at the time is being build
+- test suites for shared libraries have been introduced to ensure that building and linking created shared library is working
+- namespaces have been improved library wide and are more specific - __there is no _ls_std_ namespace anymore__ - instead you can choose submodule specific namespaces (e.g. _ls::std::boxing::_)
 
 #### Fixes ####
 
-- TBA
+- there is a cmake guard now to ensure that only one goal at the time is being build
 
 ### Documentation ###
 

+ 2 - 2
test/TestHelper.hpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-08-15
- * Changed:         2022-05-16
+ * Changed:         2022-05-19
  *
  * */
 
@@ -156,7 +156,7 @@ namespace ls_std_test
 
       #ifdef _WIN32
 
-      ::std::string _getWorkingDirectoryWindows()
+      static ::std::string _getWorkingDirectoryWindows()
       {
         ::std::string workingDirectory{};
         TCHAR buffer[MAX_PATH];