diff --git a/.travis.yml b/.travis.yml
index e593d94..51965cc 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -76,12 +76,7 @@ before_script:
- popd
script:
- - VERBOSE=1 cmake --build build
-
-after_success:
- - pushd build
- - GTEST_COLOR=1 ctest --verbose
- - popd
+ - VERBOSE=1 cmake --build build && pushd build && GTEST_COLOR=1 ctest --verbose && popd
notifications:
slack:
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..5d8f5b6
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,16 @@
+# Change Log
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](http://keepachangelog.com/)
+and this project adheres to [Semantic Versioning](http://semver.org/).
+
+## [unreleased]
+### Added
+ - Custom plugin loaders (old version supported only shared libraries).
+
+### Changed
+ - Interface and implementation separation.
+ - Changed plugin API.
+ - Fixed MinGW build.
+
+[unreleased]: https://github.com/georgievlab/CeCe-core/compare/v0.6.0...HEAD
diff --git a/CMake/Functions.cmake b/CMake/Functions.cmake
new file mode 100644
index 0000000..f949aae
--- /dev/null
+++ b/CMake/Functions.cmake
@@ -0,0 +1,128 @@
+# ######################################################################### #
+# Georgiev Lab (c) 2015-2016 #
+# ######################################################################### #
+# Department of Cybernetics #
+# Faculty of Applied Sciences #
+# University of West Bohemia in Pilsen #
+# ######################################################################### #
+# #
+# This file is part of CeCe. #
+# #
+# CeCe is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# CeCe is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with CeCe. If not, see . #
+# #
+# ######################################################################### #
+
+##
+## Add CeCe test.
+## NAME: Test name
+##
+function (cece_add_test NAME)
+ if (NOT CECE_TESTS_BUILD)
+ return ()
+ endif ()
+
+ set(FULLNAME "cece-${NAME}_test")
+
+ include(CMakeParseArguments)
+ cmake_parse_arguments(ARG "" "" "SOURCES;LIBRARIES" ${ARGN})
+
+ # Create executable
+ add_executable(${FULLNAME}
+ ${ARG_SOURCES}
+ )
+
+ # Properties
+ set_target_properties(${FULLNAME} PROPERTIES
+ CXX_STANDARD 11
+ CXX_EXTENSIONS Off
+ CXX_STANDARD_REQUIRED On
+ )
+
+ # Libraries
+ target_link_libraries(${FULLNAME}
+ PRIVATE cece
+ PRIVATE ${ARG_LIBRARIES}
+ PRIVATE gtest_main
+ )
+
+ if (CMAKE_COMPILER_IS_GNUCXX AND CECE_TESTS_BUILD AND CECE_COVERAGE)
+ target_compile_options(${FULLNAME} PRIVATE --coverage)
+ target_link_libraries(${FULLNAME} PRIVATE --coverage)
+ endif ()
+
+ # Register test
+ add_test(
+ NAME ${FULLNAME}
+ COMMAND ${FULLNAME}
+ WORKING_DIRECTORY $
+ )
+
+ if (WIN32 OR MINGW)
+ # Windows doen't support rpath, so we need to copy the main library to the test executable
+ add_custom_command(TARGET ${FULLNAME} POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy $ $
+ )
+ endif ()
+endfunction ()
+
+# ######################################################################### #
+
+##
+## Initialize GIT submodule
+## PATH: Submodule path
+## [CHECK]: Path to tested file in submodule (default CMakeLists.txt)
+##
+function(cece_init_submodule PATH)
+ if (ARGC GREATER 1)
+ set(TEST_PATH "${PATH}/${ARGV1}")
+ else ()
+ set(TEST_PATH "${PATH}/CMakeLists.txt")
+ endif ()
+
+ # Check if file exists
+ if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_PATH}")
+ find_package(Git REQUIRED)
+ execute_process(
+ COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive ${PATH}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ )
+ endif ()
+endfunction ()
+
+# ######################################################################### #
+
+##
+## Initialize vendor submodule (in `vendor` directory).
+## PATH: Vendor submodule name
+## [CHECK]: Path to tested file in submodule (default CMakeLists.txt)
+##
+function(cece_init_vendor PATH)
+ cece_init_submodule(vendor/${PATH} ${ARGN})
+endfunction ()
+
+# ######################################################################### #
+
+##
+## Enable CCACHE for given directory.
+## DIRECTORY: Cache directory.
+##
+function (cece_enable_ccache)
+ find_program(CCACHE_FOUND ccache)
+ if (CCACHE_FOUND)
+ set_property(DIRECTORY ${DIRECTORY} PROPERTY RULE_LAUNCH_COMPILE ccache)
+ set_property(DIRECTORY ${DIRECTORY} PROPERTY RULE_LAUNCH_LINK ccache)
+ endif ()
+endfunction ()
+
+# ######################################################################### #
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5213778..8b92537 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,12 +28,16 @@ cmake_minimum_required(VERSION 3.1)
# ######################################################################### #
project(cece
- VERSION 0.6.0
+ VERSION 0.7.0
LANGUAGES CXX
)
# ######################################################################### #
+include(CMake/Functions.cmake)
+
+# ######################################################################### #
+
# Options
option(CECE_RENDER "Enable simulation rendering (vizualization support)" On)
option(CECE_RENDER_CHECK_ERRORS "Enable renderer errors checking." Off)
@@ -52,6 +56,11 @@ if (APPLE)
set(MACOSX_VERSION_MIN "10.9" CACHE STRING "Minimum version of MacOS X to support")
endif ()
+# Allow to enable code coverage, only for tests and GCC
+if (CMAKE_COMPILER_IS_GNUCXX AND CECE_TESTS_BUILD)
+ option(CECE_COVERAGE "Enable code coverage generation for tests" Off)
+endif ()
+
# ######################################################################### #
# Build unit tests
@@ -59,13 +68,7 @@ if (CECE_TESTS_BUILD)
enable_testing()
# Init google test submodule
- if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/vendor/googletest/CMakeLists.txt")
- find_package(Git REQUIRED)
- execute_process(
- COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive vendor/googletest
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- )
- endif ()
+ cece_init_vendor(googletest)
message(STATUS "Build unit tests")
set(BUILD_GMOCK Off CACHE BOOL "" FORCE)
@@ -75,21 +78,11 @@ if (CECE_TESTS_BUILD)
add_subdirectory(vendor/googletest)
target_include_directories(gtest INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/vendor/googletest/include)
- find_program(CCACHE_FOUND ccache)
- if (CCACHE_FOUND)
- set_property(DIRECTORY vendor/googletest PROPERTY RULE_LAUNCH_COMPILE ccache)
- set_property(DIRECTORY vendor/googletest PROPERTY RULE_LAUNCH_LINK ccache)
- endif ()
+ cece_enable_ccache(vendor/googletest)
endif ()
-# Init google test submodule
-if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/vendor/Box2D/Box2D/CMakeLists.txt")
- find_package(Git REQUIRED)
- execute_process(
- COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive vendor/Box2D
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- )
-endif ()
+# Init Box2D submodule
+cece_init_vendor(Box2D Box2D/CMakeLists.txt)
# Add Box2D physics library
set(BOX2D_BUILD_EXAMPLES Off CACHE BOOL "" FORCE)
@@ -104,15 +97,47 @@ add_subdirectory(vendor/Box2D/Box2D)
set_target_properties(Box2D PROPERTIES POSITION_INDEPENDENT_CODE On)
target_include_directories(Box2D INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/vendor/Box2D/Box2D)
-find_program(CCACHE_FOUND ccache)
-if (CCACHE_FOUND)
- set_property(DIRECTORY vendor/Box2D/Box2D PROPERTY RULE_LAUNCH_COMPILE ccache)
- set_property(DIRECTORY vendor/Box2D/Box2D PROPERTY RULE_LAUNCH_LINK ccache)
-endif ()
+cece_enable_ccache(vendor/Box2D/Box2D)
# ######################################################################### #
# CeCe library
-add_subdirectory(cece)
+add_subdirectory(src)
+
+# ######################################################################### #
+
+if (CECE_TESTS_BUILD)
+ add_subdirectory(unittests)
+
+ if (CMAKE_COMPILER_IS_GNUCXX AND CECE_COVERAGE)
+ find_program(LCOV lcov)
+ find_program(GENHTML genhtml)
+
+ if (NOT LCOV)
+ message(FATAL_ERROR "lcov not found!")
+ endif ()
+
+ if (NOT GENHTML)
+ message(FATAL_ERROR "genhtml not found!")
+ endif ()
+
+ # Add custom target for gcov
+ add_custom_target(cece-coverage
+ # Cleanup lcov
+ ${LCOV} --directory . --zerocounters
+
+ # Run tests
+ COMMAND ctest
+
+ # Capturing lcov counters and generating report
+ COMMAND ${LCOV} --directory . --capture --output-file coverage0.info
+ COMMAND ${LCOV} -r coverage0.info 'vendor/*' 'unittests/*' '/usr*' --output-file coverage.info
+ COMMAND ${GENHTML} --demangle-cpp -o coverage coverage.info
+ COMMAND ${CMAKE_COMMAND} -E remove coverage0.info
+
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ )
+ endif ()
+endif ()
# ######################################################################### #
diff --git a/appveyor.yml b/appveyor.yml
index d258dad..cde765d 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -25,7 +25,7 @@
os: Visual Studio 2015
-version: 0.6.0.{build}
+version: 0.7.0.{build}
environment:
matrix:
@@ -42,10 +42,6 @@ environment:
- GENERATOR: MinGW Makefiles
CECE_RENDER: Off
-matrix:
- allow_failures:
- - GENERATOR: MinGW Makefiles
-
# Branches to build
branches:
except:
@@ -62,6 +58,6 @@ build_script:
- pushd build && cmake --build . --config Release & popd
test_script:
- - pushd build && ctest --verbose & popd
+ - pushd build && ctest -C Release --verbose & popd
# ######################################################################### #
diff --git a/cece/config/Configuration.hpp b/cece/config/Configuration.hpp
deleted file mode 100644
index accaba6..0000000
--- a/cece/config/Configuration.hpp
+++ /dev/null
@@ -1,406 +0,0 @@
-/* ************************************************************************ */
-/* Georgiev Lab (c) 2015-2016 */
-/* ************************************************************************ */
-/* Department of Cybernetics */
-/* Faculty of Applied Sciences */
-/* University of West Bohemia in Pilsen */
-/* ************************************************************************ */
-/* */
-/* This file is part of CeCe. */
-/* */
-/* CeCe is free software: you can redistribute it and/or modify */
-/* it under the terms of the GNU General Public License as published by */
-/* the Free Software Foundation, either version 3 of the License, or */
-/* (at your option) any later version. */
-/* */
-/* CeCe is distributed in the hope that it will be useful, */
-/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
-/* GNU General Public License for more details. */
-/* */
-/* You should have received a copy of the GNU General Public License */
-/* along with CeCe. If not, see . */
-/* */
-/* ************************************************************************ */
-
-#pragma once
-
-/* ************************************************************************ */
-
-// CeCe
-#include "cece/core/String.hpp"
-#include "cece/core/StringView.hpp"
-#include "cece/core/UniquePtr.hpp"
-#include "cece/core/ViewPtr.hpp"
-#include "cece/core/Exception.hpp"
-#include "cece/core/DynamicArray.hpp"
-#include "cece/core/StringStream.hpp"
-#include "cece/config/Exception.hpp"
-#include "cece/config/Implementation.hpp"
-
-/* ************************************************************************ */
-
-namespace cece { inline namespace core { class Parameters; } }
-
-/* ************************************************************************ */
-
-namespace cece {
-namespace config {
-
-/* ************************************************************************ */
-
-/**
- * @brief Container for configuration.
- */
-class Configuration
-{
-
-// Public Ctors
-public:
-
-
- /**
- * @brief Constructor.
- *
- * @param impl Implementation.
- * @param parameters Optional parameters.
- */
- Configuration(UniquePtr impl, ViewPtr parameters = nullptr) noexcept
- : m_impl(std::move(impl))
- , m_parameters(parameters)
- {
- // Nothing to do
- }
-
-
- /**
- * @brief Constructor.
- *
- * @param impl Implementation.
- * @param parameters Optional parameters.
- */
- Configuration(Implementation* impl, ViewPtr parameters = nullptr) noexcept
- : m_impl(impl)
- , m_parameters(parameters)
- {
- // Nothign to do
- }
-
-
- /**
- * @brief Constructor (memory version).
- *
- * @param parameters Optional parameters.
- */
- explicit Configuration(ViewPtr parameters = nullptr) noexcept;
-
-
-// Public Accessors
-public:
-
-
- /**
- * @brief Returns if value exists under given name.
- *
- * @param name Value name.
- *
- * @return
- */
- bool has(StringView name) const noexcept
- {
- return m_impl->has(name);
- }
-
-
- /**
- * @brief Returns string value.
- *
- * @param name Value name.
- *
- * @return
- *
- * @throw ConfigException
- */
- String get(StringView name) const
- {
- if (!has(name))
- throw config::Exception("Missing value for '" + String(name) + "'");
-
- return replaceParameters(m_impl->get(name));
- }
-
-
- /**
- * @brief Returns string value.
- *
- * @param name Value name.
- * @param def Default value if doesn't exists.
- *
- * @return
- */
- String get(StringView name, String def) const
- {
- return has(name) ? replaceParameters(m_impl->get(name)) : std::move(def);
- }
-
-
- /**
- * @brief Returns value of given type.
- *
- * @tparam T Required value type.
- *
- * @param name Value name.
- *
- * @return
- *
- * @throw ConfigException
- */
- template
- T get(StringView name) const
- {
- return castFrom(get(name));
- }
-
-
- /**
- * @brief Returns value of given type.
- *
- * @tparam T Required value type.
- *
- * @param name Value name.
- * @param def Default value if doesn't exists.
- *
- * @return
- */
- template
- T get(StringView name, T def) const
- {
- return has(name) ? castFrom(replaceParameters(m_impl->get(name))) : std::move(def);
- }
-
-
- /**
- * @brief Returns list of configuration names.
- *
- * @return
- */
- DynamicArray getNames() const noexcept
- {
- return m_impl->getNames();
- }
-
-
- /**
- * @brief Returns if there is content.
- *
- * @return
- */
- bool hasContent() const noexcept
- {
- return m_impl->hasContent();
- }
-
-
- /**
- * @brief Returns content.
- *
- * @return
- */
- String getContent() const noexcept
- {
- return m_impl->getContent();
- }
-
-
- /**
- * @brief Check if subconfiguration exists.
- *
- * @param name Configuration name.
- *
- * @return Configuration or nullptr.
- */
- bool hasConfiguration(StringView name) const noexcept
- {
- return m_impl->hasSubs(name);
- }
-
-
- /**
- * @brief Returns the first sub-configuration.
- *
- * @param name Sub-configuration name.
- *
- * @return Sub-configuration.
- *
- * @throw ConfigException
- */
- Configuration getConfiguration(StringView name) const
- {
- auto configurations = getConfigurations(name);
-
- if (configurations.empty())
- throw config::Exception("Sub-configuration '" + String(name) + "' doesn't exists");
-
- return std::move(configurations[0]);
- }
-
-
- /**
- * @brief Returns all sub-configurations with given name.
- *
- * @param name Sub-configuration name.
- *
- * @return List of valid sub-configurations.
- */
- DynamicArray getConfigurations(StringView name) const noexcept;
-
-
- /**
- * @brief Returns list of sub-configuration names.
- *
- * @return
- */
- DynamicArray getConfigurationNames() const noexcept
- {
- return m_impl->getSubNames();
- }
-
-
-// Public Mutators
-public:
-
-
- /**
- * @brief Store string value.
- *
- * @param name Value name.
- * @param value Value to store.
- */
- void set(StringView name, StringView value) noexcept
- {
- m_impl->set(name, value);
- }
-
-
- /**
- * @brief Set integer value.
- *
- * @tparam T Value type.
- *
- * @param name Value name.
- * @param value Value to store.
- */
- template
- void set(StringView name, T value) noexcept
- {
- m_impl->set(name, castTo(value));
- }
-
-
- /**
- * @brief Set content text.
- *
- * @param content Content text.
- */
- void setContent(StringView content) noexcept
- {
- m_impl->setContent(content);
- }
-
-
- /**
- * @brief Create new sub-configuration.
- *
- * @param name Sub-configuration name.
- *
- * @return New configuration.
- */
- Configuration addConfiguration(StringView name) noexcept
- {
- return {m_impl->addSub(name)};
- }
-
-
-// Public Operations
-public:
-
-
- /**
- * @brief Copy configuration from other one.
- *
- * @param config Source configuration.
- */
- void copyFrom(const Configuration& config);
-
-
- /**
- * @brief Clone configuration to memory.
- *
- * @return
- */
- Configuration toMemory() const;
-
-
-// Private Operations
-private:
-
-
- /**
- * @brief Cast value from string into required type.
- *
- * @param value Value.
- *
- * @return
- */
- template
- static T castFrom(const String& value)
- {
- InStringStream is(value);
- T res;
- is >> std::noskipws >> std::boolalpha >> res;
- return res;
- }
-
-
- /**
- * @brief Cast value to string from given type.
- *
- * @param value Value.
- *
- * @return
- */
- template
- static String castTo(T&& value)
- {
- OutStringStream os;
- os << value;
- return os.str();
- }
-
-
- /**
- * @brief Replace parameters in given string.
- *
- * @param str Source string.
- *
- * @return Result string with replaced parameters.
- */
- String replaceParameters(String str) const;
-
-
-// Private Data Members
-private:
-
- /// Configuration implementation.
- UniquePtr m_impl;
-
- /// Optional parameters.
- ViewPtr m_parameters;
-};
-
-/* ************************************************************************ */
-
-}
-}
-
-/* ************************************************************************ */
diff --git a/cece/config/MemoryImplementation.cpp b/cece/config/MemoryImplementation.cpp
deleted file mode 100644
index b1cef09..0000000
--- a/cece/config/MemoryImplementation.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/* ************************************************************************ */
-/* Georgiev Lab (c) 2015-2016 */
-/* ************************************************************************ */
-/* Department of Cybernetics */
-/* Faculty of Applied Sciences */
-/* University of West Bohemia in Pilsen */
-/* ************************************************************************ */
-/* */
-/* This file is part of CeCe. */
-/* */
-/* CeCe is free software: you can redistribute it and/or modify */
-/* it under the terms of the GNU General Public License as published by */
-/* the Free Software Foundation, either version 3 of the License, or */
-/* (at your option) any later version. */
-/* */
-/* CeCe is distributed in the hope that it will be useful, */
-/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
-/* GNU General Public License for more details. */
-/* */
-/* You should have received a copy of the GNU General Public License */
-/* along with CeCe. If not, see . */
-/* */
-/* ************************************************************************ */
-
-// Declaration
-#include "cece/config/MemoryImplementation.hpp"
-
-/* ************************************************************************ */
-
-namespace cece {
-namespace config {
-
-/* ************************************************************************ */
-
-DynamicArray MemoryImplementation::getNames() const noexcept
-{
- DynamicArray names;
- names.reserve(m_data->values.size());
-
- for (const auto& p : m_data->values)
- names.push_back(std::move(p.first));
-
- return names;
-}
-
-/* ************************************************************************ */
-
-DynamicArray> MemoryImplementation::getSubs(StringView name) const noexcept
-{
- DynamicArray> res;
-
- auto it = m_data->data.find(name.getData());
-
- if (it == m_data->data.end())
- return res;
-
- for (const auto& ptr : it->second)
- res.push_back(makeUnique(ptr));
-
- return res;
-}
-
-/* ************************************************************************ */
-
-DynamicArray MemoryImplementation::getSubNames() const noexcept
-{
- DynamicArray names;
- names.reserve(m_data->data.size());
-
- for (const auto& p : m_data->data)
- names.push_back(p.first);
-
- return names;
-}
-
-/* ************************************************************************ */
-
-UniquePtr MemoryImplementation::addSub(StringView name) noexcept
-{
- auto data = makeShared();
-
- // Register data
- m_data->data[name.getData()].push_back(data);
-
- return makeUnique(std::move(data));
-}
-
-/* ************************************************************************ */
-
-}
-}
-
-/* ************************************************************************ */
diff --git a/cece/config/MemoryImplementation.hpp b/cece/config/MemoryImplementation.hpp
deleted file mode 100644
index 4e61d83..0000000
--- a/cece/config/MemoryImplementation.hpp
+++ /dev/null
@@ -1,236 +0,0 @@
-/* ************************************************************************ */
-/* Georgiev Lab (c) 2015-2016 */
-/* ************************************************************************ */
-/* Department of Cybernetics */
-/* Faculty of Applied Sciences */
-/* University of West Bohemia in Pilsen */
-/* ************************************************************************ */
-/* */
-/* This file is part of CeCe. */
-/* */
-/* CeCe is free software: you can redistribute it and/or modify */
-/* it under the terms of the GNU General Public License as published by */
-/* the Free Software Foundation, either version 3 of the License, or */
-/* (at your option) any later version. */
-/* */
-/* CeCe is distributed in the hope that it will be useful, */
-/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
-/* GNU General Public License for more details. */
-/* */
-/* You should have received a copy of the GNU General Public License */
-/* along with CeCe. If not, see . */
-/* */
-/* ************************************************************************ */
-
-// CeCe
-#include "cece/core/String.hpp"
-#include "cece/core/StringView.hpp"
-#include "cece/core/SharedPtr.hpp"
-#include "cece/core/DynamicArray.hpp"
-#include "cece/core/Map.hpp"
-#include "cece/config/Implementation.hpp"
-
-/* ************************************************************************ */
-
-namespace cece {
-namespace config {
-
-/* ************************************************************************ */
-
-/**
- * @brief Memory configuration implementation.
- */
-class MemoryImplementation : public Implementation
-{
-
-// Private Structures
-private:
-
-
- /**
- * @brief Data storage.
- */
- struct Data
- {
- /// Stored values.
- Map values;
-
- /// Stored content.
- String content;
-
- /// Subdata
- Map>> data;
- };
-
-
-// Public Ctors & Dtors
-public:
-
-
- /**
- * @brief Constructor.
- */
- MemoryImplementation()
- : m_data(makeShared())
- {
- // Nothing to do
- }
-
-
- /**
- * @brief Constructor.
- *
- * @param data Managed data.
- */
- explicit MemoryImplementation(SharedPtr data)
- : m_data(std::move(data))
- {
- // Nothing to do
- }
-
-
-// Public Accessors
-public:
-
-
- /**
- * @brief Check if value with given name exists.
- *
- * @param name Value name.
- *
- * @return
- */
- bool has(StringView name) const noexcept override
- {
- return m_data->values.find(name.getData()) != m_data->values.end();
- }
-
-
- /**
- * @brief Returns string value.
- *
- * @param name Value name.
- *
- * @return
- */
- String get(StringView name) const noexcept override
- {
- auto it = m_data->values.find(name.getData());
- return it != m_data->values.end() ? it->second : "";
- }
-
-
- /**
- * @brief Returns list of configuration names.
- *
- * @return
- */
- DynamicArray getNames() const noexcept override;
-
-
- /**
- * @brief Returns if content string is set.
- *
- * @return
- */
- bool hasContent() const noexcept override
- {
- return !m_data->content.empty();
- }
-
-
- /**
- * @brief Returns content string.
- *
- * @return
- */
- String getContent() const noexcept override
- {
- return m_data->content;
- }
-
-
- /**
- * @brief Returns if sub-configuration exists.
- *
- * @param name Sub-configuration name.
- *
- * @return
- */
- bool hasSubs(StringView name) const noexcept override
- {
- return m_data->data.find(name.getData()) != m_data->data.end();
- }
-
-
- /**
- * @brief Returns all sub-configuration with given name.
- *
- * @param name Sub-configuration name.
- *
- * @return
- */
- DynamicArray> getSubs(StringView name) const noexcept override;
-
-
- /**
- * @brief Returns list of sub-configuration names.
- *
- * @return
- */
- DynamicArray getSubNames() const noexcept override;
-
-
-// Public Mutators
-public:
-
-
- /**
- * @brief Set string value.
- *
- * @param name Value name.
- * @param value Value to store.
- *
- * @return
- */
- void set(StringView name, StringView value) noexcept override
- {
- m_data->values[name.getData()] = value.getData();
- }
-
-
- /**
- * @brief Store content.
- *
- * @param content Content text.
- */
- void setContent(StringView content) noexcept override
- {
- m_data->content = content.getData();
- }
-
-
- /**
- * @brief Create new sub-configuration.
- *
- * @param name Sub-configuration name.
- *
- * @return
- */
- UniquePtr addSub(StringView name) noexcept override;
-
-
-// Private Data Members
-private:
-
- /// Shared data.
- SharedPtr m_data;
-};
-
-/* ************************************************************************ */
-
-}
-}
-
-/* ************************************************************************ */
diff --git a/cece/core/CMakeLists.txt b/cece/core/CMakeLists.txt
deleted file mode 100644
index 43a9447..0000000
--- a/cece/core/CMakeLists.txt
+++ /dev/null
@@ -1,128 +0,0 @@
-# ######################################################################### #
-# Georgiev Lab (c) 2015-2016 #
-# ######################################################################### #
-# Department of Cybernetics #
-# Faculty of Applied Sciences #
-# University of West Bohemia in Pilsen #
-# ######################################################################### #
-# #
-# This file is part of CeCe. #
-# #
-# CeCe is free software: you can redistribute it and/or modify #
-# it under the terms of the GNU General Public License as published by #
-# the Free Software Foundation, either version 3 of the License, or #
-# (at your option) any later version. #
-# #
-# CeCe is distributed in the hope that it will be useful, #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
-# GNU General Public License for more details. #
-# #
-# You should have received a copy of the GNU General Public License #
-# along with CeCe. If not, see . #
-# #
-# ######################################################################### #
-
-set(SRCS
- Macro.hpp
- constants.hpp
- fastexp.hpp
- DynamicArray.hpp
- StaticArray.hpp
- StaticMatrix.hpp
- Unit.hpp
- Unit.cpp
- UnitIo.hpp
- UnitIo.cpp
- UnitSymbol.hpp
- Units.hpp
- Units.cpp
- UnitsCtors.hpp
- Vector.hpp
- Vector.cpp
- VectorUnits.hpp
- VectorUnits.cpp
- Grid.hpp
- Grid.cpp
- AlignedAllocator.hpp
- AlignedAllocator.cpp
- ExpressionParser.hpp
- ExpressionParser.cpp
- Log.hpp
- Log.cpp
- TimeMeasurement.hpp
- TimeMeasurement.cpp
- String.hpp
- StringView.hpp
- FilePath.hpp
- FilePath.cpp
- Exception.hpp
- OutStream.hpp
- InStream.hpp
- InOutStream.hpp
- FileStream.hpp
- CsvFile.hpp
- CsvFile.cpp
- DataExport.hpp
- DataExport.cpp
- DataExportCsv.hpp
- DataExportCsv.cpp
- DataExportFactory.hpp
- DataExportFactory.cpp
- DataExportCsvFactory.hpp
- DataExportCsvFactory.cpp
- ValueIterator.hpp
- Range.hpp
- VectorRange.hpp
- IntegerSequence.hpp
- Tuple.hpp
- UniquePtr.hpp
- ViewPtr.hpp
- ListenerContainer.hpp
- Zero.hpp
- StringStream.hpp
- Tokenizer.hpp
- Real.hpp
- Mutex.hpp
- Pair.hpp
- SharedPtr.hpp
- Parameters.hpp
- Parameters.cpp
- Factory.hpp
- FactoryManager.hpp
- Shape.hpp
- ShapeToGrid.hpp
- PtrContainer.hpp
- PtrNamedContainer.hpp
- IterationType.hpp
- IterationRange.hpp
- CliColor.hpp
- CliColor.cpp
-)
-
-set(SRCS_TEST
- AlignedAllocatorTest.cpp
- DynamicArrayTest.cpp
- IteratorRangeTest.cpp
- VectorRangeTest.cpp
- UnitsTest.cpp
- StringViewTest.cpp
- VectorTest.cpp
- VectorUnitsTest.cpp
- ExpressionParserTest.cpp
- TokenizerTest.cpp
- ParametersTest.cpp
- PtrContainerTest.cpp
- ViewPtrTest.cpp
- FilePathTest.cpp
-)
-
-# ######################################################################### #
-
-dir_pretend(SOURCES core/ ${SRCS})
-dir_pretend(SOURCES_TEST core/test/ ${SRCS_TEST})
-
-set(SOURCES_CORE ${SOURCES} PARENT_SCOPE)
-set(SOURCES_CORE_TEST ${SOURCES_TEST} PARENT_SCOPE)
-
-# ######################################################################### #
diff --git a/cece/core/FilePath.hpp b/cece/core/FilePath.hpp
deleted file mode 100644
index efba6af..0000000
--- a/cece/core/FilePath.hpp
+++ /dev/null
@@ -1,428 +0,0 @@
-/* ************************************************************************ */
-/* Georgiev Lab (c) 2015-2016 */
-/* ************************************************************************ */
-/* Department of Cybernetics */
-/* Faculty of Applied Sciences */
-/* University of West Bohemia in Pilsen */
-/* ************************************************************************ */
-/* */
-/* This file is part of CeCe. */
-/* */
-/* CeCe is free software: you can redistribute it and/or modify */
-/* it under the terms of the GNU General Public License as published by */
-/* the Free Software Foundation, either version 3 of the License, or */
-/* (at your option) any later version. */
-/* */
-/* CeCe is distributed in the hope that it will be useful, */
-/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
-/* GNU General Public License for more details. */
-/* */
-/* You should have received a copy of the GNU General Public License */
-/* along with CeCe. If not, see . */
-/* */
-/* ************************************************************************ */
-
-#pragma once
-
-/* ************************************************************************ */
-
-// C++
-#include
-#include
-#include
-
-#ifdef _WIN32
-# include
-#endif
-
-// CeCe
-#include "cece/core/String.hpp"
-#include "cece/core/DynamicArray.hpp"
-#include "cece/core/InStream.hpp"
-#include "cece/core/OutStream.hpp"
-
-/* ************************************************************************ */
-
-namespace cece {
-inline namespace core {
-
-/* ************************************************************************ */
-
-/**
- * @brief File path type.
- */
-class FilePath
-{
-
-// Public Constants
-public:
-
-
- /// Path separator.
- static constexpr char SEPARATOR = '/';
-
-
-// Public Ctors & Dtors
-public:
-
-
- /**
- * @brief Default constructor.
- */
- FilePath() = default;
-
-
- /**
- * @brief Constructor.
- *
- * @param source
- */
- FilePath(String source)
- : m_path(std::move(source))
- {
- // Nothing to do
- }
-
-
- /**
- * @brief Constructor.
- *
- * @param source
- */
- FilePath(const char* source)
- : m_path(source)
- {
- // Nothing to do
- }
-
-
-// Public Operators
-public:
-
-
- /**
- * @brief Append path.
- *
- * @param path
- *
- * @return this
- */
- FilePath& operator/=(const FilePath& path)
- {
- if (!m_path.empty())
- m_path += SEPARATOR;
- m_path.append(path.m_path);
- return *this;
- }
-
-
- /**
- * @brief Append source.
- *
- * @param source
- *
- * @return this
- */
- FilePath& operator/=(const String& source)
- {
- if (!m_path.empty())
- m_path += SEPARATOR;
- m_path.append(source);
- return *this;
- }
-
-
- /**
- * @brief Append source.
- *
- * @param source
- *
- * @return this
- */
- FilePath& operator/=(const char* source)
- {
- if (!m_path.empty())
- m_path += SEPARATOR;
- m_path.append(source);
- return *this;
- }
-
-
- /**
- * @brief Append path.
- *
- * @param path
- *
- * @return
- */
- FilePath operator/(const FilePath& path) const
- {
- return FilePath(*this) /= path;
- }
-
-
- /**
- * @brief Append source.
- *
- * @param source
- *
- * @return
- */
- FilePath operator/(const String& source) const
- {
- return FilePath(*this) /= source;
- }
-
-
- /**
- * @brief Append source.
- *
- * @param source
- *
- * @return
- */
- FilePath operator/(const char* source) const
- {
- return FilePath(*this) /= source;
- }
-
-
-// Public Accessors & Mutators
-public:
-
-
- /**
- * @brief Check if path is empty.
- *
- * @return
- */
- bool isEmpty() const noexcept
- {
- return m_path.empty();
- }
-
-
- /**
- * @brief Check if path is empty.
- *
- * @return
- *
- * @deprecated
- */
- bool empty() const noexcept
- {
- return isEmpty();
- }
-
-
- /**
- * @brief Returns path file name.
- *
- * @return
- */
- String getFilename() const noexcept;
-
-
- /**
- * @brief Returns path extension.
- *
- * @return
- */
- String getExtension() const noexcept;
-
-
- /**
- * @brief Returns parent path.
- *
- * @return
- */
- FilePath getParentPath() const noexcept;
-
-
- /**
- * @brief Returns path stem.
- *
- * @return
- */
- FilePath getStem() const noexcept;
-
-
- /**
- * @brief Convert path to string.
- *
- * @return
- */
- const char* c_str() const noexcept
- {
- return m_path.c_str();
- }
-
-
- /**
- * @brief Returns path length.
- *
- * @return
- */
- String::size_type getSize() const noexcept
- {
- return m_path.size();
- }
-
-
- /**
- * @brief Convert path to string.
- *
- * @return
- */
- String toString() const noexcept
- {
- return m_path;
- }
-
-
- /**
- * @brief Convert path to string.
- *
- * @return
- *
- * @deprecated
- */
- String string() const noexcept
- {
- return toString();
- }
-
-
- /**
- * @brief Append string to the path.
- *
- * @param str String to append.
- *
- * @return this
- */
- FilePath& append(const String& str)
- {
- m_path.append(str);
- return *this;
- }
-
-
- /**
- * @brief Replace path extension.
- *
- * @param ext New extension.
- *
- * @return this
- */
- FilePath& replaceExtension(const String& ext);
-
-
-// Public Operations
-public:
-
-
- /**
- * @brief Clear path.
- */
- void clear() noexcept
- {
- m_path.clear();
- }
-
-
- /**
- * @brief Input stream operator.
- *
- * @param is
- * @param path
- *
- * @return is
- */
- friend InStream& operator>>(InStream& is, FilePath& path)
- {
- return is >> path.m_path;
- }
-
-
- /**
- * @brief Output stream operator.
- *
- * @param os
- * @param path
- *
- * @return os
- */
- friend OutStream& operator<<(OutStream& os, const FilePath& path)
- {
- return os << path.m_path;
- }
-
-
-// Private Data Members
-private:
-
- /// Path value.
- String m_path;
-
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief Tests if path is a file.
- *
- * @param path
- *
- * @return
- */
-bool isFile(const FilePath& path) noexcept;
-
-/* ************************************************************************ */
-
-/**
- * @brief Tests if path is a directory.
- *
- * @param path
- *
- * @return
- */
-bool isDirectory(const FilePath& path) noexcept;
-
-/* ************************************************************************ */
-
-/**
- * @brief Tests if file path exists.
- *
- * @param path
- *
- * @return
- */
-bool pathExists(const FilePath& path) noexcept;
-
-/* ************************************************************************ */
-
-/**
- * @brief Returns temporary directory.
- *
- * @return
- */
-FilePath tempDirectory();
-
-/* ************************************************************************ */
-
-/**
- * @brief Get all entries in given directory.
- *
- * @param dir
- *
- * @return
- */
-DynamicArray openDirectory(const FilePath& dir);
-
-/* ************************************************************************ */
-
-}
-}
-
-/* ************************************************************************ */
diff --git a/cece/core/Log.hpp b/cece/core/Log.hpp
deleted file mode 100644
index 30371a4..0000000
--- a/cece/core/Log.hpp
+++ /dev/null
@@ -1,281 +0,0 @@
-/* ************************************************************************ */
-/* Georgiev Lab (c) 2015-2016 */
-/* ************************************************************************ */
-/* Department of Cybernetics */
-/* Faculty of Applied Sciences */
-/* University of West Bohemia in Pilsen */
-/* ************************************************************************ */
-/* */
-/* This file is part of CeCe. */
-/* */
-/* CeCe is free software: you can redistribute it and/or modify */
-/* it under the terms of the GNU General Public License as published by */
-/* the Free Software Foundation, either version 3 of the License, or */
-/* (at your option) any later version. */
-/* */
-/* CeCe is distributed in the hope that it will be useful, */
-/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
-/* GNU General Public License for more details. */
-/* */
-/* You should have received a copy of the GNU General Public License */
-/* along with CeCe. If not, see . */
-/* */
-/* ************************************************************************ */
-
-#pragma once
-
-/* ************************************************************************ */
-
-// CeCe
-#include "cece/export.hpp"
-#include "cece/core/String.hpp"
-#include "cece/core/OutStream.hpp"
-#include "cece/core/StringStream.hpp"
-#include "cece/core/CliColor.hpp"
-
-/* ************************************************************************ */
-
-namespace cece {
-inline namespace core {
-
-/* ************************************************************************ */
-
-/**
- * @brief Logging class.
- */
-class Log
-{
-
-// Public Enums
-public:
-
-
- /**
- * @brief Log message types.
- */
- enum class Type
- {
- Default,
- Info,
- Warning,
- Error,
- Debug
- };
-
-
-// Public Classes
-public:
-
-
- /**
- * @brief Output class that handles log output.
- */
- class Output
- {
- // Public Ctors & Dtors
- public:
-
- /**
- * @brief Destructor.
- */
- virtual ~Output();
-
- // Public Operations
- public:
-
- /**
- * @brief Write a message to output.
- *
- * @param type Message type.
- * @param section Message section.
- * @param msg Message to log.
- */
- virtual void write(Type type, const String& section, const String& msg) = 0;
- };
-
-
- /**
- * @brief Output for output streams.
- */
- class StreamOutput : public Output
- {
- // Public Ctors & Dtors
- public:
-
- /**
- * @brief Constructor.
- *
- * @param os
- */
- explicit StreamOutput(OutStream* os) : m_os(os) {}
-
-
- /**
- * @brief Destructor.
- */
- ~StreamOutput();
-
- // Public Operations
- public:
-
- /**
- * @brief Write a message to output.
- *
- * @param type Message type.
- * @param section Message section.
- * @param msg Message to log.
- */
- void write(Type type, const String& section, const String& msg) override;
-
- // Private Data Members
- private:
-
- /// Output stream.
- OutStream* m_os;
- };
-
-
-// Public Mutators
-public:
-
-
- /**
- * @brief Set output stream.
- *
- * @param os
- */
- static void setOutput(Output* os) noexcept
- {
- s_output = os;
- }
-
-
- /**
- * @brief Set error stream.
- *
- * @param os
- */
- static void setError(Output* os) noexcept
- {
- s_error = os;
- }
-
-
-// Public Operators
-public:
-
-
- /**
- * @brief Log info message.
- *
- * @param args
- */
- template
- static void info(Args&&... args)
- {
- if (s_output)
- {
- OutStringStream oss;
- message(oss, std::forward(args)...);
- s_output->write(Type::Info, String{}, oss.str());
- }
- }
-
-
- /**
- * @brief Log debug message.
- *
- * @param args
- */
- template
- static void debug(Args&&... args)
- {
-#ifndef NDEBUG
- if (s_output)
- {
- OutStringStream oss;
- message(oss, std::forward(args)...);
- s_output->write(Type::Debug, String{}, oss.str());
- }
-#endif
- }
-
-
- /**
- * @brief Log warning message.
- *
- * @param args
- */
- template
- static void warning(Args&&... args)
- {
- if (s_output)
- {
- OutStringStream oss;
- message(oss, std::forward(args)...);
- s_output->write(Type::Warning, String{}, oss.str());
- }
- }
-
-
- /**
- * @brief Log error message.
- *
- * @param args
- */
- template
- static void error(Args&&... args)
- {
- if (s_error)
- {
- OutStringStream oss;
- message(oss, std::forward(args)...);
- s_error->write(Type::Error, String{}, oss.str());
- }
- }
-
-
-// Private Operations
-private:
-
-
- /**
- * @brief Log message.
- */
- static void message(OutStream& os)
- {
- // Nothing to do
- }
-
-
- /**
- * @brief Log message.
- *
- * @param args
- */
- template
- static void message(OutStream& os, Arg&& arg, Args&&... args)
- {
- os << arg;
- message(os, std::forward(args)...);
- }
-
-
-// Private Data Members
-private:
-
- /// Standard output.
- static CECE_EXPORT Output* s_output;
-
- /// Error output.
- static CECE_EXPORT Output* s_error;
-
-};
-
-/* ************************************************************************ */
-
-}
-}
-
-/* ************************************************************************ */
diff --git a/cece/core/PtrContainer.hpp b/cece/core/PtrContainer.hpp
deleted file mode 100644
index ee823d0..0000000
--- a/cece/core/PtrContainer.hpp
+++ /dev/null
@@ -1,296 +0,0 @@
-/* ************************************************************************ */
-/* Georgiev Lab (c) 2015-2016 */
-/* ************************************************************************ */
-/* Department of Cybernetics */
-/* Faculty of Applied Sciences */
-/* University of West Bohemia in Pilsen */
-/* ************************************************************************ */
-/* */
-/* This file is part of CeCe. */
-/* */
-/* CeCe is free software: you can redistribute it and/or modify */
-/* it under the terms of the GNU General Public License as published by */
-/* the Free Software Foundation, either version 3 of the License, or */
-/* (at your option) any later version. */
-/* */
-/* CeCe is distributed in the hope that it will be useful, */
-/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
-/* GNU General Public License for more details. */
-/* */
-/* You should have received a copy of the GNU General Public License */
-/* along with CeCe. If not, see . */
-/* */
-/* ************************************************************************ */
-
-#pragma once
-
-/* ************************************************************************ */
-
-// C++
-#include
-#include
-
-// CeCe
-#include "cece/core/UniquePtr.hpp"
-#include "cece/core/ViewPtr.hpp"
-#include "cece/core/DynamicArray.hpp"
-
-/* ************************************************************************ */
-
-/**
- * @brief Define pointer container specialization.
- */
-#define CECE_PTR_CONTAINER(...) \
- namespace cece { inline namespace core { template class PtrContainer<__VA_ARGS__>; } }
-
-/**
- * @brief Define extern pointer container specialization.
- */
-#define CECE_PTR_CONTAINER_EXTERN(...) \
- namespace cece { inline namespace core { extern template class PtrContainer<__VA_ARGS__>; } }
-
-/**
- * @brief Define pointer container specialization.
- */
-#define CECE_PTR_CONTAINER_INST(...) \
- namespace cece { inline namespace core { template class PtrContainer<__VA_ARGS__>; } }
-
-/* ************************************************************************ */
-
-namespace cece {
-inline namespace core {
-
-/* ************************************************************************ */
-
-/**
- * @brief Container for pointers.
- */
-template
-class PtrContainer
-{
-
-// Public Types
-public:
-
-
- /// Pointer type.
- using type = T;
-
-
-// Public Operators
-public:
-
-
- /**
- * @brief Returns n-th object.
- *
- * @param pos Required position.
- *
- * @return Pointer to object.
- *
- * @warning No boundary checking.
- */
- ViewPtr operator[](std::size_t pos) const noexcept
- {
- return m_data[pos];
- }
-
-
-// Public Accessors
-public:
-
-
- /**
- * @brief Returns a number of stored objects.
- *
- * @return
- */
- std::size_t getCount() const noexcept
- {
- return m_data.size();
- }
-
-
- /**
- * @brief Returns n-th object.
- *
- * @param pos Required position.
- *
- * @return Pointer to object.
- */
- ViewPtr get(std::size_t pos) const
- {
- return m_data.at(pos);
- }
-
-
- /**
- * @brief Returns begin iterator.
- *
- * @return
- */
- typename DynamicArray>::const_iterator begin() const noexcept
- {
- return m_data.begin();
- }
-
-
- /**
- * @brief Returns begin iterator.
- *
- * @return
- */
- typename DynamicArray>::const_iterator cbegin() const noexcept
- {
- return m_data.cbegin();
- }
-
-
- /**
- * @brief Returns end iterator.
- *
- * @return
- */
- typename DynamicArray>::const_iterator end() const noexcept
- {
- return m_data.end();
- }
-
-
- /**
- * @brief Returns end iterator.
- *
- * @return
- */
- typename DynamicArray>::const_iterator cend() const noexcept
- {
- return m_data.cend();
- }
-
-
-// Public Mutators
-public:
-
-
- /**
- * @brief Store an object.
- *
- * @param object The object to store.
- *
- * @return View pointer to stored object.
- */
- ViewPtr add(UniquePtr object)
- {
- m_data.push_back(std::move(object));
- return m_data.back();
- }
-
-
- /**
- * @brief Create and store an object.
- *
- * @tparam Args Construction argument types.
- *
- * @param args Construction arguments.
- *
- * @return View pointer to stored object.
- */
- template
- ViewPtr create(Args&&... args)
- {
- return add(makeUnique(std::forward(args)...));
- }
-
-
- /**
- * @brief Create and store an object.
- *
- * @tparam T2 Type of constructed object.
- * @tparam Args Construction argument types.
- *
- * @param args Construction arguments.
- *
- * @return View pointer to stored object.
- */
- template
- ViewPtr create(Args&&... args)
- {
- return add(makeUnique(std::forward(args)...));
- }
-
-
- /**
- * @brief Remove object from container.
- *
- * @param object The object to remove.
- *
- * @return A pointer to removed object.
- */
- UniquePtr remove(ViewPtr object)
- {
- for (auto itB = m_data.begin(), itE = m_data.end(); itB != itE; ++itB)
- {
- if (itB->get() == object.get())
- {
- auto ptr = std::move(*itB);
- m_data.erase(itB);
- return ptr;
- }
- }
-
- // Not found
- return nullptr;
- }
-
-
- /**
- * @brief Clear container.
- */
- void clear()
- {
- m_data.clear();
- }
-
-
-// Protected Operations
-protected:
-
-
- /**
- * @brief Invoke a member function for all stored objects.
- *
- * @tparam Args A list of member function arguments.
- *
- * @param function A pointer to object's member function that will be
- * called for all stored listeners.
- * @param args...
- */
- template
- void invoke(Fn fn, Args2&&... args) const
- {
- static_assert(std::is_member_function_pointer::value, "Fn is not a member function.");
-
- // Foreach all object
- for (const auto& object : m_data)
- {
- // Call member function with given arguments
- (object.get()->*fn)(std::forward(args)...);
- }
- }
-
-
-// Private Data Members
-private:
-
- /// Stored pointers.
- DynamicArray> m_data;
-
-};
-
-/* ************************************************************************ */
-
-}
-}
-
-/* ************************************************************************ */
diff --git a/cece/core/PtrNamedContainer.hpp b/cece/core/PtrNamedContainer.hpp
deleted file mode 100644
index deec982..0000000
--- a/cece/core/PtrNamedContainer.hpp
+++ /dev/null
@@ -1,392 +0,0 @@
-/* ************************************************************************ */
-/* Georgiev Lab (c) 2015-2016 */
-/* ************************************************************************ */
-/* Department of Cybernetics */
-/* Faculty of Applied Sciences */
-/* University of West Bohemia in Pilsen */
-/* ************************************************************************ */
-/* */
-/* This file is part of CeCe. */
-/* */
-/* CeCe is free software: you can redistribute it and/or modify */
-/* it under the terms of the GNU General Public License as published by */
-/* the Free Software Foundation, either version 3 of the License, or */
-/* (at your option) any later version. */
-/* */
-/* CeCe is distributed in the hope that it will be useful, */
-/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
-/* GNU General Public License for more details. */
-/* */
-/* You should have received a copy of the GNU General Public License */
-/* along with CeCe. If not, see . */
-/* */
-/* ************************************************************************ */
-
-#pragma once
-
-/* ************************************************************************ */
-
-// C++
-#include
-#include
-
-// CeCe
-#include "cece/core/Assert.hpp"
-#include "cece/core/UniquePtr.hpp"
-#include "cece/core/ViewPtr.hpp"
-#include "cece/core/String.hpp"
-#include "cece/core/StringView.hpp"
-#include "cece/core/DynamicArray.hpp"
-
-/* ************************************************************************ */
-
-/**
- * @brief Define pointer named container specialization.
- */
-#define CECE_PTR_NAMED_CONTAINER(...) \
- namespace cece { inline namespace core { template class PtrNamedContainer<__VA_ARGS__>; } }
-
-/**
- * @brief Define extern pointer named container specialization.
- */
-#define CECE_PTR_NAMED_CONTAINER_EXTERN(...) \
- namespace cece { inline namespace core { extern template class PtrNamedContainer<__VA_ARGS__>; } }
-
-/**
- * @brief Define pointer named container specialization.
- */
-#define CECE_PTR_NAMED_CONTAINER_INST(...) \
- namespace cece { inline namespace core { template class PtrNamedContainer<__VA_ARGS__>; } }
-
-/* ************************************************************************ */
-
-namespace cece {
-inline namespace core {
-
-/* ************************************************************************ */
-
-/**
- * @brief Container for named pointers.
- */
-template
-class PtrNamedContainer
-{
-
-// Public Types
-public:
-
-
- /// Pointer type.
- using type = T;
-
-
-// Public Structures
-public:
-
-
- /**
- * @brief Container record.
- */
- struct Record
- {
- /// Object name.
- String name;
-
- /// Pointer to object.
- UniquePtr object;
-
-
- /**
- * @brief Implicit cast to view pointer operator.
- */
- operator ViewPtr() const noexcept
- {
- return object;
- }
-
-
- /**
- * @brief Implicit cast to operator.
- */
- operator T*() const noexcept
- {
- return object.get();
- }
-
-
- /**
- * @brief Dereference operator.
- *
- * @return Reference.
- */
- T& operator*() const noexcept
- {
- return *object;
- }
-
-
- /**
- * @brief Pointer access operator.
- *
- * @return Pointer.
- */
- T* operator->() const noexcept
- {
- return object.get();
- }
- };
-
-
-// Public Operators
-public:
-
-
- /**
- * @brief Returns object with given name.
- *
- * @param name Object name.
- *
- * @return Pointer to object.
- */
- ViewPtr operator[](StringView name) const noexcept
- {
- return get(name);
- }
-
-
-// Public Accessors
-public:
-
-
- /**
- * @brief Returns a number of stored objects.
- *
- * @return
- */
- std::size_t getCount() const noexcept
- {
- return m_data.size();
- }
-
-
- /**
- * @brief Returns if an object with given name exists.
- *
- * @param name Object name.
- *
- * @return
- */
- bool exists(StringView name) const noexcept
- {
- return find(m_data, name) != nullptr;
- }
-
-
- /**
- * @brief Returns object with given value.
- *
- * @param name Object name.
- *
- * @return Pointer to object. Can be nullptr.
- */
- ViewPtr get(StringView name) const noexcept
- {
- auto ptr = find(m_data, name);
-
- if (ptr)
- return *ptr;
-
- return nullptr;
- }
-
-
- /**
- * @brief Returns object with given value.
- *
- * @tparam T2 Required type.
- *
- * @param name Object name.
- *
- * @return Pointer to object. Can be nullptr.
- */
- template
- ViewPtr get(StringView name) const noexcept
- {
- auto ptr = get(name);
- if (!ptr)
- return nullptr;
-
- CECE_ASSERT(dynamic_cast(ptr.get()));
- return static_cast(ptr.get());
- }
-
-
- /**
- * @brief Returns begin iterator.
- *
- * @return
- */
- typename DynamicArray::const_iterator begin() const noexcept
- {
- return m_data.begin();
- }
-
-
- /**
- * @brief Returns begin iterator.
- *
- * @return
- */
- typename DynamicArray::const_iterator cbegin() const noexcept
- {
- return m_data.cbegin();
- }
-
-
- /**
- * @brief Returns end iterator.
- *
- * @return
- */
- typename DynamicArray::const_iterator end() const noexcept
- {
- return m_data.end();
- }
-
-
- /**
- * @brief Returns end iterator.
- *
- * @return
- */
- typename DynamicArray::const_iterator cend() const noexcept
- {
- return m_data.cend();
- }
-
-
-// Public Mutators
-public:
-
-
- /**
- * @brief Store and object.
- *
- * @param object The object to store.
- *
- * @return View pointer to stored object.
- */
- ViewPtr add(String name, UniquePtr object)
- {
- auto ptr = find(m_data, name);
-
- if (ptr)
- {
- *ptr = std::move(object);
- return *ptr;
- }
- else
- {
- m_data.emplace_back(Record{std::move(name), std::move(object)});
- return m_data.back().object;
- }
- }
-
-
- /**
- * @brief Remove object from container.
- *
- * @param name Object name.
- *
- * @return A pointer to removed object.
- */
- UniquePtr remove(StringView name)
- {
- for (auto itB = m_data.begin(), itE = m_data.end(); itB != itE; ++itB)
- {
- if (itB->name == name)
- {
- auto ptr = std::move(itB->object);
- m_data.erase(itB);
- return ptr;
- }
- }
-
- // Not found
- return nullptr;
- }
-
-
- /**
- * @brief Clear container.
- */
- void clear()
- {
- m_data.clear();
- }
-
-
-// Protected Operations
-protected:
-
-
- /**
- * @brief Invoke a member function for all stored objects.
- *
- * @tparam Args A list of member function arguments.
- *
- * @param function A pointer to object's member function that will be
- * called for all stored listeners.
- * @param args...
- */
- template
- void invoke(void (T::*fn)(Args...), Args&& ... args) const
- {
- // Foreach all object
- for (const auto& object : m_data)
- {
- // Call member function with given arguments
- (object.object.get()->*fn)(std::forward(args)...);
- }
- }
-
-
-// Private Operations
-private:
-
-
- /**
- * @brief Find an object in container.
- *
- * @param data
- *
- * @return
- */
- template
- static auto find(ContainerType& data, StringView name) noexcept -> decltype(&(data.begin()->object))
- {
- auto it = std::find_if(data.begin(), data.end(),
- [&name](const Record& p) {
- return p.name == name;
- }
- );
-
- return it != data.end() ? &(it->object) : nullptr;
- }
-
-
-// Private Data Members
-private:
-
- /// Stored pointers.
- DynamicArray m_data;
-
-};
-
-/* ************************************************************************ */
-
-}
-}
-
-/* ************************************************************************ */
diff --git a/cece/core/StringView.hpp b/cece/core/StringView.hpp
deleted file mode 100644
index 07c2414..0000000
--- a/cece/core/StringView.hpp
+++ /dev/null
@@ -1,280 +0,0 @@
-/* ************************************************************************ */
-/* Georgiev Lab (c) 2015-2016 */
-/* ************************************************************************ */
-/* Department of Cybernetics */
-/* Faculty of Applied Sciences */
-/* University of West Bohemia in Pilsen */
-/* ************************************************************************ */
-/* */
-/* This file is part of CeCe. */
-/* */
-/* CeCe is free software: you can redistribute it and/or modify */
-/* it under the terms of the GNU General Public License as published by */
-/* the Free Software Foundation, either version 3 of the License, or */
-/* (at your option) any later version. */
-/* */
-/* CeCe is distributed in the hope that it will be useful, */
-/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
-/* GNU General Public License for more details. */
-/* */
-/* You should have received a copy of the GNU General Public License */
-/* along with CeCe. If not, see . */
-/* */
-/* ************************************************************************ */
-
-#pragma once
-
-/* ************************************************************************ */
-
-// C++
-#include
-#include
-
-// CeCe
-#include "cece/core/String.hpp"
-#include "cece/core/OutStream.hpp"
-#include "cece/core/InStream.hpp"
-#include "cece/core/StaticArray.hpp"
-#include "cece/core/DynamicArray.hpp"
-
-/* ************************************************************************ */
-
-namespace cece {
-inline namespace core {
-
-/* ************************************************************************ */
-
-/**
- * @brief View for string independent on string storage.
- */
-class StringView
-{
-
-// Public Types
-public:
-
-
- /// Character type.
- using CharType = char;
-
- /// Sequence length type.
- using LengthType = std::size_t;
-
- /// Sequence position type.
- using PositionType = std::size_t;
-
-
-// Public Ctors & Dtors
-public:
-
-
- /**
- * @brief Default constructor.
- */
- StringView() = default;
-
-
- /**
- * @brief Constructor.
- *
- * @param ptr Sequence start pointer.
- * @param len Sequence length.
- */
- StringView(const CharType* ptr, LengthType len) noexcept
- : m_ptr(ptr)
- , m_length(len)
- {
- // Nothing to do
- }
-
-
- /**
- * @brief Constructor.
- *
- * @param ptr Sequence start pointer.
- */
- StringView(const CharType* ptr) noexcept
- : m_ptr(ptr)
- , m_length(strlen(ptr))
- {
- // Nothing to do
- }
-
-
- /**
- * @brief Constructor.
- *
- * @param str String.
- */
- StringView(const String& str) noexcept
- : m_ptr(str.c_str())
- , m_length(str.length())
- {
- // Nothing to do
- }
-
-
- /**
- * @brief Constructor.
- *
- * @param str String.
- */
- StringView(const DynamicArray& str) noexcept
- : m_ptr(str.data())
- , m_length(str.size())
- {
- // Nothing to do
- }
-
-
- /**
- * @brief Constructor.
- *
- * @param str String.
- */
- template
- StringView(const StaticArray& str) noexcept
- : m_ptr(str.data())
- , m_length(str.size())
- {
- // Nothing to do
- }
-
-
-// Public Operators
-public:
-
-
- /**
- * @brief Get character at given position.
- *
- * @param pos Character position.
- *
- * @return
- */
- CharType operator[](PositionType pos) const noexcept
- {
- return m_ptr[pos];
- }
-
-
- /**
- * @brief Cast to String.
- */
- explicit operator String() const noexcept
- {
- return String(m_ptr, m_length);
- }
-
-
-// Public Accessors
-public:
-
-
- /**
- * @brief Returns sequence data.
- *
- * @return
- */
- const CharType* getData() const noexcept
- {
- return m_ptr;
- }
-
-
- /**
- * @brief Returns sequence length.
- *
- * @return
- */
- LengthType getLength() const noexcept
- {
- return m_length;
- }
-
-
-// Private Data Members
-private:
-
- /// Start of the string.
- const CharType* m_ptr = nullptr;
-
- /// Length of the string.
- LengthType m_length = 0;
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief Compare operator.
- *
- * @param lhs Left operand.
- * @param rhs Right operand.
- *
- * @return
- */
-inline bool operator==(const StringView& lhs, const StringView& rhs) noexcept
-{
- // Data pointer and length match -> same views.
- if (lhs.getData() == rhs.getData() && lhs.getLength() == rhs.getLength())
- return true;
-
- // Different lengths
- if (lhs.getLength() != rhs.getLength())
- return false;
-
- // Compare all characters
- return !strncmp(lhs.getData(), rhs.getData(), lhs.getLength());
-}
-
-/* ************************************************************************ */
-
-/**
- * @brief Compare operator.
- *
- * @param lhs Left operand.
- * @param rhs Right operand.
- *
- * @return
- */
-inline bool operator!=(const StringView& lhs, const StringView& rhs)
-{
- return !operator==(lhs, rhs);
-}
-
-/* ************************************************************************ */
-
-/**
- * @brief Output stream operator for StringView.
- *
- * @param os Output stream.
- * @param view View to print.
- *
- * @return os.
- */
-inline OutStream& operator<<(OutStream& os, const StringView& view) noexcept
-{
- return os.write(view.getData(), view.getLength());
-}
-
-/* ************************************************************************ */
-
-/**
- * @brief Input stream operator for StringView.
- *
- * @note StringView cannot be used as string storage.
- *
- * @param is Input stream.
- * @param view Output view.
- *
- * @return is.
- */
-inline InStream& operator<<(InStream& is, StringView& view) noexcept = delete;
-
-/* ************************************************************************ */
-
-}
-}
-
-/* ************************************************************************ */
diff --git a/cece/core/Unit.hpp b/cece/core/Unit.hpp
deleted file mode 100644
index 16f6e5e..0000000
--- a/cece/core/Unit.hpp
+++ /dev/null
@@ -1,1615 +0,0 @@
-/* ************************************************************************ */
-/* Georgiev Lab (c) 2015-2016 */
-/* ************************************************************************ */
-/* Department of Cybernetics */
-/* Faculty of Applied Sciences */
-/* University of West Bohemia in Pilsen */
-/* ************************************************************************ */
-/* */
-/* This file is part of CeCe. */
-/* */
-/* CeCe is free software: you can redistribute it and/or modify */
-/* it under the terms of the GNU General Public License as published by */
-/* the Free Software Foundation, either version 3 of the License, or */
-/* (at your option) any later version. */
-/* */
-/* CeCe is distributed in the hope that it will be useful, */
-/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
-/* GNU General Public License for more details. */
-/* */
-/* You should have received a copy of the GNU General Public License */
-/* along with CeCe. If not, see . */
-/* */
-/* ************************************************************************ */
-
-#pragma once
-
-/* ************************************************************************ */
-
-// C++
-#include
-#include
-#include
-
-// CeCe
-#include "cece/core/Real.hpp"
-#include "cece/core/Zero.hpp"
-#include "cece/core/String.hpp"
-#include "cece/core/StringView.hpp"
-#include "cece/core/StaticArray.hpp"
-
-/* ************************************************************************ */
-
-namespace cece {
-inline namespace core {
-
-/* ************************************************************************ */
-
-namespace units {
-
-/* ************************************************************************ */
-
-/**
- * @brief Basic value.
- */
-using Value = RealType;
-
-/* ************************************************************************ */
-
-/// Base units exponents
-static constexpr int LENGTH_EXPONENT = 6;
-static constexpr int TIME_EXPONENT = 0;
-static constexpr int MASS_EXPONENT = 6;
-static constexpr int ELECTRIC_CURRENT_EXPONENT = 0;
-static constexpr int THERMODYNAMIC_TEMPERATURE_EXPONENT = 0;
-static constexpr int AMOUNT_OF_SUBSTANCE_EXPONENT = 6;
-static constexpr int LUMINOUS_INTENSITY_EXPONENT = 0;
-
-/* ************************************************************************ */
-
-/// @link http://stackoverflow.com/questions/26682812/argument-counting-macro-with-zero-arguments-for-visualstudio-2010/26685339#26685339
-#ifdef _MSC_VER // Microsoft compilers
-
-#define EXPAND(x) x
-#define __NARGS(_1, _2, _3, _4, N, ...) N
-#define NARGS_1(...) EXPAND(__NARGS(__VA_ARGS__, 3, 2, 1, 0))
-
-#define AUGMENTER(...) unused, __VA_ARGS__
-#define NARG(...) NARGS_1(AUGMENTER(__VA_ARGS__))
-
-#else // And normal compilers
-
-/// @link https://azraelplanet.wordpress.com/2012/03/30/number-of-arguments-in-__va_args__-gcc/
-#define ARG_N(_1, _2, _3, N, ...) N
-#define NARG_(...) ARG_N(__VA_ARGS__)
-#define NARG(...) NARG_(__VA_ARGS__, 3, 2, 1, 0)
-
-#endif
-
-/* ************************************************************************ */
-
-/**
- * @brief Defines base unit.
- *
- * @param name Unit Name.
- * @param ord Unit order.
- * @param exp Value coefficient exponent.
- * @param ... Characters of unit symbol.
- */
-#define DEFINE_BASE_UNIT(name, exp, ord, ...) \
- struct Base ## name {\
- static constexpr int exponent = exp; \
- static constexpr int order = ord;\
- static constexpr std::size_t symbolLength = NARG(__VA_ARGS__) + 1; \
- static constexpr StaticArray getSymbol() noexcept \
- { \
- return {{__VA_ARGS__, '\0'}};\
- } \
- }
-
-/* ************************************************************************ */
-
-/**
- * @brief Base SI units.
- */
-DEFINE_BASE_UNIT(Length, LENGTH_EXPONENT, 0, 'm');
-DEFINE_BASE_UNIT(Time, TIME_EXPONENT, 1, 's');
-DEFINE_BASE_UNIT(Mass, MASS_EXPONENT, 2, 'g');
-DEFINE_BASE_UNIT(ElectricCurrent, ELECTRIC_CURRENT_EXPONENT, 3, 'A');
-DEFINE_BASE_UNIT(ThermodynamicTemperature, THERMODYNAMIC_TEMPERATURE_EXPONENT, 4, 'K');
-DEFINE_BASE_UNIT(AmountOfSubstance, AMOUNT_OF_SUBSTANCE_EXPONENT, 5, 'm', 'o', 'l');
-DEFINE_BASE_UNIT(LuminousIntensity, LUMINOUS_INTENSITY_EXPONENT, 6, 'c', 'd');
-
-/* ************************************************************************ */
-
-/**
- * @brief Calculate coefficient from exponent.
- *
- * @param exponent
- *
- * @return Result coefficient
- */
-inline constexpr Value exponentToCoefficient(int exponent) noexcept
-{
- return (exponent == 0)
- ? 1
- : (exponent > 0)
- ? 10 * exponentToCoefficient(exponent - 1)
- : 0.1 * exponentToCoefficient(exponent + 1)
- ;
-}
-
-/* ************************************************************************ */
-
-/**
- * @brief Less structure.
- *
- * @tparam T1 First base unit type.
- * @tparam T2 Second base unit type.
- */
-template
-struct Less
-{
- /// If T1 is less than T2
- static constexpr bool value = T1::order < T2::order;
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief List of types.
- *
- * @tparam Types A list of types.
- */
-template
-struct List
-{
-
- /// Number of types in list.
- static constexpr std::size_t size = sizeof...(Types);
-
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief Struct for calculating total coefficient exponent of given list.
- *
- * @tparam Types A list of unit types.
- */
-template
-struct Exponent;
-
-/* ************************************************************************ */
-
-/**
- * @brief Struct for calculating total coefficient exponent of given list.
- *
- * @tparam Types A list of unit types.
- */
-template
-struct Exponent>
-{
-
- /**
- * @brief Add coefficient exponents.
- *
- * @param arg The first coefficient exponent.
- * @param args Rest of the coefficient exponents.
- *
- * @return Result exponent.
- */
- template
- static constexpr int add(Arg&& arg, Args&&... args) noexcept
- {
- return arg + add(args...);
- }
-
-
- /**
- * @brief Add coefficient exponents.
- *
- * @return 1.
- */
- static constexpr int add() noexcept
- {
- return 0;
- }
-
-
- /// Calculate types coefficient exponent.
- static constexpr int value = add(Types::exponent...);
-
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief Concatenate two lists.
- *
- * @tparam T Types.
- */
-template
-struct Concat;
-
-/* ************************************************************************ */
-
-/**
- * @brief Concatenated specialization for single list.
- *
- * @tparam Types Types of the list.
- */
-template
-struct Concat>
-{
- /// Concatenated list.
- using type = List;
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief Concatenate two lists.
- *
- * @tparam Types1 Types of the first list.
- * @tparam Types2 Types of the second list.
- * @tparam Tail Remaining types.
- */
-template
-struct Concat, List, Tail...>
-{
- /// Concatenated list.
- using type = typename Concat, Tail...>::type;
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief Type counter.
- *
- * @tparam T Type to count.
- * @tparam List List of types.
- */
-template
-struct Counter;
-
-/* ************************************************************************ */
-
-/**
- * @brief Type counter.
- *
- * @tparam T Type to count.
- */
-template
-struct Counter>
-{
- /// Number of occurences.
- static constexpr std::size_t value = 0;
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief Type counter.
- *
- * @tparam T Type to count.
- * @tparam Type The first type from types.
- * @tparam List List of types.
- */
-template
-struct Counter>
-{
- /// Number of occurences.
- static constexpr std::size_t value =
- (std::is_same::value ? 1 : 0) +
- Counter>::value
- ;
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief Type counter.
- *
- * @tparam List List of types.
- */
-template
-struct CounterFirst;
-
-/* ************************************************************************ */
-
-/**
- * @brief Type counter.
- *
- * @tparam List List of types.
- */
-template<>
-struct CounterFirst>
-{
- /// Number of occurences.
- static constexpr std::size_t value = 0;
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief Type counter.
- *
- * @tparam Type The first type from types.
- * @tparam List List of types.
- */
-template
-struct CounterFirst>
-{
- /// Number of occurences.
- static constexpr std::size_t value = Counter>::value;
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief Remove type from list.
- *
- * @tparam T Type to remove.
- * @tparam List List of types.
- */
-template
-struct Remove;
-
-/* ************************************************************************ */
-
-/**
- * @brief Remove type from list.
- *
- * @tparam T Type to remove.
- */
-template
-struct Remove>
-{
- // Not found
- static constexpr bool value = false;
-
- // Remaining types.
- using type = List<>;
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief Remove type element from list.
- *
- * @tparam T Type to remove.
- * @tparam Type First type.
- * @tparam Types Remaining types in the list.
- */
-template
-struct Remove>
-{
- /// If types match.
- static constexpr bool match = std::is_same::value;
-
- // Inner remove.
- using RemoveInnerType = Remove>;
-
- // If type is found.
- static constexpr bool value = match || RemoveInnerType::value;
-
- /// List type without the required type.
- using type = typename std::conditional,
- typename Concat, typename RemoveInnerType::type>::type
- >::type;
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief Helper class to reduce units.
- *
- * @tparam Nom Nominators.
- * @tparam Denom Denominators.
- */
-template
-struct ReduceInner;
-
-/* ************************************************************************ */
-
-/**
- * @brief Helper class to reduce units.
- *
- * @tparam Denominators List types.
- */
-template
-struct ReduceInner, List>
-{
- using nominators = List<>;
- using denominators = List;
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief Helper class to simplify units.
- *
- * Type removes shared types in nominator and denominator.
- *
- * @tparam Nom First nominator.
- * @tparam Nominators List types.
- * @tparam Denominators List types.
- */
-template
-struct ReduceInner, List>
-{
- /// Type of removing type.
- using remove_type = Remove>;
-
- // Reduce without the first nominator
- using reduce_inner = ReduceInner, typename remove_type::type>;
-
- /// List of nominators
- using nominators = typename std::conditional, typename reduce_inner::nominators>::type
- >::type;
-
- /// List of denominators
- using denominators = typename reduce_inner::denominators;
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief Remove all occurences of given type element from list.
- *
- * @tparam T Type to remove.
- * @tparam List List of types.
- */
-template
-struct RemoveAll;
-
-/* ************************************************************************ */
-
-/**
- * @brief Remove all occurences of given type element from list.
- *
- * @tparam T Type to remove.
- */
-template
-struct RemoveAll>
-{
- // Not found
- static constexpr bool value = false;
-
- // Number of occurences.
- static constexpr std::size_t count = 0;
-
- // Remaining types.
- using type = List<>;
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief Remove all occurences of given type element from list.
- *
- * @tparam T Type to remove.
- * @tparam Type First type.
- * @tparam Types Remaining types in the list.
- */
-template
-struct RemoveAll>
-{
- /// If types match.
- static constexpr bool match = std::is_same::value;
-
- // Inner remove.
- using RemoveInnerType = RemoveAll>;
-
- // If type is found.
- static constexpr bool value = match || RemoveInnerType::value;
-
- // Number of occurences.
- static constexpr std::size_t count = (match ? 1 : 0) + RemoveInnerType::count;
-
- /// List type without the required type.
- using type = typename std::conditional, typename RemoveInnerType::type>::type
- >::type;
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief SI Unit.
- *
- * @tparam Nom List type.
- * @tparam Denom List type.
- */
-template
-class Unit
-{
-
-// Public Types
-public:
-
-
- /// Value type.
- using value_type = Value;
-
- /// List type.
- using nominator = Nom;
-
- /// List type.
- using denominator = Denom;
-
-// Public Constants
-public:
-
-
- /// Total unit coefficient.
- static constexpr int exponent = Exponent::value - Exponent::value;
-
- /// Number of occurences of the first nominator.
- static constexpr std::size_t firstCountNom = CounterFirst::value;
-
- /// Number of occurences of the first denominator.
- static constexpr std::size_t firstCountDenom = CounterFirst::value;
-
-
-// Public Ctors & Dtors
-public:
-
-
- /**
- * @brief Default constructor.
- */
- Unit() noexcept
- : m_value{}
- {
- // Default ( = default) constructor and extern template are not
- // friends in GCC
- }
-
-
- /**
- * @brief Constructor.
- *
- * @param value Init value.
- */
- explicit constexpr Unit(value_type value) noexcept
- : m_value(value)
- {
- // Nothing to do
- }
-
-
- /**
- * @brief Zero constructor.
- */
- constexpr Unit(Zero_t) noexcept
- : m_value(0)
- {
- // Nothing to do
- }
-
-
-// Public Operators
-public:
-
-
- /**
- * @brief If value is set operator.
- *
- * @return
- */
- explicit operator bool() const noexcept
- {
- return m_value != 0;
- }
-
-
- /**
- * @brief Cast to value type.
- *
- * @return
- */
- explicit operator Value() const noexcept
- {
- return m_value;
- }
-
-
- /**
- * @brief Unary plus operator.
- *
- * @return New value.
- */
- Unit operator+() const noexcept
- {
- return Unit(m_value);
- }
-
-
- /**
- * @brief Unary minus operator.
- *
- * @return New value.
- */
- Unit operator-() const noexcept
- {
- return Unit(-m_value);
- }
-
-
- /**
- * @brief Addition operator.
- *
- * @param rhs
- *
- * @return *this.
- */
- Unit& operator+=(Unit rhs) noexcept
- {
- m_value += rhs.m_value;
- return *this;
- }
-
-
- /**
- * @brief Substraction operator.
- *
- * @param rhs Right operand.
- *
- * @return *this.
- */
- Unit& operator-=(Unit rhs) noexcept
- {
- m_value -= rhs.m_value;
- return *this;
- }
-
-
- /**
- * @brief Multiplication operator.
- *
- * @param rhs Right operand.
- *
- * @return *this.
- */
- Unit& operator*=(value_type rhs) noexcept
- {
- m_value *= rhs;
- return *this;
- }
-
-
- /**
- * @brief Division operator.
- *
- * @param rhs Right operand.
- *
- * @return *this.
- */
- Unit& operator/=(value_type rhs) noexcept
- {
- m_value /= rhs;
- return *this;
- }
-
-
-// Public Accessors
-public:
-
-
- /**
- * @brief Returns current value.
- *
- * @return
- */
- constexpr value_type value() const noexcept
- {
- return m_value;
- }
-
-
-// Private Data Members
-private:
-
- /// Stored value.
- value_type m_value;
-
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief Reduce empty lists.
- */
-template
-struct ReduceEmpty
-{
- /// Result unit type.
- using type = Unit;
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief Reduce empty lists.
- */
-template<>
-struct ReduceEmpty, List<>>
-{
- /// Result unit type.
- using type = Value;
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief Value filter.
- *
- * @tparam T Type to filter.
- * @tparam neg Negate less.
- * @tparam Types Types.
- */
-template
-struct Filter;
-
-/* ************************************************************************ */
-
-/**
- * @brief Value filter.
- *
- * @tparam T Type to filter.
- * @tparam neg Negate less.
- * @tparam Type First type.
- * @tparam Types Types.
- */
-template
-struct Filter>
-{
- // List without the first type.
- using tail = typename Filter>::type;
-
- using type = typename std::conditional<
- neg ^ Less::value,
- typename Concat, tail>::type,
- tail
- >::type;
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief Value filter.
- *
- * @tparam T Type to filter.
- * @tparam neg Negate less.
- */
-template
-struct Filter>
-{
- using type = List<>;
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief List sorting structure.
- *
- * @tparam Types Types.
- */
-template
-struct Sort;
-
-/* ************************************************************************ */
-
-/**
- * @brief List sorting structure.
- *
- * @tparam Type First type.
- * @tparam Types A list of types.
- */
-template
-struct Sort>
-{
- using front = typename Filter>::type;
- using tail = typename Filter>::type;
-
- // Sorted list.
- using type = typename Concat, tail>::type;
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief List sorting structure.
- *
- * @tparam Type Type.
- */
-template
-struct Sort>
-{
- using type = List;
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief List sorting structure.
- */
-template<>
-struct Sort>
-{
- using type = List<>;
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief Helper class to reduce units.
- *
- * @tparam Nom Nominators.
- * @tparam Denom Denominators.
- */
-template
-struct Reduce;
-
-/* ************************************************************************ */
-
-/**
- * @brief Helper class to simplify units.
- *
- * Type removes shared types in nominator and denominator.
- *
- * @tparam Nom First nominator.
- * @tparam Nominators List types.
- * @tparam Denominators List types.
- */
-template
-struct Reduce, List>
-{
- // Inner reduce
- using inner = ReduceInner, List>;
-
- /// Result unit type.
- using type = typename ReduceEmpty<
- typename Sort::type,
- typename Sort::type
- >::type;
-};
-
-/* ************************************************************************ */
-
-/**
- * @brief Compare operator.
- *
- * @tparam Nominators A list of nominators.
- * @tparam Denominators A list of denominators.
- *
- * @param lhs Left operand.
- * @param rhs Right operand.
- *
- * @return Result value.
- */
-template
-inline constexpr bool operator==(
- Unit, List> lhs,
- Unit, List> rhs
-) noexcept
-{
- return std::abs(lhs.value() - rhs.value()) < std::numeric_limits::epsilon();
- //return lhs.value() == rhs.value();
-}
-
-/* ************************************************************************ */
-
-/**
- * @brief Compare operator.
- *
- * @tparam Nominators A list of nominators.
- * @tparam Denominators A list of denominators.
- *
- * @param lhs Left operand.
- * @param rhs Right operand.
- *
- * @return Result value.
- */
-template
-inline constexpr bool operator==(
- Unit, List> lhs, Zero_t rhs
-) noexcept
-{
- return lhs == Unit, List>(Zero);
-}
-
-/* ************************************************************************ */
-
-/**
- * @brief Compare operator.
- *
- * @tparam Nominators A list of nominators.
- * @tparam Denominators A list of denominators.
- *
- * @param lhs Left operand.
- * @param rhs Right operand.
- *
- * @return Result value.
- */
-template
-inline constexpr bool operator==(
- Zero_t lhs, Unit, List> rhs
-) noexcept
-{
- return Unit, List>(Zero) == rhs;
-}
-
-/* ************************************************************************ */
-
-/**
- * @brief Compare operator.
- *
- * @tparam Nominators A list of nominators.
- * @tparam Denominators A list of denominators.
- *
- * @param lhs Left operand.
- * @param rhs Right operand.
- *
- * @return Result value.
- */
-template
-inline constexpr bool operator!=(
- Unit, List> lhs,
- Unit, List> rhs
-) noexcept
-{
- return !operator==(lhs, rhs);
-}
-
-/* ************************************************************************ */
-
-/**
- * @brief Compare operator.
- *
- * @tparam Nominators A list of nominators.
- * @tparam Denominators A list of denominators.
- *
- * @param lhs Left operand.
- * @param rhs Right operand.
- *
- * @return Result value.
- */
-template
-inline constexpr bool operator!=(
- Unit, List> lhs, Zero_t rhs
-) noexcept
-{
- return !operator==(lhs, rhs);
-}
-
-/* ************************************************************************ */
-
-/**
- * @brief Compare operator.
- *
- * @tparam Nominators A list of nominators.
- * @tparam Denominators A list of denominators.
- *
- * @param lhs Left operand.
- * @param rhs Right operand.
- *
- * @return Result value.
- */
-template
-inline constexpr bool operator!=(
- Zero_t lhs, Unit, List> rhs
-) noexcept
-{
- return !operator==(lhs, rhs);
-}
-
-/* ************************************************************************ */
-
-/**
- * @brief Less operator.
- *
- * @tparam Nominators A list of nominators.
- * @tparam Denominators A list of denominators.
- *
- * @param lhs Left operand.
- * @param rhs Right operand.
- *
- * @return Result value.
- */
-template
-inline constexpr bool operator<(
- Unit, List> lhs,
- Unit, List> rhs
-) noexcept
-{
- return lhs.value() < rhs.value();
-}
-
-/* ************************************************************************ */
-
-/**
- * @brief Less operator.
- *
- * @tparam Nominators A list of nominators.
- * @tparam Denominators A list of denominators.
- *
- * @param lhs Left operand.
- * @param rhs Zero.
- *
- * @return Result value.
- */
-template
-inline constexpr bool operator<(
- Unit, List> lhs, Zero_t
-) noexcept
-{
- return lhs.value() < 0;
-}
-
-/* ************************************************************************ */
-
-/**
- * @brief Less operator.
- *
- * @tparam Nominators A list of nominators.
- * @tparam Denominators A list of denominators.
- *
- * @param lhs Zero.
- * @param rhs Right operand.
- *
- * @return Result value.
- */
-template
-inline constexpr bool operator<(
- Zero_t, Unit, List> rhs
-) noexcept
-{
- return 0 < rhs.value();
-}
-
-/* ************************************************************************ */
-
-/**
- * @brief Less equals operator.
- *
- * @tparam Nominators A list of nominators.
- * @tparam Denominators A list of denominators.
- *
- * @param lhs Left operand.
- * @param rhs Right operand.
- *
- * @return Result value.
- */
-template
-inline constexpr bool operator<=(
- Unit, List> lhs,
- Unit, List> rhs
-) noexcept
-{
- return !operator>(lhs, rhs);
-}
-
-/* ************************************************************************ */
-
-/**
- * @brief Less equals operator.
- *
- * @tparam Nominators A list of nominators.
- * @tparam Denominators A list of denominators.
- *
- * @param lhs Left operand.
- * @param rhs Zero.
- *
- * @return Result value.
- */
-template
-inline constexpr bool operator<=(
- Unit, List> lhs, Zero_t
-) noexcept
-{
- return !operator>(lhs, Zero);
-}
-
-/* ************************************************************************ */
-
-/**
- * @brief Less equals operator.
- *
- * @tparam Nominators A list of nominators.
- * @tparam Denominators A list of denominators.
- *
- * @param lhs Zero.
- * @param rhs Right operand.
- *
- * @return Result value.
- */
-template
-inline constexpr bool operator<=(
- Zero_t, Unit, List> rhs
-) noexcept
-{
- return !operator>(Zero, rhs);
-}
-
-/* ************************************************************************ */
-
-/**
- * @brief Greater operator.
- *
- * @tparam Nominators A list of nominators.
- * @tparam Denominators A list of denominators.
- *
- * @param lhs Left operand.
- * @param rhs Right operand.
- *
- * @return Result value.
- */
-template
-inline constexpr bool operator>(
- Unit, List> lhs,
- Unit, List> rhs
-) noexcept
-{
- return operator<(rhs, lhs);
-}
-
-/* ************************************************************************ */
-
-/**
- * @brief Greater operator.
- *
- * @tparam Nominators A list of nominators.
- * @tparam Denominators A list of denominators.
- *
- * @param lhs Left operand.
- * @param rhs Zero.
- *
- * @return Result value.
- */
-template
-inline constexpr bool operator>(
- Unit, List> lhs, Zero_t
-) noexcept
-{
- return operator<(Zero, lhs);
-}
-
-/* ************************************************************************ */
-
-/**
- * @brief Greater operator.
- *
- * @tparam Nominators A list of nominators.
- * @tparam Denominators A list of denominators.
- *
- * @param lhs Zero.
- * @param rhs Right operand.
- *
- * @return Result value.
- */
-template