mirror of
https://github.com/ETLCPP/etl.git
synced 2026-10-28 18:07:10 +08:00
Add free-standing sanity tests for C++03/11/14/17 (#351)
* Add ETL_CONSTEXPR for state_chart, transision and state constructors. * Updated versions * Added ETL_CONSTEXPR * Added ETL_CONSTEXPR * Updated version numbers * Updated version numbers * Add buffer descriptors * Issue 297 * Updated version numbers * Added extra std/etl conversions * Updated strings Re-introduced case utilities Fixed make_string for empty strings * make_string_view + fix constexpr in flags.h * Added etl::buffer_descriptors. Added std/etl pair conversions. Added etl::make_string_view. Resolved issue with zero length literals for etl::make_string Resolved etl::flags constexpr issues. Added atomics for clang. Resolved type_traits issues for GCC < v5 * Added etl::buffer_descriptors. Added std/etl pair conversions. Added etl::make_string_view. Resolved issue with zero length literals for etl::make_string Resolved etl::flags constexpr issues. Added atomics for clang. Resolved type_traits issues for GCC < v5 * Fixed warnings * Disabled ASAN option in Visual Studio project. * Fix make_string for zero length literals Remove redundant test support code * Updated notes * Adding Tests for a fractional -1.0 < x < 0, fixing missing sign for integral parts equals to zero 0 (#306) Co-authored-by: Heinz-Peter Liechtenecker <h.liechtenecker@fh-kaernten.at> * #306-bugfix-to-string-formatting * Updated version numbers * Update setup-msbuild to v1.0.2 Updates Actions core toolkit to fix vulnerability on environment/path variable setting. * circular_buffer_ext * forward_list_ext * list_ext * indirect_vector_ext * string_ext * vector_ext * Updated .leu * Merge remote-tracking branch 'origin/feature/no-huge-value' into development * Remove VS2017 project * Refactor of etl::buffer_descriptors interface * Refactor buffer_descriptors test * Refactor buffer_descriptors test * Refactor buffer_descriptors test * Refactor buffer_descriptors test * Refactor buffer_descriptors test * Refactor buffer_descriptors test * clang.yml hack for testing * clang hack for testing * Refactor buffer_descriptors test * Refactor buffer_descriptors test * Refactor buffer_descriptors test * Refactor buffer_descriptors test * Refactor buffer_descriptors test * Refactor buffer_descriptors test * Refactor buffer_descriptors test * Refactor buffer_descriptors test * Refactor buffer_descriptors test * Refactor buffer_descriptors test * Refactor buffer_descriptors test * Refactor buffer_descriptors test * Refactor buffer_descriptors test * Fixed non-initialisation of in_use flag. * Fixed non-initialisation of in_use flag. * Squashed commit of the following: commit dceb56dd1a19be6fe9b991bb50e08902eefe36a8 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 19:27:18 2020 +0000 Fixed non-initialisation of in_use flag. commit c7ee1d6574ca5d95869152c5f8e4e6d02a7fa6bc Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 19:20:24 2020 +0000 Fixed non-initialisation of in_use flag. commit 36cbf21cd1b67a28255582cfb4a188a601631ab2 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:52:53 2020 +0000 Refactor buffer_descriptors test commit 49c60add63153bf53f400a891d8c4fb880cacda8 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:44:42 2020 +0000 Refactor buffer_descriptors test commit 7bda7678311bf2eb497483f3ef27c3af9211680b Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:29:02 2020 +0000 Refactor buffer_descriptors test commit 7a68c932a7df05f66690fa63e67365cf4b0619e8 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:14:30 2020 +0000 Refactor buffer_descriptors test commit a9b25ac67d175f58751a2eb819f0e5822e8f0cf9 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:08:21 2020 +0000 Refactor buffer_descriptors test commit 0c721c0466733751708fcbd995ce0bc1d7c0a932 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:58:22 2020 +0000 Refactor buffer_descriptors test commit 4b2dd2fce22cd0a4846b95695fbfd812e0823540 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:47:43 2020 +0000 Refactor buffer_descriptors test commit 80d5776c409b416377269d543bd539bdad83dc86 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:32:27 2020 +0000 Refactor buffer_descriptors test commit 3564ac5b7ef89c41b240d9f54fce36042408daa0 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:17:50 2020 +0000 Refactor buffer_descriptors test commit 297ef42c60e4228bfbcb2adcddeb6b8a617c4113 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:08:45 2020 +0000 Refactor buffer_descriptors test commit 658d592c96eb7eaf1afb5d09fef38e293ea6f79b Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 16:58:52 2020 +0000 Refactor buffer_descriptors test commit e97d8f90d5527349324ea84fd578c1d879d7a5a4 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 16:48:52 2020 +0000 Refactor buffer_descriptors test commit ed783a8ccccc8673c0f55eb1780c08668880a745 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 16:43:52 2020 +0000 clang.yml hack for testing * Squashed commit of the following: commit dceb56dd1a19be6fe9b991bb50e08902eefe36a8 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 19:27:18 2020 +0000 Fixed non-initialisation of in_use flag. commit c7ee1d6574ca5d95869152c5f8e4e6d02a7fa6bc Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 19:20:24 2020 +0000 Fixed non-initialisation of in_use flag. commit 36cbf21cd1b67a28255582cfb4a188a601631ab2 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:52:53 2020 +0000 Refactor buffer_descriptors test commit 49c60add63153bf53f400a891d8c4fb880cacda8 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:44:42 2020 +0000 Refactor buffer_descriptors test commit 7bda7678311bf2eb497483f3ef27c3af9211680b Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:29:02 2020 +0000 Refactor buffer_descriptors test commit 7a68c932a7df05f66690fa63e67365cf4b0619e8 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:14:30 2020 +0000 Refactor buffer_descriptors test commit a9b25ac67d175f58751a2eb819f0e5822e8f0cf9 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:08:21 2020 +0000 Refactor buffer_descriptors test commit 0c721c0466733751708fcbd995ce0bc1d7c0a932 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:58:22 2020 +0000 Refactor buffer_descriptors test commit 4b2dd2fce22cd0a4846b95695fbfd812e0823540 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:47:43 2020 +0000 Refactor buffer_descriptors test commit 80d5776c409b416377269d543bd539bdad83dc86 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:32:27 2020 +0000 Refactor buffer_descriptors test commit 3564ac5b7ef89c41b240d9f54fce36042408daa0 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:17:50 2020 +0000 Refactor buffer_descriptors test commit 297ef42c60e4228bfbcb2adcddeb6b8a617c4113 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:08:45 2020 +0000 Refactor buffer_descriptors test commit 658d592c96eb7eaf1afb5d09fef38e293ea6f79b Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 16:58:52 2020 +0000 Refactor buffer_descriptors test commit e97d8f90d5527349324ea84fd578c1d879d7a5a4 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 16:48:52 2020 +0000 Refactor buffer_descriptors test commit ed783a8ccccc8673c0f55eb1780c08668880a745 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 16:43:52 2020 +0000 clang.yml hack for testing * Squashed commit of the following: commit dceb56dd1a19be6fe9b991bb50e08902eefe36a8 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 19:27:18 2020 +0000 Fixed non-initialisation of in_use flag. commit c7ee1d6574ca5d95869152c5f8e4e6d02a7fa6bc Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 19:20:24 2020 +0000 Fixed non-initialisation of in_use flag. commit 36cbf21cd1b67a28255582cfb4a188a601631ab2 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:52:53 2020 +0000 Refactor buffer_descriptors test commit 49c60add63153bf53f400a891d8c4fb880cacda8 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:44:42 2020 +0000 Refactor buffer_descriptors test commit 7bda7678311bf2eb497483f3ef27c3af9211680b Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:29:02 2020 +0000 Refactor buffer_descriptors test commit 7a68c932a7df05f66690fa63e67365cf4b0619e8 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:14:30 2020 +0000 Refactor buffer_descriptors test commit a9b25ac67d175f58751a2eb819f0e5822e8f0cf9 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:08:21 2020 +0000 Refactor buffer_descriptors test commit 0c721c0466733751708fcbd995ce0bc1d7c0a932 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:58:22 2020 +0000 Refactor buffer_descriptors test commit 4b2dd2fce22cd0a4846b95695fbfd812e0823540 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:47:43 2020 +0000 Refactor buffer_descriptors test commit 80d5776c409b416377269d543bd539bdad83dc86 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:32:27 2020 +0000 Refactor buffer_descriptors test commit 3564ac5b7ef89c41b240d9f54fce36042408daa0 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:17:50 2020 +0000 Refactor buffer_descriptors test commit 297ef42c60e4228bfbcb2adcddeb6b8a617c4113 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:08:45 2020 +0000 Refactor buffer_descriptors test commit 658d592c96eb7eaf1afb5d09fef38e293ea6f79b Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 16:58:52 2020 +0000 Refactor buffer_descriptors test commit e97d8f90d5527349324ea84fd578c1d879d7a5a4 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 16:48:52 2020 +0000 Refactor buffer_descriptors test commit ed783a8ccccc8673c0f55eb1780c08668880a745 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 16:43:52 2020 +0000 clang.yml hack for testing * Squashed commit of the following: commit fa9d9592aa7cb686ae1e8c6eeedfcbfda7a59835 Author: John Wellbelove <github@wellbelove.co.uk> Date: Thu Nov 26 19:26:11 2020 +0000 format_spec may be constexpr * Squashed commit of the following: commit 638cceaf9c4a6964e58894adb36d633b01a1d5ac Author: John Wellbelove <github@wellbelove.co.uk> Date: Wed Nov 25 17:57:06 2020 +0000 Strings inherit secure status on copy. commit 5f1ab55c61ed62b5c234b5e1d6ac3ef362b78851 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 22:33:08 2020 +0000 Squashed commit of the following: commit dceb56dd1a19be6fe9b991bb50e08902eefe36a8 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 19:27:18 2020 +0000 Fixed non-initialisation of in_use flag. commit c7ee1d6574ca5d95869152c5f8e4e6d02a7fa6bc Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 19:20:24 2020 +0000 Fixed non-initialisation of in_use flag. commit 36cbf21cd1b67a28255582cfb4a188a601631ab2 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:52:53 2020 +0000 Refactor buffer_descriptors test commit 49c60add63153bf53f400a891d8c4fb880cacda8 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:44:42 2020 +0000 Refactor buffer_descriptors test commit 7bda7678311bf2eb497483f3ef27c3af9211680b Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:29:02 2020 +0000 Refactor buffer_descriptors test commit 7a68c932a7df05f66690fa63e67365cf4b0619e8 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:14:30 2020 +0000 Refactor buffer_descriptors test commit a9b25ac67d175f58751a2eb819f0e5822e8f0cf9 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:08:21 2020 +0000 Refactor buffer_descriptors test commit 0c721c0466733751708fcbd995ce0bc1d7c0a932 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:58:22 2020 +0000 Refactor buffer_descriptors test commit 4b2dd2fce22cd0a4846b95695fbfd812e0823540 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:47:43 2020 +0000 Refactor buffer_descriptors test commit 80d5776c409b416377269d543bd539bdad83dc86 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:32:27 2020 +0000 Refactor buffer_descriptors test commit 3564ac5b7ef89c41b240d9f54fce36042408daa0 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:17:50 2020 +0000 Refactor buffer_descriptors test commit 297ef42c60e4228bfbcb2adcddeb6b8a617c4113 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:08:45 2020 +0000 Refactor buffer_descriptors test commit 658d592c96eb7eaf1afb5d09fef38e293ea6f79b Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 16:58:52 2020 +0000 Refactor buffer_descriptors test commit e97d8f90d5527349324ea84fd578c1d879d7a5a4 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 16:48:52 2020 +0000 Refactor buffer_descriptors test commit ed783a8ccccc8673c0f55eb1780c08668880a745 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 16:43:52 2020 +0000 clang.yml hack for testing commit c26e42253f4502c3afb943a7ff1f7ef0f79c475b Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 19:32:48 2020 +0000 Squashed commit of the following: commit dceb56dd1a19be6fe9b991bb50e08902eefe36a8 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 19:27:18 2020 +0000 Fixed non-initialisation of in_use flag. commit c7ee1d6574ca5d95869152c5f8e4e6d02a7fa6bc Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 19:20:24 2020 +0000 Fixed non-initialisation of in_use flag. commit 36cbf21cd1b67a28255582cfb4a188a601631ab2 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:52:53 2020 +0000 Refactor buffer_descriptors test commit 49c60add63153bf53f400a891d8c4fb880cacda8 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:44:42 2020 +0000 Refactor buffer_descriptors test commit 7bda7678311bf2eb497483f3ef27c3af9211680b Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:29:02 2020 +0000 Refactor buffer_descriptors test commit 7a68c932a7df05f66690fa63e67365cf4b0619e8 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:14:30 2020 +0000 Refactor buffer_descriptors test commit a9b25ac67d175f58751a2eb819f0e5822e8f0cf9 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:08:21 2020 +0000 Refactor buffer_descriptors test commit 0c721c0466733751708fcbd995ce0bc1d7c0a932 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:58:22 2020 +0000 Refactor buffer_descriptors test commit 4b2dd2fce22cd0a4846b95695fbfd812e0823540 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:47:43 2020 +0000 Refactor buffer_descriptors test commit 80d5776c409b416377269d543bd539bdad83dc86 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:32:27 2020 +0000 Refactor buffer_descriptors test commit 3564ac5b7ef89c41b240d9f54fce36042408daa0 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:17:50 2020 +0000 Refactor buffer_descriptors test commit 297ef42c60e4228bfbcb2adcddeb6b8a617c4113 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:08:45 2020 +0000 Refactor buffer_descriptors test commit 658d592c96eb7eaf1afb5d09fef38e293ea6f79b Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 16:58:52 2020 +0000 Refactor buffer_descriptors test commit e97d8f90d5527349324ea84fd578c1d879d7a5a4 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 16:48:52 2020 +0000 Refactor buffer_descriptors test commit ed783a8ccccc8673c0f55eb1780c08668880a745 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 16:43:52 2020 +0000 clang.yml hack for testing commit 3cbe1a80030263aac53616391fa434d0501f4f26 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 19:31:03 2020 +0000 Squashed commit of the following: commit dceb56dd1a19be6fe9b991bb50e08902eefe36a8 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 19:27:18 2020 +0000 Fixed non-initialisation of in_use flag. commit c7ee1d6574ca5d95869152c5f8e4e6d02a7fa6bc Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 19:20:24 2020 +0000 Fixed non-initialisation of in_use flag. commit 36cbf21cd1b67a28255582cfb4a188a601631ab2 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:52:53 2020 +0000 Refactor buffer_descriptors test commit 49c60add63153bf53f400a891d8c4fb880cacda8 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:44:42 2020 +0000 Refactor buffer_descriptors test commit 7bda7678311bf2eb497483f3ef27c3af9211680b Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:29:02 2020 +0000 Refactor buffer_descriptors test commit 7a68c932a7df05f66690fa63e67365cf4b0619e8 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:14:30 2020 +0000 Refactor buffer_descriptors test commit a9b25ac67d175f58751a2eb819f0e5822e8f0cf9 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 18:08:21 2020 +0000 Refactor buffer_descriptors test commit 0c721c0466733751708fcbd995ce0bc1d7c0a932 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:58:22 2020 +0000 Refactor buffer_descriptors test commit 4b2dd2fce22cd0a4846b95695fbfd812e0823540 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:47:43 2020 +0000 Refactor buffer_descriptors test commit 80d5776c409b416377269d543bd539bdad83dc86 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:32:27 2020 +0000 Refactor buffer_descriptors test commit 3564ac5b7ef89c41b240d9f54fce36042408daa0 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:17:50 2020 +0000 Refactor buffer_descriptors test commit 297ef42c60e4228bfbcb2adcddeb6b8a617c4113 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 17:08:45 2020 +0000 Refactor buffer_descriptors test commit 658d592c96eb7eaf1afb5d09fef38e293ea6f79b Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 16:58:52 2020 +0000 Refactor buffer_descriptors test commit e97d8f90d5527349324ea84fd578c1d879d7a5a4 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 16:48:52 2020 +0000 Refactor buffer_descriptors test commit ed783a8ccccc8673c0f55eb1780c08668880a745 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 16:43:52 2020 +0000 clang.yml hack for testing commit e939e6b15557544bd0bb88d9862b5d5711170859 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 16:47:40 2020 +0000 Refactor buffer_descriptors test commit 4c4149abf6221f245aa4d73eb85e50319e7bd32c Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Nov 24 16:45:53 2020 +0000 clang hack for testing * Added AVR compile time switch * Updated version numbers * Fixed AVR to __AVR__ * Fixed version number retrieval from Github * constexpr, template aliases and inline variables * Updated version numbers * Added ETL_ASSERT for out-of-order state list. * issue-314-constexpr * issue-314-constexpr * Make modifying constexpr C++14 only * Make modifying constexpr C++14 only * Removed double subtraction of float size from 'bits_remaining' for floating point reads * Added parameterised constructor for etl::format_spec * Updated version numbers * Include new on megaAVR Boards (Arduino Nano Every) (#313) * Change new to new.h * Only include <new> header if ETL supports STL * Adding a flag to define placement new if necessary Co-authored-by: Heinz-Peter Liechtenecker <h.liechtenecker@fh-kaernten.at> * Minor changes * Added clang mutex header redirect to GCC implementation * Updated for automatic detection of <new> or <new.h> * Updated generators * Updated generators * Merge branch 'hotfix/issue-303-etl-not-compatible-with-arduino-ide' into development # Conflicts: # support/Release notes.txt # test/vs2019/etl.vcxproj.filters * Make span std compliant (#317) * add missing overloads for span::first + span::last The C++20 standard defines additional overloads for first and last: template< std::size_t Count > constexpr std::span<element_type, Count> first() const; constexpr std::span<element_type, std::dynamic_extent> first( size_type Count ) const; template< std::size_t Count > constexpr std::span<element_type, Count> last() const; constexpr std::span<element_type, std::dynamic_extent> last( size_type Count ) const; etl implements only the first (= template) variants so far. To be able to compile valid C++20 code the missing overload should be added. * remove explicit specifier for span conversion operator The C++20 standard allows to assign a span of non-const elements to a span of const elements. Example: std::span<const int> cintspan; std::span<int> intspan; cintspan = intspan; This is enabled in the STL by using an explicit specifier with a constant expression for one of the conversion constructors: template< class R > explicit(extent != std::dynamic_extent) constexpr span( R&& r ); The explicit specifier together with a constant expression is a C++20 feature and therefore can't be used within etl. To be able to compile valid C++20 code which uses the conversion on assignment, the explicit specifier has to be removed. * remove explicit specifier for span conversion operator The C++20 standard allows to assign an array of elements directly (without explicitly using a conversion constructor). Example: const int data = { 1, 2, 3 }; std::span<const int> cintspan; cintspan = data; To be able to compile valid C++20 code which uses the conversion on assignment, the explicit specifier of the array-conversion constructor has to be removed. * Updated version numbers * Change std::move to etl::move in etl::forward_list * Create Arduino ZIP * Fcs make getter const (#319) * make FCS get and conversion-operator methods const etl::frame_check_sequence has to access methods which can be made const: value_type value() const operator value_type() const * make jenkins_policy::initial and final const According to the documentation, initial, add and const have to be tagged as const. final has to be const now due to the change in the previous commit which makes the fcs getter methods const. * let default assignment operator return a reference to itself (#320) The default assignment operator in C++ shall return a reference to *this. * Arduino compatibility * Arduino compatibility * Updated version numbers * Merge branch 'hotfix/fcs_make_getter_const' into development * Arduino compatibility * VS2019 Delegate function interrupt service example * Removed unused functions * Added is_random_access_iterator and deprecated is_random_iterator * Interim commit * Added etl::for_each * Added etl::multi_loop * etl::multi_loop implementation * Added etl::multi_loop * Added typedefs * Latest implementation * Refactor multi_loop to multi_range * Moved code lines * Interim commit * Interim commit Refactor of reference counted types. * Merged shared_message handlers into message_router * reference_counted_object and reference_counted_message specialisations * reference_counted_object and reference_counted_message specialisations * reference_counted_object and reference_counted_message specialisations * Unknown board is not an error * Refactored reference_counted_message now contains owner reference * Added fixed_sized_memory_block_pool and restored imemory_block_pool interface * message router changes * Fixed LGT8F macro name clash * Updated generators * Updated deque from development * get_memory_block_size() const * Updates to pools and memory allocators * LLVM changes * Ongoing addition of unit tests * Added final unit tests * Added static asserts * Renamed internal structure * Minor updates. * Added virtual function 'void on_task_added()' that is called when a task is added to a shceduler. * Added virtual function 'void on_task_added()' that is called when a task is added to a scheduler. * Update version number * Removed pool_message and non_pool_message * Added shared_message example * Added shared_message receive override to messge_bus * Added shared_message example * Added memory allocator successor * Added reference_counted_message specialisation for void counter * Added lock/unlock interface * Added lock/unlock example * Added constructors with deleters for unique_ptr. * Fixed typos in rvalue constructor * Added ilockable interface class * Fixed VS2019 warning for etl::deque iterators. * Added nullptr check to unique_ptr destructor * Added nullptr check to unique_ptr destructor. * Added nullptr check to unique_ptr destructor. * Added ilockable interface & queue_lockable * Added nullptr check to unique_ptr destructor. * Typo in unique_ptr * Refactored queues * Added virtual destructor to observer. Changed C++11 destructors to '= default'. * Updated version and release notes. * Added more CMakeLists.txt files for examples * Added enable_if for container iterator costructors, to exclude integrals from consideration * Squashed commit of the following: commit 23c5f1d3f9b13ff9e46ce3de96aefeb655d5ed97 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:32:35 2021 +0000 Fixed rollover error for etl::queue_spsc_atomic Added 'required_alignment' parameter to 'allocate' for etl::imemeory_block_allocator. Updated QueuedMessageRouter example * Squashed commit of the following: commit e5f4eb6fb38c337c82fcc250f17a8f21eb788975 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:34:49 2021 +0000 Squashed commit of the following: commit 23c5f1d3f9b13ff9e46ce3de96aefeb655d5ed97 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:32:35 2021 +0000 Fixed rollover error for etl::queue_spsc_atomic Added 'required_alignment' parameter to 'allocate' for etl::imemeory_block_allocator. Updated QueuedMessageRouter example * Squashed commit of the following: commit 6107c4538be149137209d85e5f41031291bc7150 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Feb 2 12:15:31 2021 +0000 Added move constructor and move assignment to etl::shared_message commit c9a5716012db9b614ea67660ebf64dcb790ce571 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:36:29 2021 +0000 Squashed commit of the following: commit e5f4eb6fb38c337c82fcc250f17a8f21eb788975 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:34:49 2021 +0000 Squashed commit of the following: commit 23c5f1d3f9b13ff9e46ce3de96aefeb655d5ed97 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:32:35 2021 +0000 Fixed rollover error for etl::queue_spsc_atomic Added 'required_alignment' parameter to 'allocate' for etl::imemeory_block_allocator. Updated QueuedMessageRouter example * Squashed commit of the following: commit 007b56d03513887636b84fc246e57d6c4f8b777e Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Feb 2 18:09:51 2021 +0000 Squashed commit of the following: commit 6107c4538be149137209d85e5f41031291bc7150 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Feb 2 12:15:31 2021 +0000 Added move constructor and move assignment to etl::shared_message commit c9a5716012db9b614ea67660ebf64dcb790ce571 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:36:29 2021 +0000 Squashed commit of the following: commit e5f4eb6fb38c337c82fcc250f17a8f21eb788975 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:34:49 2021 +0000 Squashed commit of the following: commit 23c5f1d3f9b13ff9e46ce3de96aefeb655d5ed97 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:32:35 2021 +0000 Fixed rollover error for etl::queue_spsc_atomic Added 'required_alignment' parameter to 'allocate' for etl::imemeory_block_allocator. Updated QueuedMessageRouter example commit e5f4eb6fb38c337c82fcc250f17a8f21eb788975 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:34:49 2021 +0000 Squashed commit of the following: commit 23c5f1d3f9b13ff9e46ce3de96aefeb655d5ed97 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:32:35 2021 +0000 Fixed rollover error for etl::queue_spsc_atomic Added 'required_alignment' parameter to 'allocate' for etl::imemeory_block_allocator. Updated QueuedMessageRouter example * Squashed commit of the following: commit 04ba91bcccc8e12867962bc3746665f430672a23 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sat Feb 6 10:43:34 2021 +0000 Updated shared message unit test commit fababc5cf748073464b4294a50c201cb0aa4fa13 Author: John Wellbelove <github@wellbelove.co.uk> Date: Fri Feb 5 09:41:52 2021 +0000 Updated FSM generator commit ff287bcf0a833ca70933354b42b8b036b422ff81 Author: John Wellbelove <github@wellbelove.co.uk> Date: Fri Feb 5 09:35:56 2021 +0000 Updated message router generator commit 52724e1e62b55dad81e2f80dd656026d828b3214 Author: John Wellbelove <github@wellbelove.co.uk> Date: Thu Feb 4 13:06:50 2021 +0000 Updated unit tests commit 0d89105262aa050577ccc17ddc6eece9f4fc5d18 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Feb 2 20:09:35 2021 +0000 Interim commit commit ce8385ff24826103c7a55267ccf3f8a31f517e0b Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Feb 2 18:13:29 2021 +0000 Squashed commit of the following: commit 007b56d03513887636b84fc246e57d6c4f8b777e Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Feb 2 18:09:51 2021 +0000 Squashed commit of the following: commit 6107c4538be149137209d85e5f41031291bc7150 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Feb 2 12:15:31 2021 +0000 Added move constructor and move assignment to etl::shared_message commit c9a5716012db9b614ea67660ebf64dcb790ce571 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:36:29 2021 +0000 Squashed commit of the following: commit e5f4eb6fb38c337c82fcc250f17a8f21eb788975 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:34:49 2021 +0000 Squashed commit of the following: commit 23c5f1d3f9b13ff9e46ce3de96aefeb655d5ed97 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:32:35 2021 +0000 Fixed rollover error for etl::queue_spsc_atomic Added 'required_alignment' parameter to 'allocate' for etl::imemeory_block_allocator. Updated QueuedMessageRouter example commit e5f4eb6fb38c337c82fcc250f17a8f21eb788975 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:34:49 2021 +0000 Squashed commit of the following: commit 23c5f1d3f9b13ff9e46ce3de96aefeb655d5ed97 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:32:35 2021 +0000 Fixed rollover error for etl::queue_spsc_atomic Added 'required_alignment' parameter to 'allocate' for etl::imemeory_block_allocator. Updated QueuedMessageRouter example commit c9a5716012db9b614ea67660ebf64dcb790ce571 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:36:29 2021 +0000 Squashed commit of the following: commit e5f4eb6fb38c337c82fcc250f17a8f21eb788975 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:34:49 2021 +0000 Squashed commit of the following: commit 23c5f1d3f9b13ff9e46ce3de96aefeb655d5ed97 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:32:35 2021 +0000 Fixed rollover error for etl::queue_spsc_atomic Added 'required_alignment' parameter to 'allocate' for etl::imemeory_block_allocator. Updated QueuedMessageRouter example * Squashed commit of the following: commit 97a6e6a03557359442123d439cef9bdf6dea2d1b Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Feb 7 11:02:49 2021 +0000 Squashed commit of the following: commit 04ba91bcccc8e12867962bc3746665f430672a23 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sat Feb 6 10:43:34 2021 +0000 Updated shared message unit test commit fababc5cf748073464b4294a50c201cb0aa4fa13 Author: John Wellbelove <github@wellbelove.co.uk> Date: Fri Feb 5 09:41:52 2021 +0000 Updated FSM generator commit ff287bcf0a833ca70933354b42b8b036b422ff81 Author: John Wellbelove <github@wellbelove.co.uk> Date: Fri Feb 5 09:35:56 2021 +0000 Updated message router generator commit 52724e1e62b55dad81e2f80dd656026d828b3214 Author: John Wellbelove <github@wellbelove.co.uk> Date: Thu Feb 4 13:06:50 2021 +0000 Updated unit tests commit 0d89105262aa050577ccc17ddc6eece9f4fc5d18 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Feb 2 20:09:35 2021 +0000 Interim commit commit ce8385ff24826103c7a55267ccf3f8a31f517e0b Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Feb 2 18:13:29 2021 +0000 Squashed commit of the following: commit 007b56d03513887636b84fc246e57d6c4f8b777e Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Feb 2 18:09:51 2021 +0000 Squashed commit of the following: commit 6107c4538be149137209d85e5f41031291bc7150 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Feb 2 12:15:31 2021 +0000 Added move constructor and move assignment to etl::shared_message commit c9a5716012db9b614ea67660ebf64dcb790ce571 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:36:29 2021 +0000 Squashed commit of the following: commit e5f4eb6fb38c337c82fcc250f17a8f21eb788975 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:34:49 2021 +0000 Squashed commit of the following: commit 23c5f1d3f9b13ff9e46ce3de96aefeb655d5ed97 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:32:35 2021 +0000 Fixed rollover error for etl::queue_spsc_atomic Added 'required_alignment' parameter to 'allocate' for etl::imemeory_block_allocator. Updated QueuedMessageRouter example commit e5f4eb6fb38c337c82fcc250f17a8f21eb788975 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:34:49 2021 +0000 Squashed commit of the following: commit 23c5f1d3f9b13ff9e46ce3de96aefeb655d5ed97 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:32:35 2021 +0000 Fixed rollover error for etl::queue_spsc_atomic Added 'required_alignment' parameter to 'allocate' for etl::imemeory_block_allocator. Updated QueuedMessageRouter example commit c9a5716012db9b614ea67660ebf64dcb790ce571 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:36:29 2021 +0000 Squashed commit of the following: commit e5f4eb6fb38c337c82fcc250f17a8f21eb788975 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:34:49 2021 +0000 Squashed commit of the following: commit 23c5f1d3f9b13ff9e46ce3de96aefeb655d5ed97 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:32:35 2021 +0000 Fixed rollover error for etl::queue_spsc_atomic Added 'required_alignment' parameter to 'allocate' for etl::imemeory_block_allocator. Updated QueuedMessageRouter example commit 007b56d03513887636b84fc246e57d6c4f8b777e Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Feb 2 18:09:51 2021 +0000 Squashed commit of the following: commit 6107c4538be149137209d85e5f41031291bc7150 Author: John Wellbelove <github@wellbelove.co.uk> Date: Tue Feb 2 12:15:31 2021 +0000 Added move constructor and move assignment to etl::shared_message commit c9a5716012db9b614ea67660ebf64dcb790ce571 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:36:29 2021 +0000 Squashed commit of the following: commit e5f4eb6fb38c337c82fcc250f17a8f21eb788975 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:34:49 2021 +0000 Squashed commit of the following: commit 23c5f1d3f9b13ff9e46ce3de96aefeb655d5ed97 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:32:35 2021 +0000 Fixed rollover error for etl::queue_spsc_atomic Added 'required_alignment' parameter to 'allocate' for etl::imemeory_block_allocator. Updated QueuedMessageRouter example commit e5f4eb6fb38c337c82fcc250f17a8f21eb788975 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:34:49 2021 +0000 Squashed commit of the following: commit 23c5f1d3f9b13ff9e46ce3de96aefeb655d5ed97 Author: John Wellbelove <github@wellbelove.co.uk> Date: Sun Jan 31 12:32:35 2021 +0000 Fixed rollover error for etl::queue_spsc_atomic Added 'required_alignment' parameter to 'allocate' for etl::imemeory_block_allocator. Updated QueuedMessageRouter example * Changed template aliases so they are available for C++11 rather than C++14. * Changed template aliases so they are available for C++11 rather than C++14. * Allow default constructed messages for shared messages * Updated version numbers * Modified reference_counted_message_pool::allocate() return type * Modified reference_counted_message_pool::allocate() return type * Added non-const get_message() member funtions in shared message framework. * Added update_size() to string API to fix string lengths after insertion of characters by C code. * Interface for C string handling. * Fixed indexing error in find_next for etl::bitset. Added some enum tests for type_traits * Updated version * fix bug in ibitset find_next method (#338) Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com> * Merge branch 'hotfix/bitset-iteration-error' into development * Merge branch 'hotfix/Chiraffollo-fix-find_next' into development * Updated version * Fixed indexing error in find_next for etl::bitset. Added some enum tests for type_traits * Updated version * Merge branch 'hotfix/bitset-iteration-error' into development * fix bug in ibitset find_next method (#338) Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com> * Merge branch 'hotfix/Chiraffollo-fix-find_next' into development * Updated version * Added data_end() and renamed trim() to trim_to_terminator() * Added ETL_CONSTANT to numeric_limits member functions. * Added uninitialized_resize() * Updated version numbers * Added uninitialized_resize() tests to external buffer containers * Updated example for shared_message * Updates to etl::shared_message example application. * Added specialisation of etl::state_chart that allows a parameter to be passed to the event handler. * Export headers as system includes (#340) Gcc doesn't apply warning to system includes paths. This change allows a project to use high warning levels without getting swamped by ETL issues. * Fix extent type conversion warning (#339) * Issue #339 - Fix extent type conversion warning * Merge branch 'feature/state-chart-to-have-optional-data-parameter' into development * Minor updates to state chart * Minor updates to state chart * Fix extent error in clang and gcc * Fix extent error in clang and gcc * Initial code * Fix C++14 only type aliases for STL * Fix C++14 only type aliases for STL * Fix C++14 only type aliases for STL * Fix C++14 only type aliases for STL * Abstracted unit test framework header * Initial commit * Added message_router_registry * Added message_router_registry * Added iterators * Added iterators * Changed to using etl::flat_multimap * Updates to message_router_registry * Remove executable permission on C++ source files (#341) * Updated * & -> operators. * Partial fix to compiling with C++98/03 (#342) * Updated version numbers * Fix default function templates for C++03 * Updated file id macros * Added ETL_CONSTEXPR to etl::array * Remove unnecessary template keyword to destroy() call. * Remove unnecessary template keyword to destroy() call. * Fix default function templates for C++03 * Correct use of ETL_NULLPTR instead for keyword nulllptr (#346) Gives problem in C++98/03 mode. * Remove etl/ prefix in state_chart.h (#347) It's the only file to include internal header files with "etl/... .h". * Add free-standing sanity tests for C++03/11/14/17 Co-authored-by: John Wellbelove <github@wellbelove.co.uk> Co-authored-by: Heinz-Peter Liechtenecker <heinz.liechtenecker@gmail.com> Co-authored-by: Heinz-Peter Liechtenecker <h.liechtenecker@fh-kaernten.at> Co-authored-by: Steffen Zimmermann <mampfes@users.noreply.github.com> Co-authored-by: Chiraffollo <ollymarx@web.de> Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com> Co-authored-by: Adam Boseley <aboseley@users.noreply.github.com>
This commit is contained in:
parent
4ffb63344d
commit
4aa74e35f2
@ -1,26 +1,32 @@
|
||||
version: 2
|
||||
|
||||
jobs:
|
||||
build:
|
||||
docker:
|
||||
- image: "debian:stretch"
|
||||
- image: "rikorose/gcc-cmake:latest"
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- development
|
||||
steps:
|
||||
- checkout
|
||||
- checkout:
|
||||
- run:
|
||||
name: Installing SUDO
|
||||
command: 'apt-get update && apt-get install -y sudo && rm -rf /var/lib/apt/lists/*'
|
||||
- run:
|
||||
name: Installing GCC
|
||||
command: 'apt-get update && apt-get install -y gcc g++'
|
||||
- run:
|
||||
name: Install CMAKE
|
||||
command: 'apt-get update && sudo apt-get install -y cmake'
|
||||
name: Listing0
|
||||
command: 'ls -lrt'
|
||||
- run:
|
||||
name: Creating Build Files
|
||||
command: 'cmake -H. -Bbuild'
|
||||
command: 'cmake -Bbuild test/'
|
||||
- run:
|
||||
name: Creating Binary Files
|
||||
command: 'cmake --build build'
|
||||
- run:
|
||||
name: Listing1
|
||||
command: 'ls -lrt /root/project/build'
|
||||
- run:
|
||||
name: Listing2
|
||||
command: 'ls -lrt /root/project/build/CMakeFiles'
|
||||
- run:
|
||||
name: Listing3
|
||||
command: 'cat /root/project/build/CMakeFiles/CMakeOutput.log'
|
||||
- run:
|
||||
name: ETL Unit Testing
|
||||
command: './bin/etl'
|
||||
command: './build/etl_tests'
|
||||
|
||||
5
.gitattributes
vendored
5
.gitattributes
vendored
@ -3,6 +3,11 @@
|
||||
###############################################################################
|
||||
* text=auto
|
||||
|
||||
###############################################################################
|
||||
# Declare files that will always have LF line endings on checkout.
|
||||
###############################################################################
|
||||
*.sh text eol=lf
|
||||
|
||||
###############################################################################
|
||||
# Set default behavior for command prompt diff.
|
||||
#
|
||||
|
||||
3
.github/FUNDING.yml
vendored
Normal file
3
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
patreon: etlcpp
|
||||
89
.github/workflows/clang.yml
vendored
Normal file
89
.github/workflows/clang.yml
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
name: clang
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build-clang-9-linux:
|
||||
name: Clang-9 Linux
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-20.04]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
export CC=clang-9
|
||||
export CXX=clang++-9
|
||||
cmake -D BUILD_TESTS=ON ./
|
||||
clang --version
|
||||
make
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
|
||||
build-clang-9-linux-no-stl:
|
||||
name: Clang-9 Linux - No STL
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-20.04]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cmake -DBUILD_TESTS=ON -DNO_STL=ON ./
|
||||
gcc --version
|
||||
make
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
|
||||
build-clang-10-osx:
|
||||
name: Clang-10 OSX
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-10.15]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
export CC=clang
|
||||
export CXX=clang++
|
||||
cmake -D BUILD_TESTS=ON ./
|
||||
clang --version
|
||||
make
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
|
||||
build-clang-10-osx-no-stl:
|
||||
name: Clang-10 OSX - No STL
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-10.15]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
export CC=clang
|
||||
export CXX=clang++
|
||||
cmake -D BUILD_TESTS=ON -DNO_STL=ON ./
|
||||
clang --version
|
||||
make
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
45
.github/workflows/gcc.yml
vendored
Normal file
45
.github/workflows/gcc.yml
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
name: gcc
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build-gcc-linux:
|
||||
name: GCC Linux
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-18.04, ubuntu-20.04]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cmake -DBUILD_TESTS=ON ./
|
||||
gcc --version
|
||||
make
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
|
||||
build-gcc-linux-no-stl:
|
||||
name: GCC Linux - No STL
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-18.04, ubuntu-20.04]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cmake -DBUILD_TESTS=ON -DNO_STL=ON ./
|
||||
gcc --version
|
||||
make
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
51
.github/workflows/vs2019.yml
vendored
Normal file
51
.github/workflows/vs2019.yml
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
name: vs2019
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build-windows-vs2019:
|
||||
name: Windows VS2019 Debug
|
||||
runs-on: [windows-latest]
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Add msbuild to PATH
|
||||
uses: microsoft/setup-msbuild@v1.0.2
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cmake -G "Visual Studio 16 2019" -DBUILD_TESTS=ON ./
|
||||
MSBuild.exe -version
|
||||
MSBuild.exe etl.sln
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/debug/etl_tests.exe
|
||||
|
||||
build-windows-vs2019-no-stl:
|
||||
name: Windows VS2019 Debug - No STL
|
||||
runs-on: [windows-latest]
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Add msbuild to PATH
|
||||
uses: microsoft/setup-msbuild@v1.0.2
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cmake -G "Visual Studio 16 2019" -DBUILD_TESTS=ON -DNO_STL=ON ./
|
||||
MSBuild.exe -version
|
||||
MSBuild.exe etl.sln
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/debug/etl_tests.exe
|
||||
35
.gitignore
vendored
35
.gitignore
vendored
@ -15,6 +15,7 @@ examples/ArmTimerCallbacks/Listings
|
||||
examples/ArmTimerCallbacks/Objects
|
||||
examples/ArmTimerCallbacks/DebugConfig
|
||||
build-test-Desktop_x86_windows_msvc2017_pe_32bit-Debug/unittest++/src
|
||||
buildresults/
|
||||
|
||||
#################
|
||||
## Eclipse
|
||||
@ -251,3 +252,37 @@ cmake-build-*/
|
||||
|
||||
unittest-cpp
|
||||
*.opendb
|
||||
build-test-Desktop_x86_windows_msvc2017_pe_32bit-Debug
|
||||
test/Logs
|
||||
build-test-Desktop_x86_windows_msvc2019_pe_32bit-Debug
|
||||
test/vs2019/.vs
|
||||
Corel Auto-Preserve
|
||||
.vscode
|
||||
build-test-Clang_10-Debug
|
||||
build-test-GCC-Debug
|
||||
test/kdevelopbuild/unittest++
|
||||
test/random_clcg.csv
|
||||
test/random_hash.csv
|
||||
test/random_lcg.csv
|
||||
test/random_lcg.csv
|
||||
test/random_lcg.csv
|
||||
test/random_lsfr.csv
|
||||
test/random_lsfr.csv
|
||||
test/random_mwc.csv
|
||||
test/random_pcg.csv
|
||||
test/random_pcg.csv
|
||||
test/random_xorshift.csv
|
||||
test/cmake_install.cmake
|
||||
test/Makefile
|
||||
test/vs2019/enc_temp_folder
|
||||
test/vs2019/.leu
|
||||
test/etl_test_log.txt
|
||||
test/vs2019/Debug No Unit Tests
|
||||
test/vs2019/multi_loop.csv
|
||||
temp/create_arduino_library.py
|
||||
examples/FunctionInterruptSimulation-Delegates/vs2019/.vs
|
||||
|
||||
*.db-shm
|
||||
test/vs2019/.vs/etl/v16/Browse.VC.db-wal
|
||||
examples/SharedMessage/.vs
|
||||
examples/QueuedMessageRouter/vs2019/.vs
|
||||
|
||||
1
.vs/.gitignore
vendored
1
.vs/.gitignore
vendored
@ -1 +0,0 @@
|
||||
/slnx.sqlite
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"CurrentProjectSetting": "x86-Debug"
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
{
|
||||
"ExpandedNodes": [
|
||||
"",
|
||||
"\\include",
|
||||
"\\include\\etl",
|
||||
"\\test"
|
||||
],
|
||||
"SelectedNode": "\\test\\test_to_string.cpp",
|
||||
"PreviewInSolutionExplorer": false
|
||||
}
|
||||
@ -4,57 +4,14 @@
|
||||
cmake_minimum_required(VERSION 3.5.0)
|
||||
project(etl)
|
||||
|
||||
#######################################################################
|
||||
# Define an option to allow consumers of the library to
|
||||
# specify the profile they would like to compile to. If
|
||||
# not explicitly set CMake will attempt to choose an appropriate
|
||||
# profile based on the compiler
|
||||
#######################################################################
|
||||
set(ETL_PROFILE "DEFAULT" CACHE STRING "Defines what profile header to include. See https://www.etlcpp.com/setup.html"
|
||||
)
|
||||
|
||||
option(BUILD_TESTS "Build unit tests" OFF)
|
||||
option(NO_STL "No STL" OFF)
|
||||
|
||||
add_library(etl INTERFACE)
|
||||
|
||||
target_include_directories(etl
|
||||
INTERFACE
|
||||
include
|
||||
include/etl/profiles
|
||||
)
|
||||
|
||||
if (${ETL_PROFILE} STREQUAL DEFAULT)
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
set(ETL_PROFILE "PROFILE_GCC_GENERIC")
|
||||
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(ETL_PROFILE "PROFILE_CLANG_GENERIC")
|
||||
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
set(ETL_PROFILE "PROFILE_MSVC")
|
||||
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "ARMCC")
|
||||
if (CXX_STANDARD EQUAL 11)
|
||||
set(ETL_PROFILE "PROFILE_ARMV6")
|
||||
else ()
|
||||
set(ETL_PROFILE "PROFILE_ARMV5")
|
||||
endif()
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "TI")
|
||||
set(ETL_PROFILE "PROFILE_TICC")
|
||||
|
||||
else()
|
||||
message(FATAL_ERROR "Can't generate default profile for compiler: ${CMAKE_CXX_COMPILER_ID}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
message(STATUS "Compiling with ETL profile set to: ${ETL_PROFILE}")
|
||||
|
||||
target_compile_definitions(etl
|
||||
INTERFACE
|
||||
${ETL_PROFILE}
|
||||
)
|
||||
|
||||
target_include_directories(etl SYSTEM INTERFACE include)
|
||||
|
||||
target_compile_definitions(etl INTERFACE)
|
||||
|
||||
if (BUILD_TESTS)
|
||||
enable_testing()
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "x86-Debug",
|
||||
"generator": "Ninja",
|
||||
"configurationType": "Debug",
|
||||
"inheritEnvironments": [
|
||||
"msvc_x86"
|
||||
],
|
||||
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
|
||||
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
|
||||
"cmakeCommandArgs": "",
|
||||
"buildCommandArgs": "-v",
|
||||
"ctestCommandArgs": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,13 +1,12 @@
|
||||
Embedded Template Library (ETL)
|
||||
-------------------------
|
||||
|
||||
AppVeyor
|
||||
[](https://ci.appveyor.com/project/jwellbelove/etl/branch/master)
|
||||
[](https://www.codacy.com/manual/jwellbelove/etl?utm_source=github.com&utm_medium=referral&utm_content=ETLCPP/etl&utm_campaign=Badge_Grade)
|
||||

|
||||
[](https://opensource.org/licenses/MIT)
|
||||
[]()
|
||||
|
||||

|
||||

|
||||

|
||||
[](https://www.codacy.com/manual/jwellbelove/etl?utm_source=github.com&utm_medium=referral&utm_content=ETLCPP/etl&utm_campaign=Badge_Grade)
|
||||
|
||||
**Motivation**
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ version: 1.0.{build}
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
image: Visual Studio 2017
|
||||
image: Visual Studio 2019
|
||||
configuration:
|
||||
- Debug
|
||||
- DebugNoSTL
|
||||
@ -12,7 +12,7 @@ install:
|
||||
before_build:
|
||||
- cmd: git clone https://github.com/unittest-cpp/unittest-cpp.git c:\projects\unittest-cpp
|
||||
build:
|
||||
project: test/vs2017/etl.vcxproj
|
||||
project: test/vs2019/etl.vcxproj
|
||||
verbosity: minimal
|
||||
notifications:
|
||||
- provider: Webhook
|
||||
@ -20,4 +20,5 @@ notifications:
|
||||
method: POST
|
||||
on_build_success: true
|
||||
on_build_failure: true
|
||||
on_build_status_changed: true
|
||||
on_build_status_changed: true
|
||||
|
||||
80
arduino/Embedded_Template_Library.h
Normal file
80
arduino/Embedded_Template_Library.h
Normal file
@ -0,0 +1,80 @@
|
||||
|
||||
#ifndef ETL_EMBEDDED_TEMPLATE_LIBRARY_INCLUDED
|
||||
#define ETL_EMBEDDED_TEMPLATE_LIBRARY_INCLUDED
|
||||
|
||||
#if defined(TEENSYDUINO)
|
||||
|
||||
#if defined(__AVR_ATmega32U4__)
|
||||
#define ARDUINO_BOARD "Teensy 2.0"
|
||||
#elif defined(__AVR_AT90USB1286__)
|
||||
#define ARDUINO_BOARD "Teensy++ 2.0"
|
||||
#elif defined(__MK20DX128__)
|
||||
#define ARDUINO_BOARD "Teensy 3.0"
|
||||
#elif defined(__MK20DX256__)
|
||||
#define ARDUINO_BOARD "Teensy 3.2" // and Teensy 3.1
|
||||
#elif defined(__MKL26Z64__)
|
||||
#define ARDUINO_BOARD "Teensy LC"
|
||||
#elif defined(__MK64FX512__)
|
||||
#define ARDUINO_BOARD "Teensy 3.5"
|
||||
#elif defined(__MK66FX1M0__)
|
||||
#define ARDUINO_BOARD "Teensy 3.6"
|
||||
#else
|
||||
#define ARDUINO_BOARD "Unknown"
|
||||
#endif
|
||||
|
||||
#else // --------------- Arduino ------------------
|
||||
|
||||
#if defined(ARDUINO_AVR_ADK)
|
||||
#define ARDUINO_BOARD "Mega Adk"
|
||||
#elif defined(ARDUINO_AVR_BT)
|
||||
#define ARDUINO_BOARD "Bt"
|
||||
#elif defined(ARDUINO_AVR_DUEMILANOVE)
|
||||
#define ARDUINO_BOARD "Duemilanove"
|
||||
#elif defined(ARDUINO_AVR_ESPLORA)
|
||||
#define ARDUINO_BOARD "Esplora"
|
||||
#elif defined(ARDUINO_AVR_ETHERNET)
|
||||
#define ARDUINO_BOARD "Ethernet"
|
||||
#elif defined(ARDUINO_AVR_FIO)
|
||||
#define ARDUINO_BOARD "Fio"
|
||||
#elif defined(ARDUINO_AVR_GEMMA)
|
||||
#define ARDUINO_BOARD "Gemma"
|
||||
#elif defined(ARDUINO_AVR_LEONARDO)
|
||||
#define ARDUINO_BOARD "Leonardo"
|
||||
#elif defined(ARDUINO_AVR_LILYPAD)
|
||||
#define ARDUINO_BOARD "Lilypad"
|
||||
#elif defined(ARDUINO_AVR_LILYPAD_USB)
|
||||
#define ARDUINO_BOARD "Lilypad Usb"
|
||||
#elif defined(ARDUINO_AVR_MEGA)
|
||||
#define ARDUINO_BOARD "Mega"
|
||||
#elif defined(ARDUINO_AVR_MEGA2560)
|
||||
#define ARDUINO_BOARD "Mega 2560"
|
||||
#elif defined(ARDUINO_AVR_MICRO)
|
||||
#define ARDUINO_BOARD "Micro"
|
||||
#elif defined(ARDUINO_AVR_MINI)
|
||||
#define ARDUINO_BOARD "Mini"
|
||||
#elif defined(ARDUINO_AVR_NANO)
|
||||
#define ARDUINO_BOARD "Nano"
|
||||
#elif defined(ARDUINO_AVR_NG)
|
||||
#define ARDUINO_BOARD "NG"
|
||||
#elif defined(ARDUINO_AVR_PRO)
|
||||
#define ARDUINO_BOARD "Pro"
|
||||
#elif defined(ARDUINO_AVR_ROBOT_CONTROL)
|
||||
#define ARDUINO_BOARD "Robot Ctrl"
|
||||
#elif defined(ARDUINO_AVR_ROBOT_MOTOR)
|
||||
#define ARDUINO_BOARD "Robot Motor"
|
||||
#elif defined(ARDUINO_AVR_UNO)
|
||||
#define ARDUINO_BOARD "Uno"
|
||||
#elif defined(ARDUINO_AVR_YUN)
|
||||
#define ARDUINO_BOARD "Yun"
|
||||
#elif defined(ARDUINO_SAM_DUE)
|
||||
#define ARDUINO_BOARD "Due"
|
||||
#elif defined(ARDUINO_SAMD_ZERO)
|
||||
#define ARDUINO_BOARD "Zero"
|
||||
#elif defined(ARDUINO_ARC32_TOOLS)
|
||||
#define ARDUINO_BOARD "101"
|
||||
#else
|
||||
#define ARDUINO_BOARD "Unknown"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
72
arduino/create_arduino_library.py
Normal file
72
arduino/create_arduino_library.py
Normal file
@ -0,0 +1,72 @@
|
||||
|
||||
import shutil
|
||||
import os
|
||||
|
||||
# Assumes this folder structure.
|
||||
# Folder Variable
|
||||
# ---------------------------------------
|
||||
# etl etl_dir
|
||||
# arduino arduino_dir
|
||||
# include include_dir
|
||||
# etl-arduino etl_arduino_dir
|
||||
# src etl_arduino_src_dir
|
||||
|
||||
print('')
|
||||
print('Copy ETL files to the etl-arduino repository')
|
||||
print('')
|
||||
|
||||
# Get the current path of the script
|
||||
arduino_dir = os.path.dirname(__file__)
|
||||
print('arduino_dir = ', arduino_dir)
|
||||
|
||||
# Get the root folder of the ETL
|
||||
etl_dir = os.path.dirname(arduino_dir)
|
||||
print('etl_dir = ', etl_dir)
|
||||
|
||||
# Get the ETL repository folder
|
||||
include_dir = os.path.join(etl_dir, 'include')
|
||||
print('include_dir = ', include_dir)
|
||||
|
||||
# Get the root folder of both repositories
|
||||
common_dir = os.path.dirname(etl_dir)
|
||||
print('common_dir = ', common_dir)
|
||||
|
||||
# Get the ETL Arduino repository folder
|
||||
etl_arduino_dir = os.path.join(common_dir, 'etl-arduino')
|
||||
print('etl_arduino_dir = ', etl_arduino_dir)
|
||||
|
||||
# Get the ETL Arduino src repository folder
|
||||
etl_arduino_src_dir = os.path.join(etl_arduino_dir, 'src')
|
||||
print('etl_arduino_src_dir = ', etl_arduino_src_dir)
|
||||
|
||||
print('')
|
||||
|
||||
# Copy the library properties
|
||||
filename = 'library.properties'
|
||||
source = os.path.join(etl_dir, filename)
|
||||
destination = os.path.join(etl_arduino_dir, filename)
|
||||
print('Copy the library properties')
|
||||
print(' From :', source)
|
||||
print(' To :', destination)
|
||||
shutil.copyfile(source, destination)
|
||||
|
||||
print('')
|
||||
|
||||
# Copy the Arduino ETL header
|
||||
filename = 'Embedded_Template_Library.h'
|
||||
source = os.path.join(arduino_dir, filename)
|
||||
destination = os.path.join(etl_arduino_src_dir, filename)
|
||||
print('Copy the Arduino ETL header')
|
||||
print(' From :', source)
|
||||
print(' To :', destination)
|
||||
shutil.copyfile(source, destination)
|
||||
|
||||
print('')
|
||||
|
||||
# Copy the ETL headers
|
||||
source = include_dir
|
||||
destination = etl_arduino_src_dir
|
||||
print('Copy the ETL headers')
|
||||
print(' From :', source)
|
||||
print(' To :', destination)
|
||||
shutil.copytree(source, destination, dirs_exist_ok = True)
|
||||
@ -20,10 +20,10 @@ class EmbeddedTemplateLibraryConan(ConanFile):
|
||||
name = "embedded-template-library"
|
||||
version = get_version_from_git_tag()
|
||||
license = "MIT"
|
||||
author = "John Wellbelove <smartgit@wellbelove.co.uk>"
|
||||
author = "John Wellbelove <john.wellbelove@etlcpp.com>"
|
||||
url = "https://github.com/ETLCPP/etl"
|
||||
description = "A C++ template library for embedded applications"
|
||||
topics = ("embedded", "template", "container")
|
||||
topics = ("C++", "embedded", "template", "container", "utility", "framework", "messaging")
|
||||
|
||||
# Source info
|
||||
scm = {
|
||||
|
||||
BIN
etl.pspimage
BIN
etl.pspimage
Binary file not shown.
@ -10,6 +10,6 @@
|
||||
#define ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK
|
||||
#define ETL_NO_STL
|
||||
|
||||
#include "etl/profiles/auto.h"
|
||||
//#include "etl/profiles/auto.h"
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,28 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25123.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Debounce", "Debounce.vcxproj", "{2D9F7027-A2E4-4558-869E-A09815D85E02}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{2D9F7027-A2E4-4558-869E-A09815D85E02}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{2D9F7027-A2E4-4558-869E-A09815D85E02}.Debug|x64.Build.0 = Debug|x64
|
||||
{2D9F7027-A2E4-4558-869E-A09815D85E02}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{2D9F7027-A2E4-4558-869E-A09815D85E02}.Debug|x86.Build.0 = Debug|Win32
|
||||
{2D9F7027-A2E4-4558-869E-A09815D85E02}.Release|x64.ActiveCfg = Release|x64
|
||||
{2D9F7027-A2E4-4558-869E-A09815D85E02}.Release|x64.Build.0 = Release|x64
|
||||
{2D9F7027-A2E4-4558-869E-A09815D85E02}.Release|x86.ActiveCfg = Release|Win32
|
||||
{2D9F7027-A2E4-4558-869E-A09815D85E02}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Debounce.ino" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="__vm\.Debounce.vsarduino.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.5.0)
|
||||
project(FunctionInterruptSimulation)
|
||||
|
||||
add_definitions(-DETL_DEBUG)
|
||||
|
||||
include_directories(${UTPP_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/../../include)
|
||||
|
||||
set(SOURCE_FILES FunctionInterruptSimulation.cpp)
|
||||
|
||||
add_executable(FunctionInterruptSimulation ${SOURCE_FILES})
|
||||
target_include_directories(FunctionInterruptSimulation
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
set_property(TARGET FunctionInterruptSimulation PROPERTY CXX_STANDARD 17)
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26730.16
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FunctionInterruptSimulation-Delegates", "FunctionInterruptSimulation-Delegates.vcxproj", "{5157DB15-C255-4E47-9FB1-AF388437F90F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{5157DB15-C255-4E47-9FB1-AF388437F90F}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{5157DB15-C255-4E47-9FB1-AF388437F90F}.Debug|x64.Build.0 = Debug|x64
|
||||
{5157DB15-C255-4E47-9FB1-AF388437F90F}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{5157DB15-C255-4E47-9FB1-AF388437F90F}.Debug|x86.Build.0 = Debug|Win32
|
||||
{5157DB15-C255-4E47-9FB1-AF388437F90F}.Release|x64.ActiveCfg = Release|x64
|
||||
{5157DB15-C255-4E47-9FB1-AF388437F90F}.Release|x64.Build.0 = Release|x64
|
||||
{5157DB15-C255-4E47-9FB1-AF388437F90F}.Release|x86.ActiveCfg = Release|Win32
|
||||
{5157DB15-C255-4E47-9FB1-AF388437F90F}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {260225EB-60CB-44CC-A60C-16A23BBC10EB}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
@ -18,37 +18,45 @@
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\FunctionInterruptSimulation.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\etl_profile.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{2D9F7027-A2E4-4558-869E-A09815D85E02}</ProjectGuid>
|
||||
<RootNamespace>Debounce</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{5157DB15-C255-4E47-9FB1-AF388437F90F}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>FunctionInterruptSimulation</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
@ -68,58 +76,81 @@
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>C:\Users\John\AppData\Local\arduino15\packages\arduino\hardware\samd\1.6.5\cores\arduino;C:\Users\John\AppData\Local\arduino15\packages\arduino\hardware\samd\1.6.5\cores\arduino\avr;C:\Users\John\AppData\Local\arduino15\packages\arduino\hardware\samd\1.6.5\cores\arduino\USB;C:\Users\John\AppData\Local\arduino15\packages\arduino\hardware\samd\1.6.5\variants\arduino_zero;D:\Users\John\Documents\Programming\GitHub\etl\examples\Debounce;C:\Program Files (x86)\Arduino\libraries;C:\Users\John\AppData\Local\arduino15\packages\arduino\hardware\samd\1.6.5\libraries;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\qdmsbpkv.c4h\Micro Platforms\default\debuggers;D:\Users\John\Documents\Programming\Arduino\libraries;C:\Users\John\AppData\Local\arduino15\packages\arduino\tools\CMSIS\4.0.0-atmel/CMSIS/Include/;C:\Users\John\AppData\Local\arduino15\packages\arduino\tools\CMSIS\4.0.0-atmel/Device/ATMEL/;C:\Users\John\AppData\Local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\c++\4.8.3;C:\Users\John\AppData\Local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\c++\4.8.3\arm-none-eabi;C:\Users\John\AppData\Local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\c++\4.8.3\bits;C:\Users\John\AppData\Local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include;C:\Users\John\AppData\Local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\sys;C:\Users\John\AppData\Local\arduino15\packages\arduino\hardware\samd\1.6.5\system;C:\Users\John\AppData\Local\arduino15\packages\arduino\hardware\samd/avr;C:\Users\John\AppData\Local\arduino15\packages\arduino\hardware\samd/usb;C:\Users\John\AppData\Local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\lib\gcc\arm-none-eabi\4.8.3\include;C:\Users\John\AppData\Local\arduino15\packages\arduino\tools\CMSIS\4.0.0-atmel;C:\Users\John\AppData\Local\arduino15\packages\arduino\tools\CMSIS\4.0.0-atmel\Device\ATMEL\samd21\include;C:\Users\John\AppData\Local\arduino15\packages\arduino\tools\CMSIS\4.0.0-atmel\CMSIS\include;C:\Users\John\AppData\Local\arduino15\packages\arduino\tools\CMSIS\4.0.0-atmel\Device\ATMEL\samd21\include\component;C:\Users\John\AppData\Local\arduino15\packages\arduino\tools\CMSIS\4.0.0-atmel\Device\ATMEL\samd21\include\instance;C:\Users\John\AppData\Local\arduino15\packages\arduino\tools\CMSIS\4.0.0-atmel\Device\ATMEL\samd21\include\pio;C:\Users\John\AppData\Local\arduino15\packages\arduino\tools\CMSIS\4.0.0-atmel\Device\ATMEL\samd21\include\component;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<ForcedIncludeFiles>D:\Users\John\Documents\Programming\GitHub\etl\examples\Debounce\__vm\.Debounce.vsarduino.h;%(ForcedIncludeFiles)</ForcedIncludeFiles>
|
||||
<PreprocessorDefinitions>F_CPU=48000000L;ARDUINO=10607;ARDUINO_SAMD_ZERO;ARDUINO_ARCH_SAMD;__SAMD21G18A__;USB_VID=0x2341;USB_PID=0x804d;USBCON;__cplusplus=201103L;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>../../../src</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>../../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Debounce.ino">
|
||||
<FileType>CppCode</FileType>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="__vm\.Debounce.vsarduino.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
17
examples/FunctionInterruptSimulation/CMakeLists.txt
Normal file
17
examples/FunctionInterruptSimulation/CMakeLists.txt
Normal file
@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.5.0)
|
||||
project(FunctionInterruptSimulation)
|
||||
|
||||
add_definitions(-DETL_DEBUG)
|
||||
|
||||
include_directories(${UTPP_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/../../include)
|
||||
|
||||
set(SOURCE_FILES FunctionInterruptSimulation.cpp)
|
||||
|
||||
add_executable(FunctionInterruptSimulation ${SOURCE_FILES})
|
||||
target_include_directories(FunctionInterruptSimulation
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
set_property(TARGET FunctionInterruptSimulation PROPERTY CXX_STANDARD 17)
|
||||
|
||||
17
examples/QueuedFSM/CMakeLists.txt
Normal file
17
examples/QueuedFSM/CMakeLists.txt
Normal file
@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.5.0)
|
||||
project(queued_fsm)
|
||||
|
||||
add_definitions(-DETL_DEBUG)
|
||||
|
||||
include_directories(${UTPP_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/../../include)
|
||||
|
||||
set(SOURCE_FILES QueuedFSM.cpp)
|
||||
|
||||
add_executable(queued_fsm ${SOURCE_FILES})
|
||||
target_include_directories(queued_fsm
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
set_property(TARGET queued_fsm PROPERTY CXX_STANDARD 17)
|
||||
|
||||
17
examples/QueuedMessageRouter/CMakeLists.txt
Normal file
17
examples/QueuedMessageRouter/CMakeLists.txt
Normal file
@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.5.0)
|
||||
project(queued_message_router)
|
||||
|
||||
add_definitions(-DETL_DEBUG)
|
||||
|
||||
include_directories(${UTPP_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/../../include)
|
||||
|
||||
set(SOURCE_FILES QueuedMessageRouter.cpp)
|
||||
|
||||
add_executable(queued_message_router ${SOURCE_FILES})
|
||||
target_include_directories(queued_message_router
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
set_property(TARGET queued_message_router PROPERTY CXX_STANDARD 17)
|
||||
|
||||
@ -67,13 +67,16 @@ public:
|
||||
if (accepts(msg_))
|
||||
{
|
||||
// Place in queue.
|
||||
|
||||
Item item(&sender_, msg_);
|
||||
|
||||
queue.emplace(&sender_, msg_);
|
||||
|
||||
std::cout << "Queueing message " << int(msg_.message_id) << std::endl;
|
||||
std::cout << "Queueing message " << int(msg_.get_message_id()) << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Ignoring message " << int(msg_.message_id) << std::endl;
|
||||
std::cout << "Ignoring message " << int(msg_.get_message_id()) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,7 +88,7 @@ public:
|
||||
Item& item = queue.front();
|
||||
etl::imessage& msg = item.packet.get();
|
||||
etl::imessage_router& sender = *item.sender;
|
||||
std::cout << "Processing message " << int(msg.message_id) << std::endl;
|
||||
std::cout << "Processing message " << int(msg.get_message_id()) << std::endl;
|
||||
|
||||
// Call the base class's receive function.
|
||||
// This will route it to the correct on_receive handler.
|
||||
@ -98,25 +101,25 @@ public:
|
||||
//***************************************************************************
|
||||
void on_receive(etl::imessage_router& sender, const Message1& msg)
|
||||
{
|
||||
std::cout << " Received message " << int(msg.message_id) << " : '" << msg.i << "'" << std::endl;
|
||||
std::cout << " Received message " << int(msg.get_message_id()) << " : '" << msg.i << "'" << std::endl;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
void on_receive(etl::imessage_router& sender, const Message2& msg)
|
||||
{
|
||||
std::cout << " Received message " << int(msg.message_id) << " : '" << msg.d << "'" << std::endl;
|
||||
std::cout << " Received message " << int(msg.get_message_id()) << " : '" << msg.d << "'" << std::endl;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
void on_receive(etl::imessage_router& sender, const Message3& msg)
|
||||
{
|
||||
std::cout << " Received message " << int(msg.message_id) << " : '" << msg.s << "'" << std::endl;
|
||||
std::cout << " Received message " << int(msg.get_message_id()) << " : '" << msg.s << "'" << std::endl;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
void on_receive_unknown(etl::imessage_router& sender, const etl::imessage& msg)
|
||||
{
|
||||
std::cout << " Received unknown message " << int(msg.message_id) << std::endl;
|
||||
std::cout << " Received unknown message " << int(msg.get_message_id()) << std::endl;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@ -33,12 +33,8 @@ SOFTWARE.
|
||||
|
||||
#define ETL_THROW_EXCEPTIONS
|
||||
#define ETL_VERBOSE_ERRORS
|
||||
#define ETL_CHECK_PUSH_POP
|
||||
#define ETL_ISTRING_REPAIR_ENABLE
|
||||
#define ETL_IVECTOR_REPAIR_ENABLE
|
||||
#define ETL_IDEQUE_REPAIR_ENABLE
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER)
|
||||
#include "etl/profiles/msvc_x86.h"
|
||||
#else
|
||||
#include "etl/profiles/gcc_windows_x86.h"
|
||||
Binary file not shown.
@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\QueuedMessageRouter.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="etl_profile.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@ -23,32 +23,32 @@
|
||||
<ProjectGuid>{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>QueuedMessageRouter</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
@ -150,7 +150,7 @@
|
||||
<ClCompile Include="..\QueuedMessageRouter.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="etl_profile.h" />
|
||||
<ClInclude Include="..\etl_profile.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
17
examples/Scheduler/CMakeLists.txt
Normal file
17
examples/Scheduler/CMakeLists.txt
Normal file
@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.5.0)
|
||||
project(scheduler)
|
||||
|
||||
add_definitions(-DETL_DEBUG)
|
||||
|
||||
include_directories(${UTPP_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/../../include)
|
||||
|
||||
set(SOURCE_FILES Scheduler.cpp)
|
||||
|
||||
add_executable(scheduler ${SOURCE_FILES})
|
||||
target_include_directories(scheduler
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
set_property(TARGET scheduler PROPERTY CXX_STANDARD 17)
|
||||
|
||||
184
examples/Scheduler/Scheduler.cpp
Normal file
184
examples/Scheduler/Scheduler.cpp
Normal file
@ -0,0 +1,184 @@
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2020 jwellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
//*****************************************************************************
|
||||
// This example demonstrates the basic method to schedule tasks.
|
||||
// Experiment with the different scheduling policies.
|
||||
//*****************************************************************************
|
||||
|
||||
#include "etl/scheduler.h"
|
||||
#include "etl/task.h"
|
||||
#include "etl/function.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
//*****************************************************************************
|
||||
// Task 1. Lowest priority.
|
||||
//*****************************************************************************
|
||||
class Task1 : public etl::task
|
||||
{
|
||||
public:
|
||||
|
||||
//*************************************
|
||||
Task1()
|
||||
: task(1)
|
||||
, work(3)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//*************************************
|
||||
uint32_t task_request_work() const
|
||||
{
|
||||
return work; // How much work do we still have to do? This could be a message queue length.
|
||||
}
|
||||
|
||||
//*************************************
|
||||
void task_process_work()
|
||||
{
|
||||
std::cout << "Task1 : Process work : " << work << std::endl;
|
||||
--work;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
uint32_t work;
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
// Task 2. Highest priority.
|
||||
//*****************************************************************************
|
||||
class Task2 : public etl::task
|
||||
{
|
||||
public:
|
||||
|
||||
//*************************************
|
||||
Task2()
|
||||
: task(2)
|
||||
, work(4)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//*************************************
|
||||
uint32_t task_request_work() const
|
||||
{
|
||||
return work; // How much work do we still have to do? This could be a message queue length.
|
||||
}
|
||||
|
||||
//*************************************
|
||||
void task_process_work()
|
||||
{
|
||||
std::cout << "Task2 : Process work : " << work << std::endl;
|
||||
--work;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
uint32_t work;
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
// The idle handler.
|
||||
//*****************************************************************************
|
||||
class Idle
|
||||
{
|
||||
public:
|
||||
|
||||
//*************************************
|
||||
Idle(etl::ischeduler& scheduler_)
|
||||
: scheduler(scheduler_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//*************************************
|
||||
void IdleCallback()
|
||||
{
|
||||
std::cout << "Idle callback" << std::endl;
|
||||
scheduler.exit_scheduler();
|
||||
std::cout << "Exiting the scheduler" << std::endl;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
etl::ischeduler& scheduler;
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
// The watchdog handler.
|
||||
//*****************************************************************************
|
||||
void WatchdogCallback()
|
||||
{
|
||||
std::cout << "Watchdog callback" << std::endl;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// The scheduler.
|
||||
// Maximum of two tasks.
|
||||
//
|
||||
// Try the other scheduler policies to see how scheduling differs.
|
||||
// etl::scheduler_policy_sequential_single
|
||||
// etl::scheduler_policy_sequential_multiple
|
||||
// etl::scheduler_policy_highest_priority
|
||||
// etl::scheduler_policy_most_work
|
||||
//*****************************************************************************
|
||||
class Scheduler : public etl::scheduler<etl::scheduler_policy_sequential_single, 2>
|
||||
{
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
// The test application.
|
||||
//*****************************************************************************
|
||||
int main()
|
||||
{
|
||||
Scheduler scheduler;
|
||||
|
||||
Task1 task1;
|
||||
Task2 task2;
|
||||
|
||||
Idle idleHandler(scheduler);
|
||||
|
||||
etl::function_mv<Idle, &Idle::IdleCallback> idleCallback(idleHandler); // Member function, no parameters, returning void.
|
||||
etl::function_fv<WatchdogCallback> watchdogCallback; // Global function, no parameters, returning void.
|
||||
|
||||
scheduler.add_task(task1);
|
||||
scheduler.add_task(task2);
|
||||
scheduler.set_idle_callback(idleCallback);
|
||||
scheduler.set_watchdog_callback(watchdogCallback);
|
||||
|
||||
std::cout << "Starting the scheduler" << std::endl;
|
||||
|
||||
scheduler.start();
|
||||
|
||||
std::cout << "Exiting the application" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2017 jwellbelove, scott-eddy
|
||||
Copyright(c) 2020 jwellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
@ -27,38 +27,17 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __ETL_PROFILE_H__
|
||||
#define __ETL_PROFILE_H__
|
||||
#if defined(PROFILE_MSVC)
|
||||
#include "msvc_x86.h"
|
||||
#elif defined(PROFILE_GCC_GENERIC)
|
||||
#include "gcc_generic.h"
|
||||
#elif defined(PROFILE_GCC_LINUX_X86)
|
||||
#include "gcc_linux_x86.h"
|
||||
#elif defined(PROFILE_GCC_WINDOWS_X86)
|
||||
#include "gcc_windows_x86.h"
|
||||
#elif defined(PROFILE_CLANG_GENERIC)
|
||||
#include "clang_generic.h"
|
||||
#elif defined(PROFILE_ARM_V5_GENERIC)
|
||||
#include "armv5.h"
|
||||
#elif defined(PROFILE_ARM_V6_GENERIC)
|
||||
#include "armv6.h"
|
||||
#elif defined(PROFILE_ARDUINO)
|
||||
#include "arduino_arm.h"
|
||||
#elif defined(PROFILE_TICC)
|
||||
#include "ticc.h"
|
||||
#elif defined(PROFILE_CPP03_GENERIC)
|
||||
#include "cpp03.h"
|
||||
#elif defined(PROFILE_CPP11_GENERIC)
|
||||
#include "cpp11.h"
|
||||
#elif defined(PROFILE_CPP14_GENERIC)
|
||||
#include "cpp14.h"
|
||||
#elif defined(PROFILE_CPP17_GENERIC)
|
||||
#include "cpp17.h"
|
||||
#elif defined(PROFILE_CUSTOM)
|
||||
#include "custom_profile.h"
|
||||
#else
|
||||
#include "auto.h"
|
||||
|
||||
#define ETL_THROW_EXCEPTIONS
|
||||
#define ETL_VERBOSE_ERRORS
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#include "etl/profiles/msvc_x86.h"
|
||||
#elif defined(__GNUC__)
|
||||
#include "etl/profiles/gcc_generic.h"
|
||||
#endif
|
||||
|
||||
#endif // __ETL_PROFILE_H_
|
||||
#endif
|
||||
30
examples/Scheduler/vs2017/Scheduler.sln
Normal file
30
examples/Scheduler/vs2017/Scheduler.sln
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26730.10
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Scheduler", "Scheduler.vcxproj", "{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Debug|x86.Build.0 = Debug|Win32
|
||||
{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Release|x64.ActiveCfg = Release|x64
|
||||
{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Release|x64.Build.0 = Release|x64
|
||||
{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Release|x86.ActiveCfg = Release|Win32
|
||||
{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {98B87835-6672-45D4-95BF-CC5C22C87D2C}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
160
examples/Scheduler/vs2017/Scheduler.vcxproj
Normal file
160
examples/Scheduler/vs2017/Scheduler.vcxproj
Normal file
@ -0,0 +1,160 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>Scheduler</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>../../../include;../vs2017</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>../../../include;../vs2017</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeaderFile />
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\Scheduler.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\etl_profile.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
30
examples/Scheduler/vs2019/Scheduler.sln
Normal file
30
examples/Scheduler/vs2019/Scheduler.sln
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26730.10
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Scheduler", "Scheduler.vcxproj", "{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Debug|x86.Build.0 = Debug|Win32
|
||||
{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Release|x64.ActiveCfg = Release|x64
|
||||
{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Release|x64.Build.0 = Release|x64
|
||||
{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Release|x86.ActiveCfg = Release|Win32
|
||||
{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {98B87835-6672-45D4-95BF-CC5C22C87D2C}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
160
examples/Scheduler/vs2019/Scheduler.vcxproj
Normal file
160
examples/Scheduler/vs2019/Scheduler.vcxproj
Normal file
@ -0,0 +1,160 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>Scheduler</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>../../../include;../vs2017</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>../../../include;../vs2017</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeaderFile />
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\Scheduler.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\etl_profile.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
17
examples/SharedMessage/CMakeLists.txt
Normal file
17
examples/SharedMessage/CMakeLists.txt
Normal file
@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.5.0)
|
||||
project(SharedMessage)
|
||||
|
||||
add_definitions(-DETL_DEBUG)
|
||||
|
||||
include_directories(${UTPP_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/../../include)
|
||||
|
||||
set(SOURCE_FILES SharedMessage.cpp)
|
||||
|
||||
add_executable(SharedMessage ${SOURCE_FILES})
|
||||
target_include_directories(SharedMessage
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
set_property(TARGET SharedMessage PROPERTY CXX_STANDARD 17)
|
||||
|
||||
285
examples/SharedMessage/SharedMessage.cpp
Normal file
285
examples/SharedMessage/SharedMessage.cpp
Normal file
@ -0,0 +1,285 @@
|
||||
//*****************************************************************************
|
||||
// Shared message example
|
||||
//*****************************************************************************
|
||||
|
||||
#include "etl/shared_message.h"
|
||||
#include "etl/message.h"
|
||||
#include "etl/reference_counted_message_pool.h"
|
||||
#include "etl/message_router.h"
|
||||
#include "etl/message_bus.h"
|
||||
#include "etl/fixed_sized_memory_block_allocator.h"
|
||||
#include "etl/queue.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <atomic>
|
||||
#include <string>
|
||||
#include <mutex>
|
||||
|
||||
constexpr etl::message_router_id_t RouterId1 = 1U;
|
||||
constexpr etl::message_router_id_t RouterId2 = 2U;
|
||||
|
||||
//*****************************************************************************
|
||||
// Message1
|
||||
//*****************************************************************************
|
||||
struct Message1 : public etl::message<1>
|
||||
{
|
||||
Message1(std::string s_)
|
||||
: s(s_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string s;
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
// Message2
|
||||
//*****************************************************************************
|
||||
struct Message2 : public etl::message<2>
|
||||
{
|
||||
Message2(std::string s_)
|
||||
: s(s_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string s;
|
||||
char data[100];
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
// Message3
|
||||
//*****************************************************************************
|
||||
struct Message3 : public etl::message<3>
|
||||
{
|
||||
Message3(std::string s_)
|
||||
: s(s_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string s;
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
// Prints the shared message
|
||||
//*****************************************************************************
|
||||
void Print(const std::string& prefix, etl::shared_message sm)
|
||||
{
|
||||
std::cout << prefix << " : Message Id = " << int(sm.get_message().get_message_id()) << "\n";
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// This router accepts Message1, Message2 and Message3 types.
|
||||
// If a shared message it received, it will be processed immediately.
|
||||
//*****************************************************************************
|
||||
class MessageRouter1 : public etl::message_router<MessageRouter1, Message1, Message2, Message3>
|
||||
{
|
||||
public:
|
||||
|
||||
//****************************************
|
||||
MessageRouter1()
|
||||
: message_router(RouterId1)
|
||||
{
|
||||
}
|
||||
|
||||
//****************************************
|
||||
void on_receive(const Message1& msg)
|
||||
{
|
||||
std::cout << "MessageRouter1 : on_receive Message1 : " << msg.s << "\n";
|
||||
}
|
||||
|
||||
//****************************************
|
||||
void on_receive(const Message2& msg)
|
||||
{
|
||||
std::cout << "MessageRouter1 : on_receive Message2 : " << msg.s << "\n";
|
||||
}
|
||||
|
||||
//****************************************
|
||||
void on_receive(const Message3& msg)
|
||||
{
|
||||
std::cout << "MessageRouter1 : on_receive Message3 : " << msg.s << "\n";
|
||||
}
|
||||
|
||||
//****************************************
|
||||
void on_receive_unknown(const etl::imessage& msg)
|
||||
{
|
||||
std::cout << "MessageRouter1 : on_receive Unknown\n";
|
||||
}
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
// This router accepts Message1, Message2 and Message3 types.
|
||||
// If a shared message it received it will queue them.
|
||||
// The messages will be processed when process_queue() is called.
|
||||
//*****************************************************************************
|
||||
class MessageRouter2 : public etl::message_router<MessageRouter2, Message1, Message2, Message3>
|
||||
{
|
||||
public:
|
||||
|
||||
using base_t = etl::message_router<MessageRouter2, Message1, Message2, Message3>;
|
||||
|
||||
//****************************************
|
||||
MessageRouter2()
|
||||
: message_router(RouterId2)
|
||||
{
|
||||
}
|
||||
|
||||
using base_t::receive;
|
||||
|
||||
//****************************************
|
||||
// Overridden receive.
|
||||
// Puts the shared messages into a queue.
|
||||
void receive(etl::shared_message shared_msg) override
|
||||
{
|
||||
if (!queue.full())
|
||||
{
|
||||
Print("MessageRouter2 : Queueing shared message", shared_msg);
|
||||
|
||||
queue.push(shared_msg);
|
||||
}
|
||||
}
|
||||
|
||||
//****************************************
|
||||
// Processes the queued shared messages.
|
||||
void process_queue()
|
||||
{
|
||||
while (!queue.empty())
|
||||
{
|
||||
// Get the shared message from the queue.
|
||||
etl::shared_message shared_msg = queue.front();
|
||||
|
||||
Print("MessageRouter2 : Process queued shared message", shared_msg);
|
||||
|
||||
// Send it to the base implementation for routing.
|
||||
base_t::receive(shared_msg);
|
||||
|
||||
queue.pop();
|
||||
}
|
||||
}
|
||||
|
||||
//****************************************
|
||||
void on_receive(const Message1& msg)
|
||||
{
|
||||
std::cout << "MessageRouter2 : on_receive Message1 : " << msg.s << "\n";
|
||||
}
|
||||
|
||||
//****************************************
|
||||
void on_receive(const Message2& msg)
|
||||
{
|
||||
std::cout << "MessageRouter2 : on_receive Message2 : " << msg.s << "\n";
|
||||
}
|
||||
|
||||
//****************************************
|
||||
void on_receive(const Message3& msg)
|
||||
{
|
||||
std::cout << "MessageRouter2 : on_receive Message3 : " << msg.s << "\n";
|
||||
}
|
||||
|
||||
//****************************************
|
||||
void on_receive_unknown(const etl::imessage& msg)
|
||||
{
|
||||
std::cout << "MessageRouter2 : on_receive Unknown\n";
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
etl::queue<etl::shared_message, 10> queue;
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
// A message bus that can accomodate two subscribers.
|
||||
//*****************************************************************************
|
||||
struct Bus : public etl::message_bus<2U>
|
||||
{
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
// Define the routers and bus.
|
||||
//*****************************************************************************
|
||||
MessageRouter1 router1;
|
||||
MessageRouter2 router2;
|
||||
Bus bus;
|
||||
|
||||
//*****************************************************************************
|
||||
// The thread safe message pool. Uses atomic uint32_t for counting.
|
||||
class MessagePool : public etl::reference_counted_message_pool<std::atomic_int32_t>
|
||||
{
|
||||
public:
|
||||
|
||||
MessagePool(etl::imemory_block_allocator& allocator)
|
||||
: reference_counted_message_pool(allocator)
|
||||
{
|
||||
}
|
||||
|
||||
// Called before the memory block allocator is accessed.
|
||||
void lock() override
|
||||
{
|
||||
mut.lock();
|
||||
}
|
||||
|
||||
// Called after the memory block allocator has been accessed.
|
||||
void unlock() override
|
||||
{
|
||||
mut.unlock();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
std::mutex mut;
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
// The memory block allocator that supplies the pool with memory
|
||||
// to store reference counted messages in.
|
||||
|
||||
// The reference counted message parameters type for the messages we will use.
|
||||
using message_parameters_small = MessagePool::pool_message_parameters<Message1, Message3>;
|
||||
using message_parameters_large = MessagePool::pool_message_parameters<Message2>;
|
||||
|
||||
constexpr size_t max_size_small = message_parameters_small::max_size;
|
||||
constexpr size_t max_alignment_small = message_parameters_small::max_alignment;
|
||||
|
||||
constexpr size_t max_size_large = message_parameters_large::max_size;
|
||||
constexpr size_t max_alignment_large = message_parameters_large::max_alignment;
|
||||
|
||||
// A fixed memory block allocator for 4 items, using the parameters from the smaller messages.
|
||||
etl::fixed_sized_memory_block_allocator<max_size_small, max_alignment_small, 4U> memory_allocator;
|
||||
|
||||
// A fixed memory block allocator for 4 items, using the parameters from the larger message.
|
||||
etl::fixed_sized_memory_block_allocator<max_size_large, max_alignment_large, 4U> memory_allocator_successor;
|
||||
|
||||
//*****************************************************************************
|
||||
// The pool that supplies reference counted messages.
|
||||
// Uses memory_allocator as its allocator.
|
||||
//*****************************************************************************
|
||||
MessagePool message_pool(memory_allocator);
|
||||
|
||||
//*****************************************************************************
|
||||
// A statically allocated reference counted message that is never allocated or released by a pool.
|
||||
// Contains a copy of Message3("Three").
|
||||
//*****************************************************************************
|
||||
etl::persistent_message<Message3> pm3(Message3("Three"));
|
||||
|
||||
//*****************************************************************************
|
||||
int main()
|
||||
{
|
||||
// If memory_allocator can't allocate, then try memory_allocator_successor.
|
||||
memory_allocator.set_successor(memory_allocator_successor);
|
||||
|
||||
Message1 m1("One");
|
||||
Message2 m2("Two");
|
||||
|
||||
etl::shared_message sm1(message_pool, m1); // Created a shared message by allocating a reference counted message from message_pool containing a copy of m1.
|
||||
etl::shared_message sm2(message_pool, m2); // Created a shared message by allocating a reference counted message from message_pool containing a copy of m2.
|
||||
etl::shared_message sm3(pm3); // Created a shared message from a statically allocated persistent message.
|
||||
|
||||
bus.subscribe(router1); // Subscribe router1 to the bus.
|
||||
bus.subscribe(router2); // Subscribe router2 to the bus.
|
||||
|
||||
bus.receive(sm1); // Send sm1 to the bus for distribution to the routers.
|
||||
bus.receive(sm2); // Send sm2 to the bus for distribution to the routers.
|
||||
bus.receive(sm3); // Send sm3 to the bus for distribution to the routers.
|
||||
|
||||
router2.process_queue(); // Allow router2 to process its queued messages.
|
||||
}
|
||||
31
examples/SharedMessage/SharedMessage.sln
Normal file
31
examples/SharedMessage/SharedMessage.sln
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30804.86
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SharedMessage", "SharedMessage.vcxproj", "{0BDB4F2A-47E7-4105-A66A-6DFF8A76587B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{0BDB4F2A-47E7-4105-A66A-6DFF8A76587B}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{0BDB4F2A-47E7-4105-A66A-6DFF8A76587B}.Debug|x64.Build.0 = Debug|x64
|
||||
{0BDB4F2A-47E7-4105-A66A-6DFF8A76587B}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{0BDB4F2A-47E7-4105-A66A-6DFF8A76587B}.Debug|x86.Build.0 = Debug|Win32
|
||||
{0BDB4F2A-47E7-4105-A66A-6DFF8A76587B}.Release|x64.ActiveCfg = Release|x64
|
||||
{0BDB4F2A-47E7-4105-A66A-6DFF8A76587B}.Release|x64.Build.0 = Release|x64
|
||||
{0BDB4F2A-47E7-4105-A66A-6DFF8A76587B}.Release|x86.ActiveCfg = Release|Win32
|
||||
{0BDB4F2A-47E7-4105-A66A-6DFF8A76587B}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {F7B7515D-19FA-42D4-9BA2-5F85A7FB7779}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
165
examples/SharedMessage/SharedMessage.vcxproj
Normal file
165
examples/SharedMessage/SharedMessage.vcxproj
Normal file
@ -0,0 +1,165 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{0bdb4f2a-47e7-4105-a66a-6dff8a76587b}</ProjectGuid>
|
||||
<RootNamespace>SharedMessage</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>D:\Users\John\Documents\Programming\GitHub\etl\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="SharedMessage.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\include\etl\atomic.h" />
|
||||
<ClInclude Include="..\..\include\etl\fixed_sized_memory_block_allocator.h" />
|
||||
<ClInclude Include="..\..\include\etl\imemory_block_allocator.h" />
|
||||
<ClInclude Include="..\..\include\etl\ireference_counted_message_pool.h" />
|
||||
<ClInclude Include="..\..\include\etl\message.h" />
|
||||
<ClInclude Include="..\..\include\etl\message_bus.h" />
|
||||
<ClInclude Include="..\..\include\etl\message_router.h" />
|
||||
<ClInclude Include="..\..\include\etl\message_types.h" />
|
||||
<ClInclude Include="..\..\include\etl\reference_counted_message.h" />
|
||||
<ClInclude Include="..\..\include\etl\reference_counted_message_pool.h" />
|
||||
<ClInclude Include="..\..\include\etl\reference_counted_object.h" />
|
||||
<ClInclude Include="..\..\include\etl\shared_message.h" />
|
||||
<ClInclude Include="..\..\include\etl\successor.h" />
|
||||
<ClInclude Include="etl_profile.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
66
examples/SharedMessage/SharedMessage.vcxproj.filters
Normal file
66
examples/SharedMessage/SharedMessage.vcxproj.filters
Normal file
@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="SharedMessage.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="etl_profile.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\atomic.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\fixed_sized_memory_block_allocator.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\imemory_block_allocator.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\ireference_counted_message_pool.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\reference_counted_message.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\reference_counted_message_pool.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\reference_counted_object.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\shared_message.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\successor.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\message.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\message_router.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\message_types.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\message_bus.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
0
examples/SharedMessage/etl_profile.h
Normal file
0
examples/SharedMessage/etl_profile.h
Normal file
BIN
favicon.ico
BIN
favicon.ico
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB |
BIN
images/etl-round.png
Normal file
BIN
images/etl-round.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
Binary file not shown.
BIN
images/etl64.png
Normal file
BIN
images/etl64.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
BIN
images/favicon-64.png
Normal file
BIN
images/favicon-64.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
@ -39,7 +39,7 @@ namespace etl
|
||||
// For signed types.
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
typename etl::enable_if<etl::is_signed<T>::value, T>::type
|
||||
ETL_CONSTEXPR typename etl::enable_if<etl::is_signed<T>::value, T>::type
|
||||
absolute(T value)
|
||||
{
|
||||
return (value < T(0)) ? -value : value;
|
||||
@ -49,7 +49,7 @@ namespace etl
|
||||
// For unsigned types.
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
typename etl::enable_if<etl::is_unsigned<T>::value, T>::type
|
||||
ETL_CONSTEXPR typename etl::enable_if<etl::is_unsigned<T>::value, T>::type
|
||||
absolute(T value)
|
||||
{
|
||||
return value;
|
||||
|
||||
@ -46,13 +46,15 @@ SOFTWARE.
|
||||
#include "functional.h"
|
||||
#include "utility.h"
|
||||
|
||||
#if !defined(ETL_NO_STL)
|
||||
#if ETL_USING_STL
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
#include <iterator>
|
||||
#include <functional>
|
||||
#endif
|
||||
|
||||
#include "private/minmax_push.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
// Declare prototypes of the ETL's sort functions
|
||||
@ -74,7 +76,7 @@ namespace etl
|
||||
//*****************************************************************************
|
||||
namespace etl
|
||||
{
|
||||
#if defined(ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// iter_swap
|
||||
template <typename TIterator1, typename TIterator2>
|
||||
@ -93,7 +95,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// swap_ranges
|
||||
template <typename T1terator1, typename TIterator2>
|
||||
@ -120,14 +122,14 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// copy
|
||||
// Pointer
|
||||
template <typename TIterator1, typename TIterator2>
|
||||
typename etl::enable_if<etl::is_pointer<TIterator1>::value &&
|
||||
etl::is_pointer<TIterator2>::value &&
|
||||
etl::is_pod<typename etl::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type
|
||||
etl::is_trivially_copyable<typename etl::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type
|
||||
copy(TIterator1 sb, TIterator1 se, TIterator2 db)
|
||||
{
|
||||
typedef typename etl::iterator_traits<TIterator1>::value_type value_t;
|
||||
@ -142,7 +144,7 @@ namespace etl
|
||||
template <typename TIterator1, typename TIterator2>
|
||||
typename etl::enable_if<!etl::is_pointer<TIterator1>::value ||
|
||||
!etl::is_pointer<TIterator2>::value ||
|
||||
!etl::is_pod<typename etl::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type
|
||||
!etl::is_trivially_copyable<typename etl::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type
|
||||
copy(TIterator1 sb, TIterator1 se, TIterator2 db)
|
||||
{
|
||||
while (sb != se)
|
||||
@ -162,7 +164,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// reverse_copy
|
||||
template <typename TIterator1, typename TIterator2>
|
||||
@ -185,14 +187,14 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
|
||||
#if ETL_NOT_USING_STL || ETL_CPP11_NOT_SUPPORTED
|
||||
//***************************************************************************
|
||||
// copy_n
|
||||
// Pointer
|
||||
template <typename TIterator1, typename TSize, typename TIterator2>
|
||||
typename etl::enable_if<etl::is_pointer<TIterator1>::value &&
|
||||
etl::is_pointer<TIterator2>::value &&
|
||||
etl::is_pod<typename etl::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type
|
||||
etl::is_pointer<TIterator2>::value &&
|
||||
etl::is_trivially_copyable<typename etl::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type
|
||||
copy_n(TIterator1 sb, TSize count, TIterator2 db)
|
||||
{
|
||||
typedef typename etl::iterator_traits<TIterator1>::value_type value_t;
|
||||
@ -203,8 +205,8 @@ namespace etl
|
||||
// Other iterator
|
||||
template <typename TIterator1, typename TSize, typename TIterator2>
|
||||
typename etl::enable_if<!etl::is_pointer<TIterator1>::value ||
|
||||
!etl::is_pointer<TIterator2>::value ||
|
||||
!etl::is_pod<typename etl::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type
|
||||
!etl::is_pointer<TIterator2>::value ||
|
||||
!etl::is_trivially_copyable<typename etl::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type
|
||||
copy_n(TIterator1 sb, TSize count, TIterator2 db)
|
||||
{
|
||||
while (count != 0)
|
||||
@ -230,14 +232,14 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// copy_backward
|
||||
// Pointer
|
||||
template <typename TIterator1, typename TIterator2>
|
||||
typename etl::enable_if<etl::is_pointer<TIterator1>::value &&
|
||||
etl::is_pointer<TIterator2>::value &&
|
||||
etl::is_pod<typename etl::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type
|
||||
etl::is_pointer<TIterator2>::value &&
|
||||
etl::is_trivially_copyable<typename etl::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type
|
||||
copy_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
|
||||
{
|
||||
typedef typename etl::iterator_traits<TIterator1>::value_type value_t;
|
||||
@ -250,8 +252,8 @@ namespace etl
|
||||
// Other iterator
|
||||
template <typename TIterator1, typename TIterator2>
|
||||
typename etl::enable_if<!etl::is_pointer<TIterator1>::value ||
|
||||
!etl::is_pointer<TIterator2>::value ||
|
||||
!etl::is_pod<typename etl::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type
|
||||
!etl::is_pointer<TIterator2>::value ||
|
||||
!etl::is_trivially_copyable<typename etl::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type
|
||||
copy_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
|
||||
{
|
||||
while (se != sb)
|
||||
@ -272,11 +274,15 @@ namespace etl
|
||||
#endif
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
#if defined(ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// move
|
||||
// non-pointer or not trivially copyable
|
||||
template <typename TIterator1, typename TIterator2>
|
||||
TIterator2 move(TIterator1 sb, TIterator1 se, TIterator2 db)
|
||||
typename etl::enable_if<!etl::is_pointer<TIterator1>::value ||
|
||||
!etl::is_pointer<TIterator2>::value ||
|
||||
!etl::is_trivially_copyable<typename etl::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type
|
||||
move(TIterator1 sb, TIterator1 se, TIterator2 db)
|
||||
{
|
||||
while (sb != se)
|
||||
{
|
||||
@ -285,6 +291,21 @@ namespace etl
|
||||
|
||||
return db;
|
||||
}
|
||||
|
||||
// pointer and trivially copyable
|
||||
template <typename TIterator1, typename TIterator2>
|
||||
typename etl::enable_if<etl::is_pointer<TIterator1>::value &&
|
||||
etl::is_pointer<TIterator2>::value &&
|
||||
etl::is_trivially_copyable<typename etl::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type
|
||||
move(TIterator1 sb, TIterator1 se, TIterator2 db)
|
||||
{
|
||||
typedef typename etl::iterator_traits<TIterator1>::value_type value_t;
|
||||
typedef typename etl::iterator_traits<TIterator1>::difference_type difference_t;
|
||||
|
||||
difference_t count = (se - sb);
|
||||
|
||||
return TIterator2(memmove(db, sb, sizeof(value_t) * count)) + count;
|
||||
}
|
||||
#else
|
||||
//***************************************************************************
|
||||
// move
|
||||
@ -307,11 +328,15 @@ namespace etl
|
||||
#endif
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
#if defined(ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// move_backward
|
||||
// non-pointer, non-pod
|
||||
template <typename TIterator1, typename TIterator2>
|
||||
TIterator2 move_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
|
||||
typename etl::enable_if<!etl::is_pointer<TIterator1>::value ||
|
||||
!etl::is_pointer<TIterator2>::value ||
|
||||
!etl::is_trivially_copyable<typename etl::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type
|
||||
move_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
|
||||
{
|
||||
while (sb != se)
|
||||
{
|
||||
@ -320,6 +345,22 @@ namespace etl
|
||||
|
||||
return de;
|
||||
}
|
||||
|
||||
// pointer and pod
|
||||
template <typename TIterator1, typename TIterator2>
|
||||
typename etl::enable_if<etl::is_pointer<TIterator1>::value &&
|
||||
etl::is_pointer<TIterator2>::value &&
|
||||
etl::is_trivially_copyable<typename etl::iterator_traits<TIterator1>::value_type>::value, TIterator2>::type
|
||||
move_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
|
||||
{
|
||||
typedef typename etl::iterator_traits<TIterator1>::value_type value_t;
|
||||
typedef typename etl::iterator_traits<TIterator1>::difference_type difference_t;
|
||||
|
||||
difference_t count = (se - sb);
|
||||
TIterator2 db = de - count;
|
||||
|
||||
return TIterator2(memmove(db, sb, sizeof(value_t) * count)) + count;
|
||||
}
|
||||
#else
|
||||
//***************************************************************************
|
||||
// move_backward
|
||||
@ -340,7 +381,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// reverse
|
||||
// Pointers
|
||||
@ -378,7 +419,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// lower_bound
|
||||
template<typename TIterator, typename TValue, typename TCompare>
|
||||
@ -436,7 +477,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// upper_bound
|
||||
template<typename TIterator, typename TValue, typename TCompare>
|
||||
@ -494,7 +535,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// equal_range
|
||||
template<typename TIterator, typename TValue, typename TCompare>
|
||||
@ -532,7 +573,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// find_if
|
||||
template <typename TIterator, typename TUnaryPredicate>
|
||||
@ -562,7 +603,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// find
|
||||
template <typename TIterator, typename T>
|
||||
@ -592,7 +633,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// fill
|
||||
template<typename TIterator, typename TValue>
|
||||
@ -621,7 +662,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// fill_n
|
||||
template<typename TIterator, typename TSize, typename TValue>
|
||||
@ -658,7 +699,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// count
|
||||
template <typename TIterator, typename T>
|
||||
@ -690,7 +731,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// count_if
|
||||
template <typename TIterator, typename TUnaryPredicate>
|
||||
@ -722,12 +763,12 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// equal
|
||||
template <typename TIterator1, typename TIterator2>
|
||||
ETL_NODISCARD
|
||||
typename etl::enable_if<!etl::is_pointer<TIterator1>::value || !etl::is_pointer<TIterator2>::value || !etl::is_pod<typename etl::iterator_traits<TIterator1>::value_type>::value, bool>::type
|
||||
typename etl::enable_if<!etl::is_pointer<TIterator1>::value || !etl::is_pointer<TIterator2>::value || !etl::is_trivially_copyable<typename etl::iterator_traits<TIterator1>::value_type>::value, bool>::type
|
||||
equal(TIterator1 first1, TIterator1 last1, TIterator2 first2)
|
||||
{
|
||||
while (first1 != last1)
|
||||
@ -743,13 +784,22 @@ namespace etl
|
||||
|
||||
template <typename TIterator1, typename TIterator2>
|
||||
ETL_NODISCARD
|
||||
typename etl::enable_if<etl::is_pointer<TIterator1>::value && etl::is_pointer<TIterator2>::value && etl::is_pod<typename etl::iterator_traits<TIterator1>::value_type>::value, bool>::type
|
||||
typename etl::enable_if<etl::is_pointer<TIterator1>::value && etl::is_pointer<TIterator2>::value && etl::is_trivially_copyable<typename etl::iterator_traits<TIterator1>::value_type>::value, bool>::type
|
||||
equal(TIterator1 first1, TIterator1 last1, TIterator2 first2)
|
||||
{
|
||||
typedef typename etl::iterator_traits<TIterator1>::value_type value_t;
|
||||
|
||||
return (memcmp(first1, first2, sizeof(value_t) * (last1 - first1)) == 0);
|
||||
}
|
||||
|
||||
template <typename TIterator1, typename TIterator2>
|
||||
ETL_NODISCARD
|
||||
bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2, TIterator2 last2)
|
||||
{
|
||||
return (etl::distance(first1, last1) == etl::distance(first2, last2)) &&
|
||||
etl::equal(first1, last1, first2);
|
||||
}
|
||||
|
||||
#else
|
||||
//***************************************************************************
|
||||
// equal
|
||||
@ -759,9 +809,26 @@ namespace etl
|
||||
{
|
||||
return std::equal(first1, last1, first2);
|
||||
}
|
||||
|
||||
#if ETL_CPP14_SUPPORTED
|
||||
template <typename TIterator1, typename TIterator2>
|
||||
ETL_NODISCARD
|
||||
bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2, TIterator2 last2)
|
||||
{
|
||||
return std::equal(first1, last1, first2, last2);
|
||||
}
|
||||
#else
|
||||
template <typename TIterator1, typename TIterator2>
|
||||
ETL_NODISCARD
|
||||
bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2, TIterator2 last2)
|
||||
{
|
||||
return (etl::distance(first1, last1) == etl::distance(first2, last2)) &&
|
||||
etl::equal(first1, last1, first2);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// lexicographical_compare
|
||||
template <typename TIterator1, typename TIterator2, typename TCompare>
|
||||
@ -823,7 +890,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// min
|
||||
template <typename T, typename TCompare>
|
||||
@ -859,7 +926,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// max
|
||||
template <typename T, typename TCompare>
|
||||
@ -895,7 +962,30 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// for_each
|
||||
template <typename TIterator, typename TUnaryOperation>
|
||||
ETL_CONSTEXPR14 TUnaryOperation for_each(TIterator first, TIterator last, TUnaryOperation unary_operation)
|
||||
{
|
||||
while (first != last)
|
||||
{
|
||||
unary_operation(*first++);
|
||||
}
|
||||
|
||||
return unary_operation;
|
||||
}
|
||||
#else
|
||||
//***************************************************************************
|
||||
// for_each
|
||||
template <typename TIterator, typename TUnaryOperation>
|
||||
ETL_CONSTEXPR14 TUnaryOperation for_each(TIterator first, TIterator last, TUnaryOperation unary_operation)
|
||||
{
|
||||
return std::for_each(first, last, unary_operation);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// transform
|
||||
template <typename TIteratorIn, typename TIteratorOut, typename TUnaryOperation>
|
||||
@ -935,6 +1025,56 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// replace
|
||||
template <typename TIterator, typename T>
|
||||
ETL_CONSTEXPR14 void replace(TIterator first, TIterator last, const T& old_value, const T& new_value)
|
||||
{
|
||||
while (first != last)
|
||||
{
|
||||
if (*first == old_value)
|
||||
{
|
||||
*first = new_value;
|
||||
}
|
||||
|
||||
++first;
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
// replace_if
|
||||
template <typename TIterator, typename TPredicate, typename T>
|
||||
ETL_CONSTEXPR14 void replace_if(TIterator first, TIterator last, TPredicate predicate, const T& new_value)
|
||||
{
|
||||
while (first != last)
|
||||
{
|
||||
if (predicate(*first))
|
||||
{
|
||||
*first = new_value;
|
||||
}
|
||||
|
||||
++first;
|
||||
}
|
||||
}
|
||||
#else
|
||||
//***************************************************************************
|
||||
// replace
|
||||
template <typename TIterator, typename T>
|
||||
ETL_CONSTEXPR14 void replace(TIterator first, TIterator last, const T& old_value, const T& new_value)
|
||||
{
|
||||
std::replace(first, last, old_value, new_value);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
// replace_if
|
||||
template <typename TIterator, typename TPredicate, typename T>
|
||||
ETL_CONSTEXPR14 void replace_if(TIterator first, TIterator last, TPredicate predicate, const T& new_value)
|
||||
{
|
||||
std::replace_if(first, last, predicate, new_value);
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
// Heap
|
||||
namespace private_heap
|
||||
@ -1006,7 +1146,7 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
#if defined (ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
// Pop Heap
|
||||
template <typename TIterator, typename TCompare>
|
||||
void pop_heap(TIterator first, TIterator last, TCompare compare)
|
||||
@ -1186,7 +1326,7 @@ namespace etl
|
||||
{
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
return std::is_heap(first, last);
|
||||
#else
|
||||
#else
|
||||
typedef etl::less<typename etl::iterator_traits<TIterator>::value_type> compare;
|
||||
return private_heap::is_heap(first, last - first, compare());
|
||||
#endif
|
||||
@ -1208,7 +1348,7 @@ namespace etl
|
||||
|
||||
#endif
|
||||
|
||||
#if defined (ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// Search
|
||||
template<typename TIterator1, typename TIterator2, typename TCompare>
|
||||
@ -1273,33 +1413,91 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// Rotate
|
||||
namespace private_algorithm
|
||||
{
|
||||
//*********************************
|
||||
template <typename TIterator>
|
||||
TIterator rotate_general(TIterator first, TIterator middle, TIterator last)
|
||||
{
|
||||
TIterator next = middle;
|
||||
|
||||
while (first != next)
|
||||
{
|
||||
using ETL_OR_STD::swap; // Allow ADL
|
||||
|
||||
swap(*first++, *next++);
|
||||
|
||||
if (next == last)
|
||||
{
|
||||
next = middle;
|
||||
}
|
||||
else if (first == middle)
|
||||
{
|
||||
middle = next;
|
||||
}
|
||||
}
|
||||
|
||||
return first;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
template <typename TIterator>
|
||||
TIterator rotate_left_by_one(TIterator first, TIterator last)
|
||||
{
|
||||
typedef typename etl::iterator_traits<TIterator>::value_type value_type;
|
||||
|
||||
// Save the first item.
|
||||
value_type temp(etl::move(*first));
|
||||
|
||||
// Move the rest.
|
||||
TIterator result = etl::move(etl::next(first), last, first);
|
||||
|
||||
// Restore the first item in its rotated position.
|
||||
*result = etl::move(temp);
|
||||
|
||||
// The new position of the first item.
|
||||
return result;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
template <typename TIterator>
|
||||
TIterator rotate_right_by_one(TIterator first, TIterator last)
|
||||
{
|
||||
typedef typename etl::iterator_traits<TIterator>::value_type value_type;
|
||||
|
||||
// Save the last item.
|
||||
TIterator previous = etl::prev(last);
|
||||
value_type temp(etl::move(*previous));
|
||||
|
||||
// Move the rest.
|
||||
TIterator result = etl::move_backward(first, previous, last);
|
||||
|
||||
// Restore the last item in its rotated position.
|
||||
*first = etl::move(temp);
|
||||
|
||||
// The new position of the first item.
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//*********************************
|
||||
template<typename TIterator>
|
||||
TIterator rotate(TIterator first, TIterator middle, TIterator last)
|
||||
{
|
||||
using ETL_OR_STD::swap; // Allow ADL
|
||||
|
||||
TIterator next = middle;
|
||||
|
||||
while (first != next)
|
||||
if (etl::next(first) == middle)
|
||||
{
|
||||
using ETL_OR_STD::swap;
|
||||
|
||||
swap(*first++, *next++);
|
||||
|
||||
if (next == last)
|
||||
{
|
||||
next = middle;
|
||||
}
|
||||
else if (first == middle)
|
||||
{
|
||||
middle = next;
|
||||
}
|
||||
return private_algorithm::rotate_left_by_one(first, last);
|
||||
}
|
||||
|
||||
return first;
|
||||
if (etl::next(middle) == last)
|
||||
{
|
||||
return private_algorithm::rotate_right_by_one(first, last);
|
||||
}
|
||||
|
||||
return private_algorithm::rotate_general(first, middle, last);
|
||||
}
|
||||
#else
|
||||
//***************************************************************************
|
||||
@ -1311,7 +1509,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
// find_end
|
||||
// Predicate
|
||||
@ -1379,7 +1577,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
/// Finds the iterator to the smallest element in the range (begin, end).<br>
|
||||
///<a href="http://en.cppreference.com/w/cpp/algorithm/min_element"></a>
|
||||
@ -1449,7 +1647,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
/// Finds the iterator to the largest element in the range (begin, end).<br>
|
||||
///<a href="http://en.cppreference.com/w/cpp/algorithm/max_element"></a>
|
||||
@ -1519,7 +1717,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
|
||||
#if ETL_NOT_USING_STL || ETL_CPP11_NOT_SUPPORTED
|
||||
//***************************************************************************
|
||||
/// Finds the greatest and the smallest element in the range (begin, end).<br>
|
||||
///<a href="http://en.cppreference.com/w/cpp/algorithm/minmax_element"></a>
|
||||
@ -1595,7 +1793,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
|
||||
#if ETL_NOT_USING_STL || ETL_CPP11_NOT_SUPPORTED
|
||||
//***************************************************************************
|
||||
/// minmax
|
||||
///\ingroup algorithm
|
||||
@ -1651,7 +1849,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
|
||||
#if ETL_NOT_USING_STL || ETL_CPP11_NOT_SUPPORTED
|
||||
//***************************************************************************
|
||||
/// is_sorted_until
|
||||
///\ingroup algorithm
|
||||
@ -1737,7 +1935,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
|
||||
#if ETL_NOT_USING_STL || ETL_CPP11_NOT_SUPPORTED
|
||||
//***************************************************************************
|
||||
/// is_sorted
|
||||
///\ingroup algorithm
|
||||
@ -1793,7 +1991,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
|
||||
#if ETL_NOT_USING_STL || ETL_CPP11_NOT_SUPPORTED
|
||||
//***************************************************************************
|
||||
/// find_if_not
|
||||
///\ingroup algorithm
|
||||
@ -1833,7 +2031,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
|
||||
#if ETL_NOT_USING_STL || ETL_CPP11_NOT_SUPPORTED
|
||||
//***************************************************************************
|
||||
/// is_permutation
|
||||
///\ingroup algorithm
|
||||
@ -2029,7 +2227,7 @@ namespace etl
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
|
||||
#if ETL_NOT_USING_STL || ETL_CPP11_NOT_SUPPORTED
|
||||
//***************************************************************************
|
||||
/// is_partitioned
|
||||
///\ingroup algorithm
|
||||
@ -2075,7 +2273,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
|
||||
#if ETL_NOT_USING_STL || ETL_CPP11_NOT_SUPPORTED
|
||||
//***************************************************************************
|
||||
/// partition_point
|
||||
///<a href="http://en.cppreference.com/w/cpp/algorithm/partition_point"></a>
|
||||
@ -2115,7 +2313,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
|
||||
#if ETL_NOT_USING_STL || ETL_CPP11_NOT_SUPPORTED
|
||||
//***************************************************************************
|
||||
/// Copies the elements from the range (begin, end) to two different ranges
|
||||
/// depending on the value returned by the predicate.<br>
|
||||
@ -2161,7 +2359,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
|
||||
#if ETL_NOT_USING_STL || ETL_CPP11_NOT_SUPPORTED
|
||||
//***************************************************************************
|
||||
/// copy_if
|
||||
///\ingroup algorithm
|
||||
@ -2201,7 +2399,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
|
||||
#if ETL_NOT_USING_STL || ETL_CPP11_NOT_SUPPORTED
|
||||
//***************************************************************************
|
||||
/// all_of
|
||||
///\ingroup algorithm
|
||||
@ -2231,7 +2429,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
|
||||
#if ETL_NOT_USING_STL || ETL_CPP11_NOT_SUPPORTED
|
||||
//***************************************************************************
|
||||
/// any_of
|
||||
///\ingroup algorithm
|
||||
@ -2261,7 +2459,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL) || !ETL_CPP11_SUPPORTED
|
||||
#if ETL_NOT_USING_STL || ETL_CPP11_NOT_SUPPORTED
|
||||
//***************************************************************************
|
||||
/// none_of
|
||||
///\ingroup algorithm
|
||||
@ -2291,7 +2489,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ETL_NO_STL)
|
||||
#if ETL_NOT_USING_STL
|
||||
//***************************************************************************
|
||||
/// Sorts the elements.
|
||||
/// Uses user defined comparison.
|
||||
@ -3244,4 +3442,6 @@ namespace etl
|
||||
#endif
|
||||
}
|
||||
|
||||
#include "private/minmax_pop.h"
|
||||
|
||||
#endif
|
||||
|
||||
@ -99,7 +99,7 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
#if defined(ETL_NO_64BIT_TYPES)
|
||||
#if ETL_NOT_USING_64BIT_TYPES
|
||||
typedef typename private_alignment::type_with_alignment_helper<ALIGNMENT, int_least8_t, int_least16_t, int32_t, float, double, void*>::type type;
|
||||
#else
|
||||
typedef typename private_alignment::type_with_alignment_helper<ALIGNMENT, int_least8_t, int_least16_t, int32_t, int64_t, float, double, void*>::type type;
|
||||
@ -184,7 +184,7 @@ namespace etl
|
||||
return reinterpret_cast<const T*>(data);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_COMPILER_ARM5)
|
||||
alignas(ALIGNMENT) char data[LENGTH];
|
||||
#else
|
||||
union
|
||||
@ -196,14 +196,24 @@ namespace etl
|
||||
};
|
||||
};
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
template <const size_t LENGTH, const size_t ALIGNMENT>
|
||||
using aligned_storage_t = typename aligned_storage<LENGTH, ALIGNMENT>::type;
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Aligned storage as
|
||||
///\ingroup alignment
|
||||
//***************************************************************************
|
||||
template <const size_t LENGTH, typename T>
|
||||
template <size_t LENGTH, typename T>
|
||||
struct aligned_storage_as : public etl::aligned_storage<LENGTH, etl::alignment_of<T>::value>
|
||||
{
|
||||
};
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
template <size_t LENGTH, typename T>
|
||||
using aligned_storage_as_t = typename aligned_storage_as<LENGTH, T>::type;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -5,7 +5,7 @@ The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
http://www.etlcpp.com
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2014 jwellbelove
|
||||
|
||||
@ -139,7 +139,7 @@ namespace etl
|
||||
/// Returns a reference to the value at index 'i'.
|
||||
///\param i The index of the element to access.
|
||||
//*************************************************************************
|
||||
reference operator[](size_t i)
|
||||
ETL_CONSTEXPR reference operator[](size_t i)
|
||||
{
|
||||
return _buffer[i];
|
||||
}
|
||||
@ -149,7 +149,7 @@ namespace etl
|
||||
/// Returns a const reference to the value at index 'i'.
|
||||
///\param i The index of the element to access.
|
||||
//*************************************************************************
|
||||
const_reference operator[](size_t i) const
|
||||
ETL_CONSTEXPR const_reference operator[](size_t i) const
|
||||
{
|
||||
return _buffer[i];
|
||||
}
|
||||
@ -157,7 +157,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a reference to the first element.
|
||||
//*************************************************************************
|
||||
reference front()
|
||||
ETL_CONSTEXPR reference front()
|
||||
{
|
||||
return _buffer[0];
|
||||
}
|
||||
@ -165,7 +165,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const reference to the first element.
|
||||
//*************************************************************************
|
||||
const_reference front() const
|
||||
ETL_CONSTEXPR const_reference front() const
|
||||
{
|
||||
return _buffer[0];
|
||||
}
|
||||
@ -173,7 +173,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a reference to the last element.
|
||||
//*************************************************************************
|
||||
reference back()
|
||||
ETL_CONSTEXPR reference back()
|
||||
{
|
||||
return _buffer[SIZE - 1];
|
||||
}
|
||||
@ -181,7 +181,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const reference to the last element.
|
||||
//*************************************************************************
|
||||
const_reference back() const
|
||||
ETL_CONSTEXPR const_reference back() const
|
||||
{
|
||||
return _buffer[SIZE - 1];
|
||||
}
|
||||
@ -189,7 +189,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a pointer to the first element of the internal buffer.
|
||||
//*************************************************************************
|
||||
pointer data()
|
||||
ETL_CONSTEXPR pointer data() ETL_NOEXCEPT
|
||||
{
|
||||
return &_buffer[0];
|
||||
}
|
||||
@ -197,7 +197,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const pointer to the first element of the internal buffer.
|
||||
//*************************************************************************
|
||||
const_pointer data() const
|
||||
ETL_CONSTEXPR const_pointer data() const ETL_NOEXCEPT
|
||||
{
|
||||
return &_buffer[0];
|
||||
}
|
||||
@ -209,7 +209,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns an iterator to the beginning of the array.
|
||||
//*************************************************************************
|
||||
iterator begin()
|
||||
ETL_CONSTEXPR iterator begin() ETL_NOEXCEPT
|
||||
{
|
||||
return &_buffer[0];
|
||||
}
|
||||
@ -217,7 +217,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const iterator to the beginning of the array.
|
||||
//*************************************************************************
|
||||
const_iterator begin() const
|
||||
ETL_CONSTEXPR const_iterator begin() const ETL_NOEXCEPT
|
||||
{
|
||||
return &_buffer[0];
|
||||
}
|
||||
@ -225,7 +225,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const iterator to the beginning of the array.
|
||||
//*************************************************************************
|
||||
const_iterator cbegin() const
|
||||
ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT
|
||||
{
|
||||
return begin();
|
||||
}
|
||||
@ -233,7 +233,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns an iterator to the end of the array.
|
||||
//*************************************************************************
|
||||
iterator end()
|
||||
ETL_CONSTEXPR iterator end() ETL_NOEXCEPT
|
||||
{
|
||||
return &_buffer[SIZE];
|
||||
}
|
||||
@ -241,7 +241,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const iterator to the end of the array.
|
||||
//*************************************************************************
|
||||
const_iterator end() const
|
||||
ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT
|
||||
{
|
||||
return &_buffer[SIZE];
|
||||
}
|
||||
@ -249,7 +249,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
// Returns a const iterator to the end of the array.
|
||||
//*************************************************************************
|
||||
const_iterator cend() const
|
||||
ETL_CONSTEXPR const_iterator cend() const ETL_NOEXCEPT
|
||||
{
|
||||
return &_buffer[SIZE];
|
||||
}
|
||||
@ -257,7 +257,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
// Returns an reverse iterator to the reverse beginning of the array.
|
||||
//*************************************************************************
|
||||
reverse_iterator rbegin()
|
||||
ETL_CONSTEXPR reverse_iterator rbegin() ETL_NOEXCEPT
|
||||
{
|
||||
return reverse_iterator(end());
|
||||
}
|
||||
@ -265,7 +265,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const reverse iterator to the reverse beginning of the array.
|
||||
//*************************************************************************
|
||||
const_reverse_iterator rbegin() const
|
||||
ETL_CONSTEXPR const_reverse_iterator rbegin() const ETL_NOEXCEPT
|
||||
{
|
||||
return const_reverse_iterator(end());
|
||||
}
|
||||
@ -273,7 +273,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const reverse iterator to the reverse beginning of the array.
|
||||
//*************************************************************************
|
||||
const_reverse_iterator crbegin() const
|
||||
ETL_CONSTEXPR const_reverse_iterator crbegin() const ETL_NOEXCEPT
|
||||
{
|
||||
return const_reverse_iterator(end());
|
||||
}
|
||||
@ -281,7 +281,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a reverse iterator to the end of the array.
|
||||
//*************************************************************************
|
||||
reverse_iterator rend()
|
||||
ETL_CONSTEXPR reverse_iterator rend() ETL_NOEXCEPT
|
||||
{
|
||||
return reverse_iterator(begin());
|
||||
}
|
||||
@ -289,7 +289,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const reverse iterator to the end of the array.
|
||||
//*************************************************************************
|
||||
const_reverse_iterator rend() const
|
||||
ETL_CONSTEXPR const_reverse_iterator rend() const ETL_NOEXCEPT
|
||||
{
|
||||
return const_reverse_iterator(begin());
|
||||
}
|
||||
@ -297,7 +297,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const reverse iterator to the end of the array.
|
||||
//*************************************************************************
|
||||
const_reverse_iterator crend() const
|
||||
ETL_CONSTEXPR const_reverse_iterator crend() const ETL_NOEXCEPT
|
||||
{
|
||||
return const_reverse_iterator(begin());
|
||||
}
|
||||
@ -309,7 +309,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns <b>true</b> if the array size is zero.
|
||||
//*************************************************************************
|
||||
bool empty() const
|
||||
ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT
|
||||
{
|
||||
return (SIZE == 0);
|
||||
}
|
||||
@ -317,7 +317,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns the size of the array.
|
||||
//*************************************************************************
|
||||
size_t size() const
|
||||
ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
|
||||
{
|
||||
return SIZE;
|
||||
}
|
||||
@ -325,7 +325,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns the maximum possible size of the array.
|
||||
//*************************************************************************
|
||||
size_t max_size() const
|
||||
ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
|
||||
{
|
||||
return SIZE;
|
||||
}
|
||||
@ -347,7 +347,7 @@ namespace etl
|
||||
/// Swaps the contents of this array and another.
|
||||
///\param other A reference to the other array.
|
||||
//*************************************************************************
|
||||
void swap(array& other)
|
||||
void swap(array& other) ETL_NOEXCEPT
|
||||
{
|
||||
using ETL_OR_STD::swap; // Allow ADL
|
||||
|
||||
@ -552,6 +552,15 @@ namespace etl
|
||||
T _buffer[SIZE];
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
template <typename T, typename... Ts>
|
||||
array(T, Ts...)
|
||||
-> array<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), T>, 1U + sizeof...(Ts)>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Overloaded swap for etl::array<T, SIZE>
|
||||
///\param lhs The first array.
|
||||
@ -670,4 +679,3 @@ namespace etl
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -39,16 +39,13 @@ SOFTWARE.
|
||||
#include "nullptr.h"
|
||||
#include "hash.h"
|
||||
#include "algorithm.h"
|
||||
|
||||
#include "algorithm.h"
|
||||
#include "memory.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
///\defgroup array array
|
||||
/// A wrapper for arrays
|
||||
///\ingroup containers
|
||||
|
||||
#undef ETL_FILE
|
||||
#define ETL_FILE "41"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
//***************************************************************************
|
||||
@ -73,7 +70,7 @@ namespace etl
|
||||
public:
|
||||
|
||||
array_view_bounds(string_type file_name_, numeric_type line_number_)
|
||||
: array_view_exception(ETL_ERROR_TEXT("array_view:bounds", ETL_FILE"A"), file_name_, line_number_)
|
||||
: array_view_exception(ETL_ERROR_TEXT("array_view:bounds", ETL_ARRAY_VIEW_FILE_ID"A"), file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
@ -87,7 +84,7 @@ namespace etl
|
||||
public:
|
||||
|
||||
array_view_uninitialised(string_type file_name_, numeric_type line_number_)
|
||||
: array_view_exception(ETL_ERROR_TEXT("array_view:uninitialised", ETL_FILE"B"), file_name_, line_number_)
|
||||
: array_view_exception(ETL_ERROR_TEXT("array_view:uninitialised", ETL_ARRAY_VIEW_FILE_ID"B"), file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
@ -100,23 +97,31 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef size_t size_type;
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
typedef T* iterator;
|
||||
typedef const T* const_iterator;
|
||||
typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef T value_type;
|
||||
typedef size_t size_type;
|
||||
typedef const T& const_reference;
|
||||
typedef const T* const_pointer;
|
||||
typedef const T* const_iterator;
|
||||
typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
#if defined(ETL_ARRAY_VIEW_IS_MUTABLE)
|
||||
typedef T* pointer;
|
||||
typedef T& reference;
|
||||
typedef T* iterator;
|
||||
typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
|
||||
#else
|
||||
typedef const_pointer pointer;
|
||||
typedef const_reference reference;
|
||||
typedef const_pointer iterator;
|
||||
typedef const_reverse_iterator reverse_iterator;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Default constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR array_view()
|
||||
: mbegin(nullptr),
|
||||
mend(nullptr)
|
||||
: mbegin(ETL_NULLPTR),
|
||||
mend(ETL_NULLPTR)
|
||||
{
|
||||
}
|
||||
|
||||
@ -125,7 +130,7 @@ namespace etl
|
||||
/// data() and size() member functions.
|
||||
//*************************************************************************
|
||||
template <typename TArray>
|
||||
ETL_CONSTEXPR explicit array_view(TArray& a)
|
||||
ETL_CONSTEXPR array_view(TArray& a)
|
||||
: mbegin(a.data()),
|
||||
mend(a.data() + a.size())
|
||||
{
|
||||
@ -155,8 +160,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Construct from C array
|
||||
//*************************************************************************
|
||||
template<const size_t ARRAY_SIZE>
|
||||
ETL_CONSTEXPR explicit array_view(T(&begin_)[ARRAY_SIZE])
|
||||
template<size_t ARRAY_SIZE>
|
||||
ETL_CONSTEXPR array_view(T(&begin_)[ARRAY_SIZE])
|
||||
: mbegin(begin_),
|
||||
mend(begin_ + ARRAY_SIZE)
|
||||
{
|
||||
@ -370,6 +375,7 @@ namespace etl
|
||||
mend = etl::addressof(*begin_) + size_;
|
||||
}
|
||||
|
||||
#if defined(ETL_ARRAY_VIEW_IS_MUTABLE)
|
||||
//*************************************************************************
|
||||
/// Returns a reference to the indexed value.
|
||||
//*************************************************************************
|
||||
@ -377,6 +383,7 @@ namespace etl
|
||||
{
|
||||
return mbegin[i];
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns a const reference to the indexed value.
|
||||
@ -386,22 +393,24 @@ namespace etl
|
||||
return mbegin[i];
|
||||
}
|
||||
|
||||
#if defined(ETL_ARRAY_VIEW_IS_MUTABLE)
|
||||
//*************************************************************************
|
||||
/// Returns a reference to the indexed value.
|
||||
//*************************************************************************
|
||||
reference at(const size_t i)
|
||||
{
|
||||
ETL_ASSERT((mbegin != nullptr && mend != nullptr), ETL_ERROR(array_view_uninitialised));
|
||||
ETL_ASSERT((mbegin != ETL_NULLPTR && mend != ETL_NULLPTR), ETL_ERROR(array_view_uninitialised));
|
||||
ETL_ASSERT(i < size(), ETL_ERROR(array_view_bounds));
|
||||
return mbegin[i];
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns a const reference to the indexed value.
|
||||
//*************************************************************************
|
||||
const_reference at(const size_t i) const
|
||||
{
|
||||
ETL_ASSERT((mbegin != nullptr && mend != nullptr), ETL_ERROR(array_view_uninitialised));
|
||||
ETL_ASSERT((mbegin != ETL_NULLPTR && mend != ETL_NULLPTR), ETL_ERROR(array_view_uninitialised));
|
||||
ETL_ASSERT(i < size(), ETL_ERROR(array_view_bounds));
|
||||
return mbegin[i];
|
||||
}
|
||||
@ -422,7 +431,10 @@ namespace etl
|
||||
//*************************************************************************
|
||||
void remove_prefix(const size_type n)
|
||||
{
|
||||
mbegin += n;
|
||||
if (n < size())
|
||||
mbegin += n;
|
||||
else
|
||||
mbegin = mend;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -430,7 +442,10 @@ namespace etl
|
||||
//*************************************************************************
|
||||
void remove_suffix(const size_type n)
|
||||
{
|
||||
mend -= n;
|
||||
if (n < size())
|
||||
mend -= n;
|
||||
else
|
||||
mend = mbegin;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -484,10 +499,28 @@ namespace etl
|
||||
|
||||
private:
|
||||
|
||||
T* mbegin;
|
||||
T* mend;
|
||||
pointer mbegin;
|
||||
pointer mend;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
template <typename TArray>
|
||||
array_view(TArray& a)
|
||||
-> array_view<typename TArray::value_type>;
|
||||
|
||||
template <typename TIterator>
|
||||
array_view(const TIterator begin_, const TIterator end_)
|
||||
-> array_view<etl::remove_pointer_t<TIterator>>;
|
||||
|
||||
template <typename TIterator,
|
||||
typename TSize>
|
||||
array_view(const TIterator begin_, const TSize size_)
|
||||
-> array_view<etl::remove_pointer_t<TIterator>>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Hash function.
|
||||
//*************************************************************************
|
||||
@ -513,7 +546,4 @@ void swap(etl::array_view<T>& lhs, etl::array_view<T>& rhs)
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
#undef ETL_FILE
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -45,9 +45,6 @@ SOFTWARE.
|
||||
/// A wrapper for arrays
|
||||
///\ingroup containers
|
||||
|
||||
#undef ETL_FILE
|
||||
#define ETL_FILE "42"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
//***************************************************************************
|
||||
@ -72,7 +69,7 @@ namespace etl
|
||||
public:
|
||||
|
||||
array_wrapper_bounds(string_type file_name_, numeric_type line_number_)
|
||||
: array_wrapper_exception(ETL_ERROR_TEXT("array_wrapper:bounds", ETL_FILE"A"), file_name_, line_number_)
|
||||
: array_wrapper_exception(ETL_ERROR_TEXT("array_wrapper:bounds", ETL_ARRAY_WRAPPER_FILE_ID"A"), file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
@ -417,7 +414,5 @@ void swap(etl::array_wrapper<T, SIZE, ARRAYL>& lhs,
|
||||
|
||||
#define ETL_ARRAY_WRAPPER(arraytype, arrayobject) etl::array_wrapper<arraytype, ETL_ARRAY_SIZE(arrayobject), arrayobject>
|
||||
|
||||
#undef ETL_FILE
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ SOFTWARE.
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#if ETL_CPP11_SUPPORTED == 1 && !defined(ETL_NO_STL)
|
||||
#if ETL_CPP11_SUPPORTED && (ETL_USING_STL || defined(ETL_IN_UNIT_TEST))
|
||||
#include "atomic/atomic_std.h"
|
||||
#define ETL_HAS_ATOMIC 1
|
||||
#elif defined(ETL_COMPILER_ARM5)
|
||||
@ -43,8 +43,12 @@ SOFTWARE.
|
||||
#elif defined(ETL_COMPILER_GCC)
|
||||
#include "atomic/atomic_gcc_sync.h"
|
||||
#define ETL_HAS_ATOMIC 1
|
||||
#elif defined(ETL_COMPILER_CLANG)
|
||||
#include "atomic/atomic_clang_sync.h"
|
||||
#define ETL_HAS_ATOMIC 1
|
||||
#else
|
||||
#define ETL_HAS_ATOMIC 0
|
||||
#pragma message ("ETL atomics not supported")
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
34
include/etl/atomic/atomic_clang_sync.h
Normal file
34
include/etl/atomic/atomic_clang_sync.h
Normal file
@ -0,0 +1,34 @@
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2017 jwellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef ETL_ATOMIC_CLANG_INCLUDED
|
||||
#define ETL_ATOMIC_CLANG_INCLUDED
|
||||
|
||||
#include "atomic_gcc_sync.h"
|
||||
|
||||
#endif
|
||||
@ -61,6 +61,9 @@ namespace etl
|
||||
memory_order_seq_cst
|
||||
} memory_order;
|
||||
|
||||
//***************************************************************************
|
||||
/// For all types except bool and pointers
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
class atomic
|
||||
{
|
||||
@ -430,24 +433,27 @@ namespace etl
|
||||
|
||||
private:
|
||||
|
||||
atomic& operator =(const atomic&);
|
||||
atomic& operator =(const atomic&) volatile;
|
||||
atomic& operator =(const atomic&) ETL_DELETE;
|
||||
atomic& operator =(const atomic&) volatile ETL_DELETE;
|
||||
|
||||
mutable volatile T value;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// Specialisation for pointers
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
class atomic<T*>
|
||||
{
|
||||
public:
|
||||
|
||||
atomic()
|
||||
: value(nullptr)
|
||||
: value(0U)
|
||||
{
|
||||
}
|
||||
|
||||
atomic(T* v)
|
||||
: value(v)
|
||||
: value(uintptr_t(v))
|
||||
{
|
||||
}
|
||||
|
||||
@ -540,7 +546,7 @@ namespace etl
|
||||
|
||||
operator T*() volatile const
|
||||
{
|
||||
return __sync_fetch_and_add(&value, 0);
|
||||
return (T*)__sync_fetch_and_add(&value, 0);
|
||||
}
|
||||
|
||||
// Is lock free?
|
||||
@ -557,12 +563,12 @@ namespace etl
|
||||
// Store
|
||||
void store(T* v, etl::memory_order order = etl::memory_order_seq_cst)
|
||||
{
|
||||
__sync_lock_test_and_set(&value, v);
|
||||
__sync_lock_test_and_set(&value, uintptr_t(v));
|
||||
}
|
||||
|
||||
void store(T* v, etl::memory_order order = etl::memory_order_seq_cst) volatile
|
||||
{
|
||||
__sync_lock_test_and_set(&value, v);
|
||||
__sync_lock_test_and_set(&value, uintptr_t(v));
|
||||
}
|
||||
|
||||
// Load
|
||||
@ -573,7 +579,7 @@ namespace etl
|
||||
|
||||
T* load(etl::memory_order order = etl::memory_order_seq_cst) const volatile
|
||||
{
|
||||
return __sync_fetch_and_add(&value, 0);
|
||||
return (T*)__sync_fetch_and_add(&value, 0);
|
||||
}
|
||||
|
||||
// Fetch add
|
||||
@ -601,18 +607,18 @@ namespace etl
|
||||
// Exchange
|
||||
T* exchange(T* v, etl::memory_order order = etl::memory_order_seq_cst)
|
||||
{
|
||||
return (T*)__sync_lock_test_and_set(&value, v);
|
||||
return (T*)__sync_lock_test_and_set(&value, uintptr_t(v));
|
||||
}
|
||||
|
||||
T* exchange(T* v, etl::memory_order order = etl::memory_order_seq_cst) volatile
|
||||
{
|
||||
return (T*)__sync_lock_test_and_set(&value, v);
|
||||
return (T*)__sync_lock_test_and_set(&value, uintptr_t(v));
|
||||
}
|
||||
|
||||
// Compare exchange weak
|
||||
bool compare_exchange_weak(T*& expected, T* desired, etl::memory_order order = etl::memory_order_seq_cst)
|
||||
{
|
||||
T* old = __sync_val_compare_and_swap(&value, expected, desired);
|
||||
T* old = (T*)__sync_val_compare_and_swap(&value, uintptr_t(expected), uintptr_t(desired));
|
||||
|
||||
if (old == expected)
|
||||
{
|
||||
@ -627,7 +633,7 @@ namespace etl
|
||||
|
||||
bool compare_exchange_weak(T*& expected, T* desired, etl::memory_order order = etl::memory_order_seq_cst) volatile
|
||||
{
|
||||
T* old = __sync_val_compare_and_swap(&value, expected, desired);
|
||||
T* old = (T*)__sync_val_compare_and_swap(&value, uintptr_t(expected), uintptr_t(desired));
|
||||
|
||||
if (old == expected)
|
||||
{
|
||||
@ -642,7 +648,7 @@ namespace etl
|
||||
|
||||
bool compare_exchange_weak(T*& expected, T* desired, etl::memory_order success, etl::memory_order failure)
|
||||
{
|
||||
T* old = __sync_val_compare_and_swap(&value, expected, desired);
|
||||
T* old = (T*)__sync_val_compare_and_swap(&value, uintptr_t(expected), uintptr_t(desired));
|
||||
|
||||
if (old == expected)
|
||||
{
|
||||
@ -657,7 +663,7 @@ namespace etl
|
||||
|
||||
bool compare_exchange_weak(T*& expected, T* desired, etl::memory_order success, etl::memory_order failure) volatile
|
||||
{
|
||||
T* old = __sync_val_compare_and_swap(&value, expected, desired);
|
||||
T* old = (T*)__sync_val_compare_and_swap(&value, uintptr_t(expected), uintptr_t(desired));
|
||||
|
||||
if (old == expected)
|
||||
{
|
||||
@ -737,10 +743,10 @@ namespace etl
|
||||
|
||||
private:
|
||||
|
||||
atomic& operator =(const atomic&);
|
||||
atomic& operator =(const atomic&) volatile;
|
||||
atomic& operator =(const atomic&) ETL_DELETE;
|
||||
atomic& operator =(const atomic&) volatile ETL_DELETE;
|
||||
|
||||
mutable volatile T* value;
|
||||
mutable uintptr_t value;
|
||||
};
|
||||
|
||||
typedef etl::atomic<char> atomic_char;
|
||||
@ -757,13 +763,15 @@ namespace etl
|
||||
typedef etl::atomic<wchar_t> atomic_wchar_t;
|
||||
typedef etl::atomic<char16_t> atomic_char16_t;
|
||||
typedef etl::atomic<char32_t> atomic_char32_t;
|
||||
#if ETL_USING_8BIT_TYPES
|
||||
typedef etl::atomic<uint8_t> atomic_uint8_t;
|
||||
typedef etl::atomic<int8_t> atomic_int8_t;
|
||||
#endif
|
||||
typedef etl::atomic<uint16_t> atomic_uint16_t;
|
||||
typedef etl::atomic<int16_t> atomic_int16_t;
|
||||
typedef etl::atomic<uint32_t> atomic_uint32_t;
|
||||
typedef etl::atomic<int32_t> atomic_int32_t;
|
||||
#if !defined(ETL_NO_64BIT_TYPES)
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
typedef etl::atomic<uint64_t> atomic_uint64_t;
|
||||
typedef etl::atomic<int64_t> atomic_int64_t;
|
||||
#endif
|
||||
@ -773,7 +781,7 @@ namespace etl
|
||||
typedef etl::atomic<uint_least16_t> atomic_uint_least16_t;
|
||||
typedef etl::atomic<int_least32_t> atomic_int_least32_t;
|
||||
typedef etl::atomic<uint_least32_t> atomic_uint_least32_t;
|
||||
#if !defined(ETL_NO_64BIT_TYPES)
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
typedef etl::atomic<int_least64_t> atomic_int_least64_t;
|
||||
typedef etl::atomic<uint_least64_t> atomic_uint_least64_t;
|
||||
#endif
|
||||
@ -783,7 +791,7 @@ namespace etl
|
||||
typedef etl::atomic<uint_fast16_t> atomic_uint_fast16_t;
|
||||
typedef etl::atomic<int_fast32_t> atomic_int_fast32_t;
|
||||
typedef etl::atomic<uint_fast32_t> atomic_uint_fast32_t;
|
||||
#if !defined(ETL_NO_64BIT_TYPES)
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
typedef etl::atomic<int_fast64_t> atomic_int_fast64_t;
|
||||
typedef etl::atomic<uint_fast64_t> atomic_uint_fast64_t;
|
||||
#endif
|
||||
|
||||
@ -1,785 +0,0 @@
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2017 jwellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef ETL_ATOMIC_LLVM_SYNC_INCLUDED
|
||||
#define ETL_ATOMIC_LLVM_SYNC_INCLUDED
|
||||
|
||||
//#include "../platform.h"
|
||||
//#include "../type_traits.h"
|
||||
//#include "../static_assert.h"
|
||||
//#include "../nullptr.h"
|
||||
//#include "../char_traits.h"
|
||||
//
|
||||
//#include <stdint.h>
|
||||
//
|
||||
//namespace etl
|
||||
//{
|
||||
// //***************************************************************************
|
||||
// // Atomic type for pre C++11 GCC compilers that support the builtin '__sync' functions.
|
||||
// // Only integral and pointer types are supported.
|
||||
// //***************************************************************************
|
||||
//
|
||||
// typedef enum memory_order
|
||||
// {
|
||||
// memory_order_relaxed,
|
||||
// memory_order_consume,
|
||||
// memory_order_acquire,
|
||||
// memory_order_release,
|
||||
// memory_order_acq_rel,
|
||||
// memory_order_seq_cst
|
||||
// } memory_order;
|
||||
//
|
||||
// template <typename T>
|
||||
// class atomic
|
||||
// {
|
||||
// public:
|
||||
//
|
||||
// ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Only integral types are supported");
|
||||
//
|
||||
// atomic()
|
||||
// : value(0)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// atomic(T v)
|
||||
// : value(v)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// // Assignment
|
||||
// T operator =(T v)
|
||||
// {
|
||||
// store(v);
|
||||
//
|
||||
// return v;
|
||||
// }
|
||||
//
|
||||
// T operator =(T v) volatile
|
||||
// {
|
||||
// store(v);
|
||||
//
|
||||
// return v;
|
||||
// }
|
||||
//
|
||||
// // Pre-increment
|
||||
// T operator ++()
|
||||
// {
|
||||
// return fetch_add(1) + 1;
|
||||
// }
|
||||
//
|
||||
// T operator ++() volatile
|
||||
// {
|
||||
// return fetch_add(1) + 1;
|
||||
// }
|
||||
//
|
||||
// // Post-increment
|
||||
// T operator ++(int)
|
||||
// {
|
||||
// return fetch_add(1);
|
||||
// }
|
||||
//
|
||||
// T operator ++(int) volatile
|
||||
// {
|
||||
// return fetch_add(1);
|
||||
// }
|
||||
//
|
||||
// // Pre-decrement
|
||||
// T operator --()
|
||||
// {
|
||||
// return fetch_sub(1) + 1;
|
||||
// }
|
||||
//
|
||||
// T operator --() volatile
|
||||
// {
|
||||
// return fetch_sub(1) + 1;
|
||||
// }
|
||||
//
|
||||
// // Post-decrement
|
||||
// T operator --(int)
|
||||
// {
|
||||
// return fetch_sub(1);
|
||||
// }
|
||||
//
|
||||
// T operator --(int) volatile
|
||||
// {
|
||||
// return fetch_sub(1);
|
||||
// }
|
||||
//
|
||||
// // Add
|
||||
// T operator +=(T v)
|
||||
// {
|
||||
// return fetch_add(v) + v;
|
||||
// }
|
||||
//
|
||||
// T operator +=(T v) volatile
|
||||
// {
|
||||
// return fetch_add(v) + v;
|
||||
// }
|
||||
//
|
||||
// // Subtract
|
||||
// T operator -=(T v)
|
||||
// {
|
||||
// return fetch_sub(v) - v;
|
||||
// }
|
||||
//
|
||||
// T operator -=(T v) volatile
|
||||
// {
|
||||
// return fetch_sub(v) - v;
|
||||
// }
|
||||
//
|
||||
// // And
|
||||
// T operator &=(T v)
|
||||
// {
|
||||
// return fetch_and(v) & v;
|
||||
// }
|
||||
//
|
||||
// T operator &=(T v) volatile
|
||||
// {
|
||||
// return fetch_and(v) & v;
|
||||
// }
|
||||
//
|
||||
// // Or
|
||||
// T operator |=(T v)
|
||||
// {
|
||||
// return fetch_or(v) | v;
|
||||
// }
|
||||
//
|
||||
// T operator |=(T v) volatile
|
||||
// {
|
||||
// return fetch_or(v) | v;
|
||||
// }
|
||||
//
|
||||
// // Exclusive or
|
||||
// T operator ^=(T v)
|
||||
// {
|
||||
// return fetch_xor(v) ^ v;
|
||||
// }
|
||||
//
|
||||
// T operator ^=(T v) volatile
|
||||
// {
|
||||
// return fetch_xor(v) ^ v;
|
||||
// }
|
||||
//
|
||||
// // Conversion operator
|
||||
// operator T () const
|
||||
// {
|
||||
// return __sync_fetch_and_add(&value, 0);
|
||||
// }
|
||||
//
|
||||
// operator T() volatile const
|
||||
// {
|
||||
// return __sync_fetch_and_add(&value, 0);
|
||||
// }
|
||||
//
|
||||
// // Is lock free?
|
||||
// bool is_lock_free() const
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// bool is_lock_free() const volatile
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// // Store
|
||||
// void store(T v, etl::memory_order order = etl::memory_order_seq_cst)
|
||||
// {
|
||||
// __sync_lock_test_and_set(&value, v);
|
||||
// }
|
||||
//
|
||||
// void store(T v, etl::memory_order order = etl::memory_order_seq_cst) volatile
|
||||
// {
|
||||
// __sync_lock_test_and_set(&value, v);
|
||||
// }
|
||||
//
|
||||
// // Load
|
||||
// T load(etl::memory_order order = etl::memory_order_seq_cst) const
|
||||
// {
|
||||
// return __sync_fetch_and_add(&value, 0);
|
||||
// }
|
||||
//
|
||||
// T load(etl::memory_order order = etl::memory_order_seq_cst) const volatile
|
||||
// {
|
||||
// return __sync_fetch_and_add(&value, 0);
|
||||
// }
|
||||
//
|
||||
// // Fetch add
|
||||
// T fetch_add(T v, etl::memory_order order = etl::memory_order_seq_cst)
|
||||
// {
|
||||
// return __sync_fetch_and_add(&value, v);
|
||||
// }
|
||||
//
|
||||
// T fetch_add(T v, etl::memory_order order = etl::memory_order_seq_cst) volatile
|
||||
// {
|
||||
// return __sync_fetch_and_add(&value, v);
|
||||
// }
|
||||
//
|
||||
// // Fetch subtract
|
||||
// T fetch_sub(T v, etl::memory_order order = etl::memory_order_seq_cst)
|
||||
// {
|
||||
// return __sync_fetch_and_sub(&value, v);
|
||||
// }
|
||||
//
|
||||
// T fetch_sub(T v, etl::memory_order order = etl::memory_order_seq_cst) volatile
|
||||
// {
|
||||
// return __sync_fetch_and_sub(&value, v);
|
||||
// }
|
||||
//
|
||||
// // Fetch or
|
||||
// T fetch_or(T v, etl::memory_order order = etl::memory_order_seq_cst)
|
||||
// {
|
||||
// return __sync_fetch_and_or(&value, v);
|
||||
// }
|
||||
//
|
||||
// T fetch_or(T v, etl::memory_order order = etl::memory_order_seq_cst) volatile
|
||||
// {
|
||||
// return __sync_fetch_and_or(&value, v);
|
||||
// }
|
||||
//
|
||||
// // Fetch and
|
||||
// T fetch_and(T v, etl::memory_order order = etl::memory_order_seq_cst)
|
||||
// {
|
||||
// return __sync_fetch_and_and(&value, v);
|
||||
// }
|
||||
//
|
||||
// T fetch_and(T v, etl::memory_order order = etl::memory_order_seq_cst) volatile
|
||||
// {
|
||||
// return __sync_fetch_and_and(&value, v);
|
||||
// }
|
||||
//
|
||||
// // Fetch exclusive or
|
||||
// T fetch_xor(T v, etl::memory_order order = etl::memory_order_seq_cst)
|
||||
// {
|
||||
// return __sync_fetch_and_xor(&value, v);
|
||||
// }
|
||||
//
|
||||
// T fetch_xor(T v, etl::memory_order order = etl::memory_order_seq_cst) volatile
|
||||
// {
|
||||
// return __sync_fetch_and_xor(&value, v);
|
||||
// }
|
||||
//
|
||||
// // Exchange
|
||||
// T exchange(T v, etl::memory_order order = etl::memory_order_seq_cst)
|
||||
// {
|
||||
// return __sync_lock_test_and_set(&value, v);
|
||||
// }
|
||||
//
|
||||
// T exchange(T v, etl::memory_order order = etl::memory_order_seq_cst) volatile
|
||||
// {
|
||||
// return __sync_lock_test_and_set(&value, v);
|
||||
// }
|
||||
//
|
||||
// // Compare exchange weak
|
||||
// bool compare_exchange_weak(T& expected, T desired, etl::memory_order order = etl::memory_order_seq_cst)
|
||||
// {
|
||||
// T old = __sync_val_compare_and_swap(&value, expected, desired);
|
||||
//
|
||||
// if (old == expected)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// expected = old;
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// bool compare_exchange_weak(T& expected, T desired, etl::memory_order order = etl::memory_order_seq_cst) volatile
|
||||
// {
|
||||
// T old = __sync_val_compare_and_swap(&value, expected, desired);
|
||||
//
|
||||
// if (old == expected)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// expected = old;
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// bool compare_exchange_weak(T& expected, T desired, etl::memory_order success, etl::memory_order failure)
|
||||
// {
|
||||
// T old = __sync_val_compare_and_swap(&value, expected, desired);
|
||||
//
|
||||
// if (old == expected)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// expected = old;
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// bool compare_exchange_weak(T& expected, T desired, etl::memory_order success, etl::memory_order failure) volatile
|
||||
// {
|
||||
// T old = __sync_val_compare_and_swap(&value, expected, desired);
|
||||
//
|
||||
// if (old == expected)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// expected = old;
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Compare exchange strong
|
||||
// bool compare_exchange_strong(T& expected, T desired, etl::memory_order order = etl::memory_order_seq_cst)
|
||||
// {
|
||||
// T old = expected;
|
||||
//
|
||||
// while (!compare_exchange_weak(old, desired))
|
||||
// {
|
||||
// if (memcmp(&old, &expected, sizeof(T)))
|
||||
// {
|
||||
// expected = old;
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// bool compare_exchange_strong(T& expected, T desired, etl::memory_order order = etl::memory_order_seq_cst) volatile
|
||||
// {
|
||||
// T old = expected;
|
||||
//
|
||||
// while (!compare_exchange_weak(old, desired))
|
||||
// {
|
||||
// if (memcmp(&old, &expected, sizeof(T)))
|
||||
// {
|
||||
// expected = old;
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// bool compare_exchange_strong(T& expected, T desired, etl::memory_order success, etl::memory_order failure)
|
||||
// {
|
||||
// T old = expected;
|
||||
//
|
||||
// while (!compare_exchange_weak(old, desired))
|
||||
// {
|
||||
// if (memcmp(&old, &expected, sizeof(T)))
|
||||
// {
|
||||
// expected = old;
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// bool compare_exchange_strong(T& expected, T desired, etl::memory_order success, etl::memory_order failure) volatile
|
||||
// {
|
||||
// T old = expected;
|
||||
//
|
||||
// while (!compare_exchange_weak(old, desired))
|
||||
// {
|
||||
// if (memcmp(&old, &expected, sizeof(T)))
|
||||
// {
|
||||
// expected = old;
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// private:
|
||||
//
|
||||
// atomic& operator =(const atomic&);
|
||||
// atomic& operator =(const atomic&) volatile;
|
||||
//
|
||||
// mutable volatile T value;
|
||||
// };
|
||||
//
|
||||
// template <typename T>
|
||||
// class atomic<T*>
|
||||
// {
|
||||
// public:
|
||||
//
|
||||
// atomic()
|
||||
// : value(nullptr)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// atomic(T* v)
|
||||
// : value(v)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// // Assignment
|
||||
// T* operator =(T* v)
|
||||
// {
|
||||
// store(v);
|
||||
//
|
||||
// return v;
|
||||
// }
|
||||
//
|
||||
// T* operator =(T* v) volatile
|
||||
// {
|
||||
// store(v);
|
||||
//
|
||||
// return v;
|
||||
// }
|
||||
//
|
||||
// // Pre-increment
|
||||
// T* operator ++()
|
||||
// {
|
||||
// return fetch_add(1) + 1;
|
||||
// }
|
||||
//
|
||||
// T* operator ++() volatile
|
||||
// {
|
||||
// return fetch_add(1) + 1;
|
||||
// }
|
||||
//
|
||||
// // Post-increment
|
||||
// T* operator ++(int)
|
||||
// {
|
||||
// return fetch_add(1);
|
||||
// }
|
||||
//
|
||||
// T* operator ++(int) volatile
|
||||
// {
|
||||
// return fetch_add(1);
|
||||
// }
|
||||
//
|
||||
// // Pre-decrement
|
||||
// T* operator --()
|
||||
// {
|
||||
// return fetch_sub(1) + 1;
|
||||
// }
|
||||
//
|
||||
// T* operator --() volatile
|
||||
// {
|
||||
// return fetch_sub(1) + 1;
|
||||
// }
|
||||
//
|
||||
// // Post-decrement
|
||||
// T* operator --(int)
|
||||
// {
|
||||
// return fetch_sub(1);
|
||||
// }
|
||||
//
|
||||
// T* operator --(int) volatile
|
||||
// {
|
||||
// return fetch_sub(1);
|
||||
// }
|
||||
//
|
||||
// // Add
|
||||
// T* operator +=(ptrdiff_t v)
|
||||
// {
|
||||
// return fetch_add(v) + v;
|
||||
// }
|
||||
//
|
||||
// T* operator +=(ptrdiff_t v) volatile
|
||||
// {
|
||||
// return fetch_add(v) + v;
|
||||
// }
|
||||
//
|
||||
// // Subtract
|
||||
// T* operator -=(ptrdiff_t v)
|
||||
// {
|
||||
// return fetch_sub(v) - v;
|
||||
// }
|
||||
//
|
||||
// T* operator -=(ptrdiff_t v) volatile
|
||||
// {
|
||||
// return fetch_sub(v) - v;
|
||||
// }
|
||||
//
|
||||
// // Conversion operator
|
||||
// operator T* () const
|
||||
// {
|
||||
// return __sync_fetch_and_add(&value, 0);
|
||||
// }
|
||||
//
|
||||
// operator T*() volatile const
|
||||
// {
|
||||
// return __sync_fetch_and_add(&value, 0);
|
||||
// }
|
||||
//
|
||||
// // Is lock free?
|
||||
// bool is_lock_free() const
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// bool is_lock_free() const volatile
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// // Store
|
||||
// void store(T* v, etl::memory_order order = etl::memory_order_seq_cst)
|
||||
// {
|
||||
// __sync_lock_test_and_set(&value, v);
|
||||
// }
|
||||
//
|
||||
// void store(T* v, etl::memory_order order = etl::memory_order_seq_cst) volatile
|
||||
// {
|
||||
// __sync_lock_test_and_set(&value, v);
|
||||
// }
|
||||
//
|
||||
// // Load
|
||||
// T* load(etl::memory_order order = etl::memory_order_seq_cst) const
|
||||
// {
|
||||
// return __sync_fetch_and_add(&value, 0);
|
||||
// }
|
||||
//
|
||||
// T* load(etl::memory_order order = etl::memory_order_seq_cst) const volatile
|
||||
// {
|
||||
// return __sync_fetch_and_add(&value, 0);
|
||||
// }
|
||||
//
|
||||
// // Fetch add
|
||||
// T* fetch_add(ptrdiff_t v, etl::memory_order order = etl::memory_order_seq_cst)
|
||||
// {
|
||||
// return __sync_fetch_and_add(&value, v);
|
||||
// }
|
||||
//
|
||||
// T* fetch_add(ptrdiff_t v, etl::memory_order order = etl::memory_order_seq_cst) volatile
|
||||
// {
|
||||
// return __sync_fetch_and_add(&value, v);
|
||||
// }
|
||||
//
|
||||
// // Fetch subtract
|
||||
// T* fetch_sub(ptrdiff_t v, etl::memory_order order = etl::memory_order_seq_cst)
|
||||
// {
|
||||
// return __sync_fetch_and_sub(&value, v);
|
||||
// }
|
||||
//
|
||||
// T* fetch_sub(ptrdiff_t v, etl::memory_order order = etl::memory_order_seq_cst) volatile
|
||||
// {
|
||||
// return __sync_fetch_and_sub(&value, v);
|
||||
// }
|
||||
//
|
||||
// // Exchange
|
||||
// T* exchange(T* v, etl::memory_order order = etl::memory_order_seq_cst)
|
||||
// {
|
||||
// return __sync_lock_test_and_set(&value, v);
|
||||
// }
|
||||
//
|
||||
// T* exchange(T* v, etl::memory_order order = etl::memory_order_seq_cst) volatile
|
||||
// {
|
||||
// return __sync_lock_test_and_set(&value, v);
|
||||
// }
|
||||
//
|
||||
// // Compare exchange weak
|
||||
// bool compare_exchange_weak(T*& expected, T* desired, etl::memory_order order = etl::memory_order_seq_cst)
|
||||
// {
|
||||
// T* old = __sync_val_compare_and_swap(&value, expected, desired);
|
||||
//
|
||||
// if (old == expected)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// expected = old;
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// bool compare_exchange_weak(T*& expected, T* desired, etl::memory_order order = etl::memory_order_seq_cst) volatile
|
||||
// {
|
||||
// T* old = __sync_val_compare_and_swap(&value, expected, desired);
|
||||
//
|
||||
// if (old == expected)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// expected = old;
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// bool compare_exchange_weak(T*& expected, T* desired, etl::memory_order success, etl::memory_order failure)
|
||||
// {
|
||||
// T* old = __sync_val_compare_and_swap(&value, expected, desired);
|
||||
//
|
||||
// if (old == expected)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// expected = old;
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// bool compare_exchange_weak(T*& expected, T* desired, etl::memory_order success, etl::memory_order failure) volatile
|
||||
// {
|
||||
// T* old = __sync_val_compare_and_swap(&value, expected, desired);
|
||||
//
|
||||
// if (old == expected)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// expected = old;
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Compare exchange strong
|
||||
// bool compare_exchange_strong(T*& expected, T* desired, etl::memory_order order = etl::memory_order_seq_cst)
|
||||
// {
|
||||
// T* old = expected;
|
||||
//
|
||||
// while (!compare_exchange_weak(old, desired))
|
||||
// {
|
||||
// if (memcmp(&old, &expected, sizeof(T*)))
|
||||
// {
|
||||
// expected = old;
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// bool compare_exchange_strong(T*& expected, T* desired, etl::memory_order order = etl::memory_order_seq_cst) volatile
|
||||
// {
|
||||
// T* old = expected;
|
||||
//
|
||||
// while (!compare_exchange_weak(old, desired))
|
||||
// {
|
||||
// if (memcmp(&old, &expected, sizeof(T*)))
|
||||
// {
|
||||
// expected = old;
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// bool compare_exchange_strong(T*& expected, T* desired, etl::memory_order success, etl::memory_order failure)
|
||||
// {
|
||||
// T* old = expected;
|
||||
//
|
||||
// while (!compare_exchange_weak(old, desired))
|
||||
// {
|
||||
// if (memcmp(&old, &expected, sizeof(T*)))
|
||||
// {
|
||||
// expected = old;
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// bool compare_exchange_strong(T*& expected, T* desired, etl::memory_order success, etl::memory_order failure) volatile
|
||||
// {
|
||||
// T* old = expected;
|
||||
//
|
||||
// while (!compare_exchange_weak(old, desired))
|
||||
// {
|
||||
// if (memcmp(&old, &expected, sizeof(T*)))
|
||||
// {
|
||||
// expected = old;
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// private:
|
||||
//
|
||||
// atomic& operator =(const atomic&);
|
||||
// atomic& operator =(const atomic&) volatile;
|
||||
//
|
||||
// mutable volatile T* value;
|
||||
// };
|
||||
//
|
||||
// typedef etl::atomic<char> atomic_char;
|
||||
// typedef etl::atomic<signed char> atomic_schar;
|
||||
// typedef etl::atomic<unsigned char> atomic_uchar;
|
||||
// typedef etl::atomic<short> atomic_short;
|
||||
// typedef etl::atomic<unsigned short> atomic_ushort;
|
||||
// typedef etl::atomic<int> atomic_int;
|
||||
// typedef etl::atomic<unsigned int> atomic_uint;
|
||||
// typedef etl::atomic<long> atomic_long;
|
||||
// typedef etl::atomic<unsigned long> atomic_ulong;
|
||||
// typedef etl::atomic<long long> atomic_llong;
|
||||
// typedef etl::atomic<unsigned long long> atomic_ullong;
|
||||
// typedef etl::atomic<wchar_t> atomic_wchar_t;
|
||||
// typedef etl::atomic<char16_t> atomic_char16_t;
|
||||
// typedef etl::atomic<char32_t> atomic_char32_t;
|
||||
// typedef etl::atomic<uint8_t> atomic_uint8_t;
|
||||
// typedef etl::atomic<int8_t> atomic_int8_t;
|
||||
// typedef etl::atomic<uint16_t> atomic_uint16_t;
|
||||
// typedef etl::atomic<int16_t> atomic_int16_t;
|
||||
// typedef etl::atomic<uint32_t> atomic_uint32_t;
|
||||
// typedef etl::atomic<int32_t> atomic_int32_t;
|
||||
// typedef etl::atomic<uint64_t> atomic_uint64_t;
|
||||
// typedef etl::atomic<int64_t> atomic_int64_t;
|
||||
// typedef etl::atomic<int_least8_t> atomic_int_least8_t;
|
||||
// typedef etl::atomic<uint_least8_t> atomic_uint_least8_t;
|
||||
// typedef etl::atomic<int_least16_t> atomic_int_least16_t;
|
||||
// typedef etl::atomic<uint_least16_t> atomic_uint_least16_t;
|
||||
// typedef etl::atomic<int_least32_t> atomic_int_least32_t;
|
||||
// typedef etl::atomic<uint_least32_t> atomic_uint_least32_t;
|
||||
// typedef etl::atomic<int_least64_t> atomic_int_least64_t;
|
||||
// typedef etl::atomic<uint_least64_t> atomic_uint_least64_t;
|
||||
// typedef etl::atomic<int_fast8_t> atomic_int_fast8_t;
|
||||
// typedef etl::atomic<uint_fast8_t> atomic_uint_fast8_t;
|
||||
// typedef etl::atomic<int_fast16_t> atomic_int_fast16_t;
|
||||
// typedef etl::atomic<uint_fast16_t> atomic_uint_fast16_t;
|
||||
// typedef etl::atomic<int_fast32_t> atomic_int_fast32_t;
|
||||
// typedef etl::atomic<uint_fast32_t> atomic_uint_fast32_t;
|
||||
// typedef etl::atomic<int_fast64_t> atomic_int_fast64_t;
|
||||
// typedef etl::atomic<uint_fast64_t> atomic_uint_fast64_t;
|
||||
// typedef etl::atomic<intptr_t> atomic_intptr_t;
|
||||
// typedef etl::atomic<uintptr_t> atomic_uintptr_t;
|
||||
// typedef etl::atomic<size_t> atomic_size_t;
|
||||
// typedef etl::atomic<ptrdiff_t> atomic_ptrdiff_t;
|
||||
// typedef etl::atomic<intmax_t> atomic_intmax_t;
|
||||
// typedef etl::atomic<uintmax_t> atomic_uintmax_t;
|
||||
//}
|
||||
|
||||
#endif
|
||||
@ -343,7 +343,7 @@ namespace etl
|
||||
public:
|
||||
|
||||
atomic()
|
||||
: value(nullptr)
|
||||
: value(ETL_NULLPTR)
|
||||
{
|
||||
}
|
||||
|
||||
@ -550,12 +550,13 @@ namespace etl
|
||||
|
||||
private:
|
||||
|
||||
atomic & operator =(const atomic&);
|
||||
//atomic& operator =(const atomic&) volatile;
|
||||
atomic & operator =(const atomic&) ETL_DELETE;
|
||||
atomic& operator =(const atomic&) volatile ETL_DELETE;
|
||||
|
||||
std::atomic<T*> value;
|
||||
};
|
||||
|
||||
typedef std::atomic<bool> atomic_bool;
|
||||
typedef std::atomic<char> atomic_char;
|
||||
typedef std::atomic<signed char> atomic_schar;
|
||||
typedef std::atomic<unsigned char> atomic_uchar;
|
||||
@ -570,13 +571,15 @@ namespace etl
|
||||
typedef std::atomic<wchar_t> atomic_wchar_t;
|
||||
typedef std::atomic<char16_t> atomic_char16_t;
|
||||
typedef std::atomic<char32_t> atomic_char32_t;
|
||||
#if ETL_USING_8BIT_TYPES
|
||||
typedef std::atomic<uint8_t> atomic_uint8_t;
|
||||
typedef std::atomic<int8_t> atomic_int8_t;
|
||||
#endif
|
||||
typedef std::atomic<uint16_t> atomic_uint16_t;
|
||||
typedef std::atomic<int16_t> atomic_int16_t;
|
||||
typedef std::atomic<uint32_t> atomic_uint32_t;
|
||||
typedef std::atomic<int32_t> atomic_int32_t;
|
||||
#if !defined(ETL_NO_64BIT_TYPES)
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
typedef std::atomic<uint64_t> atomic_uint64_t;
|
||||
typedef std::atomic<int64_t> atomic_int64_t;
|
||||
#endif
|
||||
@ -586,7 +589,7 @@ namespace etl
|
||||
typedef std::atomic<uint_least16_t> atomic_uint_least16_t;
|
||||
typedef std::atomic<int_least32_t> atomic_int_least32_t;
|
||||
typedef std::atomic<uint_least32_t> atomic_uint_least32_t;
|
||||
#if !defined(ETL_NO_64BIT_TYPES)
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
typedef std::atomic<int_least64_t> atomic_int_least64_t;
|
||||
typedef std::atomic<uint_least64_t> atomic_uint_least64_t;
|
||||
#endif
|
||||
@ -596,7 +599,7 @@ namespace etl
|
||||
typedef std::atomic<uint_fast16_t> atomic_uint_fast16_t;
|
||||
typedef std::atomic<int_fast32_t> atomic_int_fast32_t;
|
||||
typedef std::atomic<uint_fast32_t> atomic_uint_fast32_t;
|
||||
#if !defined(ETL_NO_64BIT_TYPES)
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
typedef std::atomic<int_fast64_t> atomic_int_fast64_t;
|
||||
typedef std::atomic<uint_fast64_t> atomic_uint_fast64_t;
|
||||
#endif
|
||||
|
||||
@ -39,6 +39,165 @@ SOFTWARE.
|
||||
|
||||
namespace etl
|
||||
{
|
||||
namespace private_basic_format_spec
|
||||
{
|
||||
//*******************************************************
|
||||
// Structures returned by stream formatting manipulators.
|
||||
//*******************************************************
|
||||
struct base_spec
|
||||
{
|
||||
ETL_CONSTEXPR base_spec(uint_least8_t base_)
|
||||
: base(base_)
|
||||
{
|
||||
}
|
||||
|
||||
const uint_least8_t base;
|
||||
};
|
||||
|
||||
//*********************************
|
||||
struct width_spec
|
||||
{
|
||||
ETL_CONSTEXPR width_spec(uint_least8_t width_)
|
||||
: width(width_)
|
||||
{
|
||||
}
|
||||
|
||||
const uint_least8_t width;
|
||||
};
|
||||
|
||||
//*********************************
|
||||
template <typename TChar>
|
||||
struct fill_spec
|
||||
{
|
||||
ETL_CONSTEXPR fill_spec(TChar fill_)
|
||||
: fill(fill_)
|
||||
{
|
||||
}
|
||||
|
||||
const TChar fill;
|
||||
};
|
||||
|
||||
//*********************************
|
||||
struct precision_spec
|
||||
{
|
||||
ETL_CONSTEXPR precision_spec(uint_least8_t precision_)
|
||||
: precision(precision_)
|
||||
{
|
||||
}
|
||||
|
||||
const uint_least8_t precision;
|
||||
};
|
||||
|
||||
//*********************************
|
||||
struct uppercase_spec
|
||||
{
|
||||
ETL_CONSTEXPR uppercase_spec(bool upper_case_)
|
||||
: upper_case(upper_case_)
|
||||
{
|
||||
}
|
||||
|
||||
const bool upper_case;
|
||||
};
|
||||
|
||||
//*********************************
|
||||
struct boolalpha_spec
|
||||
{
|
||||
ETL_CONSTEXPR boolalpha_spec(bool boolalpha_)
|
||||
: boolalpha(boolalpha_)
|
||||
{
|
||||
}
|
||||
|
||||
const bool boolalpha;
|
||||
};
|
||||
|
||||
//*********************************
|
||||
struct showbase_spec
|
||||
{
|
||||
ETL_CONSTEXPR showbase_spec(bool show_base_)
|
||||
: show_base(show_base_)
|
||||
{
|
||||
}
|
||||
|
||||
const bool show_base;
|
||||
};
|
||||
|
||||
//*********************************
|
||||
struct left_spec
|
||||
{
|
||||
};
|
||||
|
||||
//*********************************
|
||||
struct right_spec
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
// Stream formatting manipulators.
|
||||
//***************************************************************************
|
||||
static ETL_CONSTEXPR private_basic_format_spec::base_spec setbase(uint32_t base)
|
||||
{
|
||||
return private_basic_format_spec::base_spec(base);
|
||||
}
|
||||
|
||||
//*********************************
|
||||
static ETL_CONSTEXPR private_basic_format_spec::width_spec setw(uint32_t width)
|
||||
{
|
||||
return private_basic_format_spec::width_spec(width);
|
||||
}
|
||||
|
||||
//*********************************
|
||||
template <typename TChar>
|
||||
static ETL_CONSTEXPR private_basic_format_spec::fill_spec<TChar> setfill(TChar fill)
|
||||
{
|
||||
return private_basic_format_spec::fill_spec<TChar>(fill);
|
||||
}
|
||||
|
||||
//*********************************
|
||||
static ETL_CONSTEXPR private_basic_format_spec::precision_spec setprecision(uint32_t precision)
|
||||
{
|
||||
return private_basic_format_spec::precision_spec(precision);
|
||||
}
|
||||
|
||||
//*********************************
|
||||
static ETL_CONSTANT private_basic_format_spec::base_spec bin = { 2U };
|
||||
|
||||
//*********************************
|
||||
static ETL_CONSTANT private_basic_format_spec::base_spec oct = { 8U };
|
||||
|
||||
//*********************************
|
||||
static ETL_CONSTANT private_basic_format_spec::base_spec dec = { 10U };
|
||||
|
||||
//*********************************
|
||||
static ETL_CONSTANT private_basic_format_spec::base_spec hex = { 16U };
|
||||
|
||||
//*********************************
|
||||
static ETL_CONSTANT private_basic_format_spec::left_spec left;
|
||||
|
||||
//*********************************
|
||||
static ETL_CONSTANT private_basic_format_spec::right_spec right;
|
||||
|
||||
//*********************************
|
||||
static ETL_CONSTANT private_basic_format_spec::boolalpha_spec boolalpha = { true };
|
||||
|
||||
//*********************************
|
||||
static ETL_CONSTANT private_basic_format_spec::boolalpha_spec noboolalpha = { false };
|
||||
|
||||
//*********************************
|
||||
static ETL_CONSTANT private_basic_format_spec::uppercase_spec uppercase = { true };
|
||||
|
||||
//*********************************
|
||||
static ETL_CONSTANT private_basic_format_spec::uppercase_spec nouppercase = { false };
|
||||
|
||||
//*********************************
|
||||
static ETL_CONSTANT private_basic_format_spec::showbase_spec showbase = { true };
|
||||
|
||||
//*********************************
|
||||
static ETL_CONSTANT private_basic_format_spec::showbase_spec noshowbase = { false };
|
||||
|
||||
//***************************************************************************
|
||||
/// basic_format_spec
|
||||
//***************************************************************************
|
||||
template <typename TString>
|
||||
class basic_format_spec
|
||||
{
|
||||
@ -46,29 +205,61 @@ namespace etl
|
||||
|
||||
//***************************************************************************
|
||||
/// Default constructor.
|
||||
/// Sets:-
|
||||
/// Base = 10
|
||||
/// Width = 0
|
||||
/// Upper case (for hex) = true
|
||||
/// Left Justified = false
|
||||
//***************************************************************************
|
||||
basic_format_spec()
|
||||
: base_(10)
|
||||
, width_(0)
|
||||
, precision_(0)
|
||||
, upper_case_(true)
|
||||
ETL_CONSTEXPR basic_format_spec()
|
||||
: base_(10U)
|
||||
, width_(0U)
|
||||
, precision_(0U)
|
||||
, upper_case_(false)
|
||||
, left_justified_(false)
|
||||
, boolalpha_(false)
|
||||
, show_base_(false)
|
||||
, fill_(typename TString::value_type(' '))
|
||||
{
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Cconstructor.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR basic_format_spec(uint_least8_t base__,
|
||||
uint_least8_t width__,
|
||||
uint_least8_t precision__,
|
||||
bool upper_case__,
|
||||
bool left_justified__,
|
||||
bool boolalpha__,
|
||||
bool show_base__,
|
||||
typename TString::value_type fill__)
|
||||
: base_(base__)
|
||||
, width_(width__)
|
||||
, precision_(precision__)
|
||||
, upper_case_(upper_case__)
|
||||
, left_justified_(left_justified__)
|
||||
, boolalpha_(boolalpha__)
|
||||
, show_base_(show_base__)
|
||||
, fill_(fill__)
|
||||
{
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Clears the format spec back to default.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR14 void clear()
|
||||
{
|
||||
base_ = 10U;
|
||||
width_ = 0U;
|
||||
precision_ = 0U;
|
||||
upper_case_ = false;
|
||||
left_justified_ = false;
|
||||
boolalpha_ = false;
|
||||
show_base_ = false;
|
||||
fill_ = typename TString::value_type(' ');
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Sets the base.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
basic_format_spec& base(const uint32_t b)
|
||||
ETL_CONSTEXPR14 basic_format_spec& base(uint32_t b)
|
||||
{
|
||||
base_ = static_cast<uint_least8_t>(b);
|
||||
return *this;
|
||||
@ -78,7 +269,7 @@ namespace etl
|
||||
/// Sets the base to binary.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
basic_format_spec& binary()
|
||||
ETL_CONSTEXPR14 basic_format_spec& binary()
|
||||
{
|
||||
base(2);
|
||||
return *this;
|
||||
@ -88,7 +279,7 @@ namespace etl
|
||||
/// Sets the base to octal.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
basic_format_spec& octal()
|
||||
ETL_CONSTEXPR14 basic_format_spec& octal()
|
||||
{
|
||||
base(8);
|
||||
return *this;
|
||||
@ -98,7 +289,7 @@ namespace etl
|
||||
/// Sets the base to decimal.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
basic_format_spec& decimal()
|
||||
ETL_CONSTEXPR14 basic_format_spec& decimal()
|
||||
{
|
||||
base(10);
|
||||
return *this;
|
||||
@ -108,7 +299,7 @@ namespace etl
|
||||
/// Sets the base to hex.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
basic_format_spec& hex()
|
||||
ETL_CONSTEXPR14 basic_format_spec& hex()
|
||||
{
|
||||
base(16);
|
||||
return *this;
|
||||
@ -117,16 +308,34 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Gets the base.
|
||||
//***************************************************************************
|
||||
uint32_t get_base() const
|
||||
ETL_CONSTEXPR uint32_t get_base() const
|
||||
{
|
||||
return base_;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Sets the show base flag.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR14 basic_format_spec& show_base(bool b)
|
||||
{
|
||||
show_base_ = b;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Gets the show base flag.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR bool is_show_base() const
|
||||
{
|
||||
return show_base_;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Sets the width.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
basic_format_spec& width(const uint32_t w)
|
||||
ETL_CONSTEXPR14 basic_format_spec& width(uint32_t w)
|
||||
{
|
||||
width_ = static_cast<uint_least8_t>(w);
|
||||
return *this;
|
||||
@ -135,7 +344,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Gets the width.
|
||||
//***************************************************************************
|
||||
uint32_t get_width() const
|
||||
ETL_CONSTEXPR uint32_t get_width() const
|
||||
{
|
||||
return width_;
|
||||
}
|
||||
@ -144,16 +353,16 @@ namespace etl
|
||||
/// Sets the precision.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
basic_format_spec& precision(const uint32_t w)
|
||||
ETL_CONSTEXPR14 basic_format_spec& precision(uint32_t p)
|
||||
{
|
||||
precision_ = static_cast<uint_least8_t>(w);
|
||||
precision_ = static_cast<uint_least8_t>(p);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Gets the precision.
|
||||
//***************************************************************************
|
||||
uint32_t get_precision() const
|
||||
ETL_CONSTEXPR uint32_t get_precision() const
|
||||
{
|
||||
return precision_;
|
||||
}
|
||||
@ -162,7 +371,7 @@ namespace etl
|
||||
/// Sets the upper case flag.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
basic_format_spec& upper_case(const bool u)
|
||||
ETL_CONSTEXPR14 basic_format_spec& upper_case(bool u)
|
||||
{
|
||||
upper_case_ = u;
|
||||
return *this;
|
||||
@ -171,7 +380,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Gets the upper case flag.
|
||||
//***************************************************************************
|
||||
bool is_upper_case() const
|
||||
ETL_CONSTEXPR bool is_upper_case() const
|
||||
{
|
||||
return upper_case_;
|
||||
}
|
||||
@ -180,7 +389,7 @@ namespace etl
|
||||
/// Sets the fill character.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
basic_format_spec& fill(const typename TString::value_type c)
|
||||
ETL_CONSTEXPR14 basic_format_spec& fill(typename TString::value_type c)
|
||||
{
|
||||
fill_ = c;
|
||||
return *this;
|
||||
@ -189,7 +398,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Gets the fill character.
|
||||
//***************************************************************************
|
||||
typename TString::value_type get_fill() const
|
||||
ETL_CONSTEXPR typename TString::value_type get_fill() const
|
||||
{
|
||||
return fill_;
|
||||
}
|
||||
@ -198,7 +407,7 @@ namespace etl
|
||||
/// Sets the left justify flag.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
basic_format_spec& left()
|
||||
ETL_CONSTEXPR14 basic_format_spec& left()
|
||||
{
|
||||
left_justified_ = true;
|
||||
return *this;
|
||||
@ -207,7 +416,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Gets the left justify flag.
|
||||
//***************************************************************************
|
||||
bool is_left() const
|
||||
ETL_CONSTEXPR bool is_left() const
|
||||
{
|
||||
return left_justified_;
|
||||
}
|
||||
@ -216,7 +425,7 @@ namespace etl
|
||||
/// Sets the right justify flag.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
basic_format_spec& right()
|
||||
ETL_CONSTEXPR14 basic_format_spec& right()
|
||||
{
|
||||
left_justified_ = false;
|
||||
return *this;
|
||||
@ -225,7 +434,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Gets the right justify flag.
|
||||
//***************************************************************************
|
||||
bool is_right() const
|
||||
ETL_CONSTEXPR bool is_right() const
|
||||
{
|
||||
return !left_justified_;
|
||||
}
|
||||
@ -234,7 +443,7 @@ namespace etl
|
||||
/// Sets the bool alpha flag.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
basic_format_spec& boolalpha(bool b)
|
||||
ETL_CONSTEXPR14 basic_format_spec& boolalpha(bool b)
|
||||
{
|
||||
boolalpha_ = b;
|
||||
return *this;
|
||||
@ -243,11 +452,34 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Gets the boolalpha flag.
|
||||
//***************************************************************************
|
||||
bool is_boolalpha() const
|
||||
ETL_CONSTEXPR bool is_boolalpha() const
|
||||
{
|
||||
return boolalpha_;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Equality operator.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR friend bool operator ==(const basic_format_spec& lhs, const basic_format_spec& rhs)
|
||||
{
|
||||
return (lhs.base_ == rhs.base_) &&
|
||||
(lhs.width_ == rhs.width_) &&
|
||||
(lhs.precision_ == rhs.precision_) &&
|
||||
(lhs.upper_case_ == rhs.upper_case_) &&
|
||||
(lhs.left_justified_ == rhs.left_justified_) &&
|
||||
(lhs.boolalpha_ == rhs.boolalpha_) &&
|
||||
(lhs.show_base_ == rhs.show_base_) &&
|
||||
(lhs.fill_ == rhs.fill_);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Inequality operator.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR friend bool operator !=(const basic_format_spec& lhs, const basic_format_spec& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
uint_least8_t base_;
|
||||
@ -256,6 +488,7 @@ namespace etl
|
||||
bool upper_case_;
|
||||
bool left_justified_;
|
||||
bool boolalpha_;
|
||||
bool show_base_;
|
||||
typename TString::value_type fill_;
|
||||
};
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
269
include/etl/basic_string_stream.h
Normal file
269
include/etl/basic_string_stream.h
Normal file
@ -0,0 +1,269 @@
|
||||
///\file
|
||||
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2020 jwellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef ETL_BASIC_STRING_STREAM_INCLUDED
|
||||
#define ETL_BASIC_STRING_STREAM_INCLUDED
|
||||
|
||||
///\ingroup string
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
template <typename TFormat, typename TIString, typename TStringView>
|
||||
class basic_string_stream
|
||||
{
|
||||
public:
|
||||
|
||||
typedef TFormat format_spec_type;
|
||||
typedef TIString istring_type;
|
||||
typedef typename TIString::value_type value_type;
|
||||
typedef typename TIString::const_pointer const_pointer;
|
||||
|
||||
//*************************************************************************
|
||||
/// Construct from text.
|
||||
//*************************************************************************
|
||||
explicit basic_string_stream(TIString& text_)
|
||||
: text(text_)
|
||||
{
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Construct from text and format spec.
|
||||
//*************************************************************************
|
||||
basic_string_stream(TIString& text_, const TFormat& spec_)
|
||||
: text(text_)
|
||||
, spec(spec_)
|
||||
{
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Set the format spec.
|
||||
//*************************************************************************
|
||||
void set_format(const TFormat& spec_)
|
||||
{
|
||||
spec = spec_;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Get a const reference to the format spec.
|
||||
//*************************************************************************
|
||||
const TFormat& get_format() const
|
||||
{
|
||||
return spec;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Get a reference to the current string.
|
||||
//*************************************************************************
|
||||
TIString& str()
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Get a const reference to the current string.
|
||||
//*************************************************************************
|
||||
const TIString& str() const
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Resets the stream to the supplied string.
|
||||
//*************************************************************************
|
||||
void str(const value_type* p)
|
||||
{
|
||||
text.assign(p);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Resets the stream to the supplied string.
|
||||
//*************************************************************************
|
||||
void str(const TIString& is)
|
||||
{
|
||||
text.assign(is);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Stream operators.
|
||||
//*************************************************************************
|
||||
|
||||
//*********************************
|
||||
/// TFormat
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, const TFormat& spec)
|
||||
{
|
||||
ss.spec = spec;
|
||||
return ss;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
/// etl::base_spec from etl::setbase, etl::bin, etl::oct, etl::dec & etl::hex stream manipulators
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::base_spec spec)
|
||||
{
|
||||
ss.spec.base(spec.base);
|
||||
return ss;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
/// etl::width_spec from etl::setw stream manipulator
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::width_spec spec)
|
||||
{
|
||||
ss.spec.width(spec.width);
|
||||
return ss;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
/// etl::fill_spec from etl::setfill stream manipulator
|
||||
//*********************************
|
||||
template <typename TChar>
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::fill_spec<TChar> spec)
|
||||
{
|
||||
ss.spec.fill(spec.fill);
|
||||
return ss;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
/// etl::precision_spec from etl::setprecision stream manipulator
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::precision_spec spec)
|
||||
{
|
||||
ss.spec.precision(spec.precision);
|
||||
return ss;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
/// etl::boolalpha_spec from etl::boolalpha & etl::noboolalpha stream manipulators
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::boolalpha_spec spec)
|
||||
{
|
||||
ss.spec.boolalpha(spec.boolalpha);
|
||||
return ss;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
/// etl::uppercase_spec from etl::uppercase & etl::nouppercase stream manipulators
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::uppercase_spec spec)
|
||||
{
|
||||
ss.spec.upper_case(spec.upper_case);
|
||||
return ss;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
/// etl::showbase_spec from etl::showbase & etl::noshowbase stream manipulators
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::showbase_spec spec)
|
||||
{
|
||||
ss.spec.show_base(spec.show_base);
|
||||
return ss;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
/// etl::left_spec from etl::left stream manipulator
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::left_spec spec)
|
||||
{
|
||||
ss.spec.left();
|
||||
return ss;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
/// etl::right_spec from etl::left stream manipulator
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::right_spec spec)
|
||||
{
|
||||
ss.spec.right();
|
||||
return ss;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
/// From a string view
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, TStringView view)
|
||||
{
|
||||
etl::to_string(view, ss.text, ss.spec, true);
|
||||
return ss;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
/// From a const pointer to a string
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, const_pointer p)
|
||||
{
|
||||
TStringView view(p);
|
||||
ss << view;
|
||||
return ss;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
/// From a string interface
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, const TIString& text)
|
||||
{
|
||||
etl::to_string(text, ss.text, ss.spec, true);
|
||||
return ss;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
/// From a string
|
||||
//*********************************
|
||||
template <template <size_t> class TString, size_t SIZE>
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, const TString<SIZE>& text)
|
||||
{
|
||||
const TIString& itext = text;
|
||||
etl::to_string(itext, ss.str(), ss.get_format(), true);
|
||||
return ss;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
/// From anything else
|
||||
//*********************************
|
||||
template <typename T>
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, const T& value)
|
||||
{
|
||||
etl::to_string(value, ss.text, ss.spec, true);
|
||||
return ss;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
TIString& text;
|
||||
TFormat spec;
|
||||
|
||||
basic_string_stream(const basic_string_stream&) ETL_DELETE;
|
||||
basic_string_stream& operator =(const basic_string_stream&) ETL_DELETE;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -46,9 +46,6 @@ SOFTWARE.
|
||||
#include "exception.h"
|
||||
#include "error_handler.h"
|
||||
|
||||
#undef ETL_FILE
|
||||
#define ETL_FILE "50"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
//***************************************************************************
|
||||
@ -74,7 +71,7 @@ namespace etl
|
||||
public:
|
||||
|
||||
binary_out_of_range(string_type file_name_, numeric_type line_number_)
|
||||
: etl::binary_exception(ETL_ERROR_TEXT("binary:out of range", ETL_FILE"A"), file_name_, line_number_)
|
||||
: etl::binary_exception(ETL_ERROR_TEXT("binary:out of range", ETL_BINARY_FILE_ID"A"), file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
@ -241,8 +238,7 @@ namespace etl
|
||||
{
|
||||
ETL_STATIC_ASSERT(etl::is_integral<TValue>::value, "TValue not an integral type");
|
||||
ETL_STATIC_ASSERT(etl::is_integral<TReturn>::value, "TReturn not an integral type");
|
||||
ETL_STATIC_ASSERT(etl::is_signed<TReturn>::value, "TReturn not a signed type");
|
||||
ETL_STATIC_ASSERT(NBITS <= etl::numeric_limits<TReturn>::digits, "NBITS too large for return type");
|
||||
ETL_STATIC_ASSERT(NBITS <= etl::integral_limits<TReturn>::bits, "NBITS too large for return type");
|
||||
|
||||
struct S
|
||||
{
|
||||
@ -263,9 +259,8 @@ namespace etl
|
||||
{
|
||||
ETL_STATIC_ASSERT(etl::is_integral<TValue>::value, "TValue not an integral type");
|
||||
ETL_STATIC_ASSERT(etl::is_integral<TReturn>::value, "TReturn not an integral type");
|
||||
ETL_STATIC_ASSERT(etl::is_signed<TReturn>::value, "TReturn not a signed type");
|
||||
ETL_STATIC_ASSERT(NBITS <= etl::numeric_limits<TReturn>::digits, "NBITS too large for return type");
|
||||
ETL_STATIC_ASSERT(SHIFT <= etl::numeric_limits<TReturn>::digits, "SHIFT too large");
|
||||
ETL_STATIC_ASSERT(NBITS <= etl::integral_limits<TReturn>::bits, "NBITS too large for return type");
|
||||
ETL_STATIC_ASSERT(SHIFT <= etl::integral_limits<TReturn>::bits, "SHIFT too large");
|
||||
|
||||
struct S
|
||||
{
|
||||
@ -285,12 +280,11 @@ namespace etl
|
||||
{
|
||||
ETL_STATIC_ASSERT(etl::is_integral<TValue>::value, "TValue not an integral type");
|
||||
ETL_STATIC_ASSERT(etl::is_integral<TReturn>::value, "TReturn not an integral type");
|
||||
ETL_STATIC_ASSERT(etl::is_signed<TReturn>::value, "TReturn not a signed type");
|
||||
|
||||
ETL_ASSERT((NBITS <= etl::numeric_limits<TReturn>::digits), ETL_ERROR(binary_out_of_range));
|
||||
ETL_ASSERT((NBITS <= etl::integral_limits<TReturn>::bits), ETL_ERROR(binary_out_of_range));
|
||||
|
||||
TReturn mask = TReturn(1) << (NBITS - 1);
|
||||
value = value & static_cast<TValue>((TReturn(1) << NBITS) - 1);
|
||||
value = value & TValue((TValue(1) << NBITS) - 1);
|
||||
|
||||
return TReturn((value ^ mask) - mask);
|
||||
}
|
||||
@ -306,12 +300,11 @@ namespace etl
|
||||
{
|
||||
ETL_STATIC_ASSERT(etl::is_integral<TValue>::value, "TValue not an integral type");
|
||||
ETL_STATIC_ASSERT(etl::is_integral<TReturn>::value, "TReturn not an integral type");
|
||||
ETL_STATIC_ASSERT(etl::is_signed<TReturn>::value, "TReturn not a signed type");
|
||||
|
||||
ETL_ASSERT((NBITS <= etl::numeric_limits<TReturn>::digits), ETL_ERROR(binary_out_of_range));
|
||||
ETL_ASSERT((NBITS <= etl::integral_limits<TReturn>::bits), ETL_ERROR(binary_out_of_range));
|
||||
|
||||
TReturn mask = TReturn(1) << (NBITS - 1);
|
||||
value = (value >> SHIFT) & static_cast<TValue>((TReturn(1) << NBITS) - 1);
|
||||
value = (value >> SHIFT) & TValue((TValue(1) << NBITS) - 1);
|
||||
|
||||
return TReturn((value ^ mask) - mask);
|
||||
}
|
||||
@ -390,6 +383,21 @@ namespace etl
|
||||
return TResult(unsigned_v_t(value) * (unsigned_r_t(~unsigned_r_t(0U)) / unsigned_v_t(~unsigned_v_t(0U))));
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Fills a value with a bit pattern. Partial compile time.
|
||||
///\ingroup binary
|
||||
//***************************************************************************
|
||||
template <typename TResult, typename TValue, const TValue N>
|
||||
ETL_CONSTEXPR TResult binary_fill()
|
||||
{
|
||||
ETL_STATIC_ASSERT(sizeof(TResult) >= sizeof(TValue), "Result must be at least as large as the fill value");
|
||||
|
||||
typedef typename etl::make_unsigned<TResult>::type unsigned_r_t;
|
||||
typedef typename etl::make_unsigned<TValue>::type unsigned_v_t;
|
||||
|
||||
return TResult(unsigned_v_t(N) * (unsigned_r_t(~unsigned_r_t(0U)) / unsigned_v_t(~unsigned_v_t(0U))));
|
||||
}
|
||||
|
||||
#if ETL_8BIT_SUPPORT
|
||||
//***************************************************************************
|
||||
/// Detects the presence of zero bytes.
|
||||
@ -405,6 +413,20 @@ namespace etl
|
||||
return (temp != 0U);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Detects the presence of zero bytes. Partial compile time.
|
||||
///\ingroup binary
|
||||
//***************************************************************************
|
||||
template <typename TValue, const TValue N>
|
||||
ETL_CONSTEXPR14 bool has_zero_byte()
|
||||
{
|
||||
typedef typename etl::make_unsigned<TValue>::type unsigned_t;
|
||||
const unsigned_t mask = etl::binary_fill<unsigned_t, uint8_t>(0x7FU);
|
||||
const unsigned_t temp = unsigned_t(~((((unsigned_t(N) & mask) + mask) | unsigned_t(N)) | mask));
|
||||
|
||||
return (temp != 0U);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Detects the presence of a byte of value N. Run time.
|
||||
///\ingroup binary
|
||||
@ -416,7 +438,7 @@ namespace etl
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Detects the presence of a byte of value N. Partial time.
|
||||
/// Detects the presence of a byte of value N. Partial compile time.
|
||||
///\ingroup binary
|
||||
//***************************************************************************
|
||||
template <typename TValue, const TValue N>
|
||||
@ -509,7 +531,7 @@ namespace etl
|
||||
return int32_t(reverse_bits(uint32_t(value)));
|
||||
}
|
||||
|
||||
#if !defined(ETL_NO_64BIT_TYPES)
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
//***************************************************************************
|
||||
/// Reverse 64 bits.
|
||||
///\ingroup binary
|
||||
@ -579,7 +601,7 @@ namespace etl
|
||||
return int32_t(reverse_bytes(uint32_t(value)));
|
||||
}
|
||||
|
||||
#if !defined(ETL_NO_64BIT_TYPES)
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
//***************************************************************************
|
||||
/// Reverse bytes 64 bit.
|
||||
///\ingroup binary
|
||||
@ -658,7 +680,7 @@ namespace etl
|
||||
return int32_t(gray_to_binary(uint32_t(value)));
|
||||
}
|
||||
|
||||
#if !defined(ETL_NO_64BIT_TYPES)
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
//***************************************************************************
|
||||
/// Converts Gray code to binary.
|
||||
///\ingroup binary
|
||||
@ -747,7 +769,7 @@ namespace etl
|
||||
return count_bits(uint32_t(value));
|
||||
}
|
||||
|
||||
#if !defined(ETL_NO_64BIT_TYPES)
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
//***************************************************************************
|
||||
/// Count set bits. 64 bits.
|
||||
///\ingroup binary
|
||||
@ -825,7 +847,7 @@ namespace etl
|
||||
return parity(uint32_t(value));
|
||||
}
|
||||
|
||||
#if !defined(ETL_NO_64BIT_TYPES)
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
//***************************************************************************
|
||||
/// Parity. 64bits. 0 = even, 1 = odd
|
||||
///\ingroup binary
|
||||
@ -986,7 +1008,7 @@ namespace etl
|
||||
return count_trailing_zeros(uint32_t(value));
|
||||
}
|
||||
|
||||
#if !defined(ETL_NO_64BIT_TYPES)
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
//***************************************************************************
|
||||
/// Count trailing zeros. 64bit.
|
||||
/// Uses a binary search.
|
||||
@ -1100,7 +1122,7 @@ namespace etl
|
||||
return int32_t(binary_interleave(uint16_t(first), uint16_t(second)));
|
||||
}
|
||||
|
||||
#if !defined(ETL_NO_64BIT_TYPES)
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
//*****************************************************************************
|
||||
/// Binary interleave
|
||||
///\ingroup binary
|
||||
@ -1459,6 +1481,4 @@ namespace etl
|
||||
};
|
||||
}
|
||||
|
||||
#undef ETL_FILE
|
||||
|
||||
#endif
|
||||
|
||||
@ -29,14 +29,14 @@ SOFTWARE.
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "etl/platform.h"
|
||||
#include "etl/type_traits.h"
|
||||
#include "etl/nullptr.h"
|
||||
#include "etl/endianness.h"
|
||||
#include "etl/integral_limits.h"
|
||||
#include "etl/binary.h"
|
||||
#include "etl/algorithm.h"
|
||||
#include "etl/iterator.h"
|
||||
#include "platform.h"
|
||||
#include "type_traits.h"
|
||||
#include "nullptr.h"
|
||||
#include "endianness.h"
|
||||
#include "integral_limits.h"
|
||||
#include "binary.h"
|
||||
#include "algorithm.h"
|
||||
#include "iterator.h"
|
||||
|
||||
#include "private/minmax_push.h"
|
||||
|
||||
@ -56,7 +56,7 @@ namespace etl
|
||||
/// Default constructor.
|
||||
//***************************************************************************
|
||||
bit_stream()
|
||||
: pdata(nullptr),
|
||||
: pdata(ETL_NULLPTR),
|
||||
length(0U)
|
||||
{
|
||||
restart();
|
||||
@ -163,7 +163,7 @@ namespace etl
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
if (pdata != nullptr)
|
||||
if (pdata != ETL_NULLPTR)
|
||||
{
|
||||
if (bits_remaining > 0)
|
||||
{
|
||||
@ -186,7 +186,7 @@ namespace etl
|
||||
return put_integral(static_cast<uint32_t>(value), width);
|
||||
}
|
||||
|
||||
#if !defined(ETL_NO_64BIT_TYPES)
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
//***************************************************************************
|
||||
/// For 64bit integral types
|
||||
//***************************************************************************
|
||||
@ -234,7 +234,7 @@ namespace etl
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
if (pdata != nullptr)
|
||||
if (pdata != ETL_NULLPTR)
|
||||
{
|
||||
// Do we have enough bits?
|
||||
if (bits_remaining > 0)
|
||||
@ -257,7 +257,7 @@ namespace etl
|
||||
bool success = false;
|
||||
uint_least8_t bits = width;
|
||||
|
||||
if (pdata != nullptr)
|
||||
if (pdata != ETL_NULLPTR)
|
||||
{
|
||||
// Do we have enough bits?
|
||||
if (bits_remaining >= width)
|
||||
@ -297,7 +297,7 @@ namespace etl
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
if (pdata != nullptr)
|
||||
if (pdata != ETL_NULLPTR)
|
||||
{
|
||||
uint_least8_t width = CHAR_BIT * sizeof(T);
|
||||
|
||||
@ -314,8 +314,6 @@ namespace etl
|
||||
|
||||
from_bytes(data, value);
|
||||
|
||||
bits_remaining -= width;
|
||||
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
@ -372,7 +370,7 @@ namespace etl
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
if (pdata != nullptr)
|
||||
if (pdata != ETL_NULLPTR)
|
||||
{
|
||||
// Do we have enough bits?
|
||||
if (bits_remaining >= width)
|
||||
@ -398,7 +396,7 @@ namespace etl
|
||||
return success;
|
||||
}
|
||||
|
||||
#if !defined(ETL_NO_64BIT_TYPES)
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
//***************************************************************************
|
||||
/// For unsigned integral types. 64bit
|
||||
//***************************************************************************
|
||||
@ -406,7 +404,7 @@ namespace etl
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
if (pdata != nullptr)
|
||||
if (pdata != ETL_NULLPTR)
|
||||
{
|
||||
// Do we have enough bits?
|
||||
if (bits_remaining >= width)
|
||||
|
||||
@ -5,7 +5,7 @@ The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
http://www.etlcpp.com
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2014 jwellbelove
|
||||
|
||||
@ -50,12 +50,10 @@ SOFTWARE.
|
||||
#include "char_traits.h"
|
||||
#include "static_assert.h"
|
||||
#include "error_handler.h"
|
||||
#include "span.h"
|
||||
|
||||
#include "private/minmax_push.h"
|
||||
|
||||
#undef ETL_FILE
|
||||
#define ETL_FILE "52"
|
||||
|
||||
#if defined(ETL_COMPILER_KEIL)
|
||||
#pragma diag_suppress 1300
|
||||
#endif
|
||||
@ -83,7 +81,7 @@ namespace etl
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// Bitset nullptr exception.
|
||||
/// Bitset null pointer exception.
|
||||
///\ingroup bitset
|
||||
//***************************************************************************
|
||||
class bitset_nullptr : public bitset_exception
|
||||
@ -91,7 +89,7 @@ namespace etl
|
||||
public:
|
||||
|
||||
bitset_nullptr(string_type file_name_, numeric_type line_number_)
|
||||
: bitset_exception(ETL_ERROR_TEXT("bitset:nullptr", ETL_FILE"A"), file_name_, line_number_)
|
||||
: bitset_exception(ETL_ERROR_TEXT("bitset:null pointer", ETL_BITSET_FILE_ID"A"), file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
@ -105,7 +103,7 @@ namespace etl
|
||||
public:
|
||||
|
||||
bitset_type_too_small(string_type file_name_, numeric_type line_number_)
|
||||
: bitset_exception(ETL_ERROR_TEXT("bitset:type_too_small", ETL_FILE"B"), file_name_, line_number_)
|
||||
: bitset_exception(ETL_ERROR_TEXT("bitset:type_too_small", ETL_BITSET_FILE_ID"B"), file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
@ -132,6 +130,9 @@ namespace etl
|
||||
|
||||
static const size_t BITS_PER_ELEMENT = etl::integral_limits<element_t>::bits;
|
||||
|
||||
typedef etl::span<element_t> span_type;
|
||||
typedef etl::span<const element_t> const_span_type;
|
||||
|
||||
enum
|
||||
{
|
||||
npos = etl::integral_limits<size_t>::max
|
||||
@ -195,7 +196,7 @@ namespace etl
|
||||
/// Default constructor.
|
||||
//*******************************
|
||||
bit_reference()
|
||||
: p_bitset(nullptr),
|
||||
: p_bitset(ETL_NULLPTR),
|
||||
position(0)
|
||||
{
|
||||
}
|
||||
@ -585,7 +586,7 @@ namespace etl
|
||||
|
||||
// Needs checking?
|
||||
if ((state && (value != ALL_CLEAR)) ||
|
||||
(!state && (value != ALL_SET)))
|
||||
(!state && (value != ALL_SET)))
|
||||
{
|
||||
// For each bit in the element...
|
||||
while ((bit < BITS_PER_ELEMENT) && (position < NBITS))
|
||||
@ -604,7 +605,7 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
position += BITS_PER_ELEMENT;
|
||||
position += (BITS_PER_ELEMENT - bit);
|
||||
}
|
||||
|
||||
// Start at the beginning for all other elements.
|
||||
@ -749,6 +750,24 @@ namespace etl
|
||||
etl::swap_ranges(pdata, pdata + SIZE, other.pdata);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// span
|
||||
/// Returns a span of the underlying data.
|
||||
//*************************************************************************
|
||||
span_type span()
|
||||
{
|
||||
return span_type(pdata, pdata + SIZE);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// span
|
||||
/// Returns a const span of the underlying data.
|
||||
//*************************************************************************
|
||||
const_span_type span() const
|
||||
{
|
||||
return const_span_type(pdata, pdata + SIZE);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
//*************************************************************************
|
||||
@ -852,7 +871,7 @@ namespace etl
|
||||
/// The class emulates an array of bool elements, but optimized for space allocation.
|
||||
/// Will accommodate any number of bits.
|
||||
/// Does not use std::string.
|
||||
///\tparam N The number of bits.
|
||||
///\tparam MAXN The number of bits.
|
||||
///\ingroup bitset
|
||||
//*************************************************************************
|
||||
template <const size_t MAXN>
|
||||
@ -1185,6 +1204,4 @@ void swap(etl::bitset<MAXN>& lhs, etl::bitset<MAXN>& rhs)
|
||||
|
||||
#include "private/minmax_pop.h"
|
||||
|
||||
#undef ETL_FILE
|
||||
|
||||
#endif
|
||||
|
||||
@ -5,7 +5,7 @@ The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
http://www.etlcpp.com
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2014 jwellbelove
|
||||
|
||||
|
||||
361
include/etl/bresenham_line.h
Normal file
361
include/etl/bresenham_line.h
Normal file
@ -0,0 +1,361 @@
|
||||
///\file
|
||||
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2020 jwellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef ETL_BRESENHAM_LINE_INCLUDED
|
||||
#define ETL_BRESENHAM_LINE_INCLUDED
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "iterator.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
#include "utility.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
//***************************************************************************
|
||||
/// A pseudo-container that generates points on a line, using Bresenham's
|
||||
/// line algorithm.
|
||||
/// T is the type for the etl::coordinate_2d value type.
|
||||
/// TWork is the internal working variable type. Default is int16_t.
|
||||
//***************************************************************************
|
||||
template <typename T, typename TWork = int16_t>
|
||||
class bresenham_line
|
||||
{
|
||||
public:
|
||||
|
||||
//***************************************************
|
||||
/// Standard container types.
|
||||
//***************************************************
|
||||
typedef etl::coordinate_2d<T> value_type;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
|
||||
//***************************************************
|
||||
/// Const Iterator
|
||||
//***************************************************
|
||||
class const_iterator : public etl::iterator<ETL_OR_STD::forward_iterator_tag, const value_type>
|
||||
{
|
||||
public:
|
||||
|
||||
friend class bresenham_line;
|
||||
|
||||
//***************************************************
|
||||
/// Default constructor
|
||||
//***************************************************
|
||||
const_iterator()
|
||||
: p_bresenham_line(ETL_NULLPTR)
|
||||
{
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Copy constuctor
|
||||
//***************************************************
|
||||
const_iterator(const const_iterator& other)
|
||||
: p_bresenham_line(other.p_bresenham_line)
|
||||
{
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Assignment operator
|
||||
//***************************************************
|
||||
const_iterator& operator =(const const_iterator& rhs)
|
||||
{
|
||||
p_bresenham_line = rhs.p_bresenham_line;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Pre-increment operator
|
||||
//***************************************************
|
||||
const_iterator& operator ++()
|
||||
{
|
||||
// Has the end of the series has been reached?
|
||||
if (p_bresenham_line->get_coordinate() == p_bresenham_line->back())
|
||||
{
|
||||
// Mark it as an end iterator.
|
||||
p_bresenham_line = ETL_NULLPTR;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_bresenham_line->next();
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// De-reference operator
|
||||
//***************************************************
|
||||
value_type operator *() const
|
||||
{
|
||||
return p_bresenham_line->get_coordinate();
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Equality operator
|
||||
//***************************************************
|
||||
friend bool operator ==(const const_iterator& lhs, const const_iterator& rhs)
|
||||
{
|
||||
return lhs.p_bresenham_line == rhs.p_bresenham_line;
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Inequality operator
|
||||
//***************************************************
|
||||
friend bool operator !=(const const_iterator& lhs, const const_iterator& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//***************************************************
|
||||
/// Constructor for use by bresenham_line
|
||||
//***************************************************
|
||||
const_iterator(bresenham_line<T>* pb)
|
||||
: p_bresenham_line(pb)
|
||||
{
|
||||
}
|
||||
|
||||
bresenham_line<T>* p_bresenham_line;
|
||||
};
|
||||
|
||||
//***************************************************
|
||||
/// Constructor.
|
||||
//***************************************************
|
||||
bresenham_line()
|
||||
{
|
||||
initialise(T(0), T(0), T(0), T(0));
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Constructor.
|
||||
/// Supplied first and last coordinates
|
||||
//***************************************************
|
||||
bresenham_line(etl::coordinate_2d<T> first_, etl::coordinate_2d<T> last_)
|
||||
{
|
||||
initialise(first_.x, first_.y, last_.x, last_.y);
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Constructor.
|
||||
/// Supplied first and last coordinates
|
||||
//***************************************************
|
||||
bresenham_line(T first_x, T first_y, T last_x, T last_y)
|
||||
{
|
||||
initialise(first_x, first_y, last_x, last_y);
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Resets the line.
|
||||
/// Supplied first and last coordinates
|
||||
//***************************************************
|
||||
void reset(etl::coordinate_2d<T> first_, etl::coordinate_2d<T> last_)
|
||||
{
|
||||
initialise(first_.x, first_.y, last_.x, last_.y);
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Resets the line.
|
||||
/// Supplied first and last coordinates
|
||||
//***************************************************
|
||||
void reset(T first_x, T first_y, T last_x, T last_y)
|
||||
{
|
||||
initialise(first_x, first_y, last_x, last_y);
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Get a const_iterator to the first coordinate.
|
||||
/// Resets the Bresenham line.
|
||||
//***************************************************
|
||||
const_iterator begin()
|
||||
{
|
||||
coordinate = first;
|
||||
|
||||
return const_iterator(this);
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Get a const_iterator to one past the last coordinate.
|
||||
//***************************************************
|
||||
const_iterator end() const
|
||||
{
|
||||
return const_iterator();
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Get the first coordinate.
|
||||
//***************************************************
|
||||
const_reference front() const
|
||||
{
|
||||
return first;
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Get the last coordinate.
|
||||
//***************************************************
|
||||
const_reference back() const
|
||||
{
|
||||
return last;
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Get the size of the series.
|
||||
//***************************************************
|
||||
size_t size() const
|
||||
{
|
||||
if (y_is_major_axis())
|
||||
{
|
||||
return (dy / 2) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (dx / 2) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Equality operator
|
||||
//***************************************************
|
||||
friend bool operator ==(const bresenham_line& lhs, const bresenham_line& rhs)
|
||||
{
|
||||
return (lhs.front() == rhs.front()) && (lhs.back() == rhs.back());
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Inequality operator
|
||||
//***************************************************
|
||||
friend bool operator !=(const bresenham_line& lhs, const bresenham_line& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//***************************************************
|
||||
/// Get the current number of generated points.
|
||||
//***************************************************
|
||||
void initialise(T first_x, T first_y, T last_x, T last_y)
|
||||
{
|
||||
first = value_type(first_x, first_y);
|
||||
last = value_type(last_x, last_y);
|
||||
coordinate = first;
|
||||
x_increment = (last_x < first_x) ? -1 : 1;
|
||||
y_increment = (last_y < first_y) ? -1 : 1;
|
||||
dx = (last_x < first_x) ? first_x - last_x : last_x - first_x;
|
||||
dy = (last_y < first_y) ? first_y - last_y : last_y - first_y;
|
||||
do_minor_increment = false;
|
||||
|
||||
if (y_is_major_axis())
|
||||
{
|
||||
dx *= 2;
|
||||
balance = dx - dy;
|
||||
dy *= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
dy *= 2;
|
||||
balance = dy - dx;
|
||||
dx *= 2;
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Returns true if Y is the major axis.
|
||||
//***************************************************
|
||||
bool y_is_major_axis() const
|
||||
{
|
||||
return dx < dy;
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Calculate the next point.
|
||||
//***************************************************
|
||||
void next()
|
||||
{
|
||||
if (y_is_major_axis())
|
||||
{
|
||||
// Y is major axis.
|
||||
if (do_minor_increment)
|
||||
{
|
||||
coordinate.x = T(coordinate.x + x_increment);
|
||||
balance -= dy;
|
||||
}
|
||||
|
||||
coordinate.y = T(coordinate.y + y_increment);
|
||||
balance += dx;
|
||||
}
|
||||
else
|
||||
{
|
||||
// X is major axis.
|
||||
if (do_minor_increment)
|
||||
{
|
||||
coordinate.y = T(coordinate.y + y_increment);
|
||||
balance -= dx;
|
||||
}
|
||||
|
||||
coordinate.x = T(coordinate.x + x_increment);
|
||||
balance += dy;
|
||||
}
|
||||
|
||||
do_minor_increment = (balance >= 0);
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Get the current coordinate.
|
||||
//***************************************************
|
||||
value_type get_coordinate() const
|
||||
{
|
||||
return coordinate;
|
||||
}
|
||||
|
||||
typedef TWork work_t;
|
||||
|
||||
value_type first;
|
||||
value_type last;
|
||||
value_type coordinate;
|
||||
work_t x_increment;
|
||||
work_t y_increment;
|
||||
work_t dx;
|
||||
work_t dy;
|
||||
work_t balance;
|
||||
bool do_minor_increment;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
293
include/etl/buffer_descriptors.h
Normal file
293
include/etl/buffer_descriptors.h
Normal file
@ -0,0 +1,293 @@
|
||||
///\file
|
||||
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2020 jwellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef ETL_BUFFER_DESCRIPTORS_INCLUDED
|
||||
#define ETL_BUFFER_DESCRIPTORS_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "array.h"
|
||||
#include "delegate.h"
|
||||
#include "type_traits.h"
|
||||
#include "static_assert.h"
|
||||
#include "cyclic_value.h"
|
||||
#include "algorithm.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
//***************************************************************************
|
||||
/// buffer_descriptors
|
||||
//***************************************************************************
|
||||
template <typename TBuffer, size_t BUFFER_SIZE_, size_t N_BUFFERS_, typename TFlag = bool>
|
||||
class buffer_descriptors
|
||||
{
|
||||
private:
|
||||
|
||||
struct descriptor_item;
|
||||
|
||||
public:
|
||||
|
||||
typedef TBuffer value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef size_t size_type;
|
||||
typedef TFlag flag_type;
|
||||
|
||||
static ETL_CONSTANT size_type N_BUFFERS = N_BUFFERS_;
|
||||
static ETL_CONSTANT size_type BUFFER_SIZE = BUFFER_SIZE_;
|
||||
|
||||
//*********************************
|
||||
/// Describes a buffer.
|
||||
//*********************************
|
||||
class descriptor
|
||||
{
|
||||
public:
|
||||
|
||||
friend class buffer_descriptors;
|
||||
|
||||
static ETL_CONSTANT const size_type MAX_SIZE = buffer_descriptors::BUFFER_SIZE;
|
||||
|
||||
//*********************************
|
||||
descriptor()
|
||||
: pdesc_item(ETL_NULLPTR)
|
||||
{
|
||||
}
|
||||
|
||||
//*********************************
|
||||
descriptor(const descriptor& other)
|
||||
: pdesc_item(other.pdesc_item)
|
||||
{
|
||||
}
|
||||
|
||||
//*********************************
|
||||
descriptor& operator =(const descriptor& other)
|
||||
{
|
||||
pdesc_item = other.pdesc_item;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
pointer data() const
|
||||
{
|
||||
assert(pdesc_item != ETL_NULLPTR);
|
||||
return pdesc_item->pbuffer;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
ETL_NODISCARD
|
||||
constexpr size_type max_size() const
|
||||
{
|
||||
return BUFFER_SIZE;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
ETL_NODISCARD
|
||||
bool is_allocated() const
|
||||
{
|
||||
return bool(pdesc_item->in_use);
|
||||
}
|
||||
|
||||
//*********************************
|
||||
ETL_NODISCARD
|
||||
bool is_released() const
|
||||
{
|
||||
return bool(!pdesc_item->in_use);
|
||||
}
|
||||
|
||||
//*********************************
|
||||
ETL_NODISCARD
|
||||
bool is_valid() const
|
||||
{
|
||||
return pdesc_item != ETL_NULLPTR;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
void release()
|
||||
{
|
||||
pdesc_item->in_use = false;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//*********************************
|
||||
descriptor(descriptor_item* pdesc_item_)
|
||||
: pdesc_item(pdesc_item_)
|
||||
{
|
||||
}
|
||||
|
||||
//*********************************
|
||||
void allocate()
|
||||
{
|
||||
pdesc_item->in_use = true;;
|
||||
}
|
||||
|
||||
/// The pointer to the buffer descriptor.
|
||||
descriptor_item* pdesc_item;
|
||||
};
|
||||
|
||||
//*********************************
|
||||
/// Describes a notification.
|
||||
//*********************************
|
||||
class notification
|
||||
{
|
||||
public:
|
||||
|
||||
//*********************************
|
||||
notification()
|
||||
: desc()
|
||||
, count(0U)
|
||||
{
|
||||
}
|
||||
|
||||
//*********************************
|
||||
notification(descriptor desc_, size_t count_)
|
||||
: desc(desc_)
|
||||
, count(count_)
|
||||
{
|
||||
}
|
||||
|
||||
//*********************************
|
||||
ETL_NODISCARD
|
||||
descriptor get_descriptor() const
|
||||
{
|
||||
return desc;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
ETL_NODISCARD
|
||||
size_t get_count() const
|
||||
{
|
||||
return count;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
descriptor desc;
|
||||
size_t count;
|
||||
};
|
||||
|
||||
// The type of the callback function.
|
||||
typedef etl::delegate<void(notification)> callback_type;
|
||||
|
||||
//*********************************
|
||||
buffer_descriptors(TBuffer* pbuffers_, callback_type callback_ = callback_type())
|
||||
: callback(callback_)
|
||||
{
|
||||
for (size_t i = 0U; i < N_BUFFERS; ++i)
|
||||
{
|
||||
descriptor_items[i].pbuffer = pbuffers_ + (i * BUFFER_SIZE);
|
||||
descriptor_items[i].in_use = false;
|
||||
}
|
||||
}
|
||||
|
||||
//*********************************
|
||||
void set_callback(const callback_type& callback_)
|
||||
{
|
||||
callback = callback_;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
void clear()
|
||||
{
|
||||
for (size_t i = 0U; i < N_BUFFERS; ++i)
|
||||
{
|
||||
descriptor_items[i].in_use = false;
|
||||
}
|
||||
|
||||
next.to_first();
|
||||
}
|
||||
|
||||
//*********************************
|
||||
ETL_NODISCARD
|
||||
bool is_valid() const
|
||||
{
|
||||
return callback.is_valid();
|
||||
}
|
||||
|
||||
//*********************************
|
||||
void notify(notification n)
|
||||
{
|
||||
// Do we have a valid callback?
|
||||
if (callback.is_valid())
|
||||
{
|
||||
callback(n);
|
||||
}
|
||||
}
|
||||
|
||||
//*********************************
|
||||
ETL_NODISCARD
|
||||
descriptor allocate()
|
||||
{
|
||||
descriptor desc(&descriptor_items[next]);
|
||||
|
||||
if (desc.is_released())
|
||||
{
|
||||
++next;
|
||||
|
||||
desc.allocate();
|
||||
|
||||
return desc;
|
||||
}
|
||||
else
|
||||
{
|
||||
return descriptor();
|
||||
}
|
||||
}
|
||||
|
||||
//*********************************
|
||||
ETL_NODISCARD
|
||||
descriptor allocate(value_type fill_)
|
||||
{
|
||||
descriptor desc = allocate();
|
||||
|
||||
if (desc.is_valid())
|
||||
{
|
||||
etl::fill_n(desc.data(), BUFFER_SIZE, fill_);
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//*********************************
|
||||
struct descriptor_item
|
||||
{
|
||||
pointer pbuffer;
|
||||
volatile flag_type in_use;
|
||||
};
|
||||
|
||||
callback_type callback;
|
||||
etl::array<descriptor_item, N_BUFFERS> descriptor_items;
|
||||
etl::cyclic_value<uint_least8_t, 0U, N_BUFFERS - 1> next;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -56,7 +56,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
callback_service()
|
||||
: unhandled_callback(*this),
|
||||
p_unhandled(nullptr)
|
||||
p_unhandled(ETL_NULLPTR)
|
||||
{
|
||||
lookup.fill(&unhandled_callback);
|
||||
}
|
||||
@ -137,7 +137,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
void unhandled(size_t id)
|
||||
{
|
||||
if (p_unhandled != nullptr)
|
||||
if (p_unhandled != ETL_NULLPTR)
|
||||
{
|
||||
(*p_unhandled)(id);
|
||||
}
|
||||
|
||||
@ -30,7 +30,6 @@ SOFTWARE.
|
||||
#define ETL_CALLBACK_TIMER_INCLUDED
|
||||
|
||||
#include <stdint.h>
|
||||
#include <new>
|
||||
|
||||
#include "platform.h"
|
||||
#include "algorithm.h"
|
||||
@ -40,15 +39,13 @@ SOFTWARE.
|
||||
#include "timer.h"
|
||||
#include "atomic.h"
|
||||
#include "error_handler.h"
|
||||
#include "placement_new.h"
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
#include "delegate.h"
|
||||
#endif
|
||||
|
||||
#undef ETL_FILE
|
||||
#define ETL_FILE "43"
|
||||
|
||||
#if defined(ETL_IN_UNIT_TEST) && defined(ETL_NO_STL)
|
||||
#if defined(ETL_IN_UNIT_TEST) && ETL_NOT_USING_STL
|
||||
#define ETL_DISABLE_TIMER_UPDATES
|
||||
#define ETL_ENABLE_TIMER_UPDATES
|
||||
#define ETL_TIMER_UPDATES_ENABLED true
|
||||
@ -96,7 +93,7 @@ namespace etl
|
||||
|
||||
//*******************************************
|
||||
callback_timer_data()
|
||||
: p_callback(nullptr),
|
||||
: p_callback(ETL_NULLPTR),
|
||||
period(0),
|
||||
delta(etl::timer::state::INACTIVE),
|
||||
id(etl::timer::id::NO_TIMER),
|
||||
@ -577,7 +574,7 @@ namespace etl
|
||||
active_list.insert(timer.id);
|
||||
}
|
||||
|
||||
if (timer.p_callback != nullptr)
|
||||
if (timer.p_callback != ETL_NULLPTR)
|
||||
{
|
||||
if (timer.cbk_type == callback_timer_data::C_CALLBACK)
|
||||
{
|
||||
@ -772,6 +769,4 @@ namespace etl
|
||||
#undef ETL_ENABLE_TIMER_UPDATES
|
||||
#undef ETL_TIMER_UPDATES_ENABLED
|
||||
|
||||
#undef ETL_FILE
|
||||
|
||||
#endif
|
||||
|
||||
@ -102,19 +102,19 @@ namespace etl
|
||||
typedef typename char_traits_types<T>::state_type state_type;
|
||||
|
||||
//*************************************************************************
|
||||
static bool eq(char_type a, char_type b)
|
||||
ETL_CONSTEXPR static bool eq(char_type a, char_type b)
|
||||
{
|
||||
return a == b;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
static bool lt(char_type a, char_type b)
|
||||
ETL_CONSTEXPR static bool lt(char_type a, char_type b)
|
||||
{
|
||||
return a < b;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
static size_t length(const char_type* str)
|
||||
ETL_CONSTEXPR14 static size_t length(const char_type* str)
|
||||
{
|
||||
size_t count = 0;
|
||||
|
||||
|
||||
1323
include/etl/circular_buffer.h
Normal file
1323
include/etl/circular_buffer.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -48,8 +48,13 @@ namespace etl
|
||||
template <const size_t NV, const size_t KV>
|
||||
struct combinations
|
||||
{
|
||||
static const size_t value = etl::permutations<NV, KV>::value / etl::factorial<KV>::value;
|
||||
static ETL_CONSTANT size_t value = etl::permutations<NV, KV>::value / etl::factorial<KV>::value;
|
||||
};
|
||||
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
template <size_t NV, size_t KV>
|
||||
inline constexpr size_t combinations_v = combinations<NV, KV>::value;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -43,7 +43,7 @@ SOFTWARE.
|
||||
|
||||
namespace etl
|
||||
{
|
||||
typedef crc8_poly_0x07<0xFF, 0x00, true, true> crc8_rohc;
|
||||
typedef crc8_poly_0x07<0xFF, 0x00, true> crc8_rohc;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -7,7 +7,7 @@ Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2016 jwellbelove
|
||||
Copyright(c) 2020 jwellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
@ -28,278 +28,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef ETL_STRING_INCLUDED
|
||||
#define ETL_STRING_INCLUDED
|
||||
//*****************************************************************************
|
||||
// This header is deprecated. Use "string.h"
|
||||
//*****************************************************************************
|
||||
|
||||
#include "platform.h"
|
||||
#include "basic_string.h"
|
||||
#include "string_view.h"
|
||||
#include "hash.h"
|
||||
#pragma message ("This header is deprecated. Use 'etl/string.h'")
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
#include <initializer_list>
|
||||
#endif
|
||||
|
||||
#include "private/minmax_push.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
typedef etl::ibasic_string<char> istring;
|
||||
|
||||
//***************************************************************************
|
||||
/// A string implementation that uses a fixed size buffer.
|
||||
///\tparam MAX_SIZE_ The maximum number of elements that can be stored.
|
||||
///\ingroup string
|
||||
//***************************************************************************
|
||||
template <const size_t MAX_SIZE_>
|
||||
class string : public istring
|
||||
{
|
||||
public:
|
||||
|
||||
typedef istring base_type;
|
||||
typedef istring interface_type;
|
||||
|
||||
typedef istring::value_type value_type;
|
||||
|
||||
static const size_t MAX_SIZE = MAX_SIZE_;
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor.
|
||||
//*************************************************************************
|
||||
string()
|
||||
: istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Copy constructor.
|
||||
///\param other The other string.
|
||||
//*************************************************************************
|
||||
string(const etl::string<MAX_SIZE_>& other)
|
||||
: istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->assign(other);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// From other istring.
|
||||
///\param other The other istring.
|
||||
//*************************************************************************
|
||||
string(const etl::istring& other)
|
||||
: istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->assign(other);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// From other string, position, length.
|
||||
///\param other The other string.
|
||||
///\param position The position of the first character.
|
||||
///\param length The number of characters. Default = npos.
|
||||
//*************************************************************************
|
||||
string(const etl::istring& other, size_t position, size_t length_ = npos)
|
||||
: istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
ETL_ASSERT(position < other.size(), ETL_ERROR(string_out_of_bounds));
|
||||
|
||||
this->assign(other.begin() + position, other.begin() + position + length_);
|
||||
|
||||
if (other.truncated())
|
||||
{
|
||||
this->is_truncated = true;
|
||||
|
||||
#if defined(ETL_STRING_TRUNCATION_IS_ERROR)
|
||||
ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor, from null terminated text.
|
||||
///\param text The initial text of the string.
|
||||
//*************************************************************************
|
||||
ETL_EXPLICIT_STRING_FROM_CHAR string(const value_type* text)
|
||||
: istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->assign(text, text + etl::char_traits<value_type>::length(text));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor, from null terminated text and count.
|
||||
///\param text The initial text of the string.
|
||||
///\param count The number of characters to copy.
|
||||
//*************************************************************************
|
||||
string(const value_type* text, size_t count)
|
||||
: istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->assign(text, text + count);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor, from initial size and value.
|
||||
///\param initialSize The initial size of the string.
|
||||
///\param value The value to fill the string with.
|
||||
//*************************************************************************
|
||||
string(size_t count, value_type c)
|
||||
: istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
this->resize(count, c);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor, from an iterator range.
|
||||
///\tparam TIterator The iterator type.
|
||||
///\param first The iterator to the first element.
|
||||
///\param last The iterator to the last element + 1.
|
||||
//*************************************************************************
|
||||
template <typename TIterator>
|
||||
string(TIterator first, TIterator last)
|
||||
: istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
string(std::initializer_list<value_type> init)
|
||||
: istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->assign(init.begin(), init.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// From string_view.
|
||||
///\param view The string_view.
|
||||
//*************************************************************************
|
||||
explicit string(const etl::string_view& view)
|
||||
: istring(reinterpret_cast<value_type*>(&buffer), MAX_SIZE)
|
||||
{
|
||||
this->assign(view.begin(), view.end());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns a sub-string.
|
||||
///\param position The position of the first character. Default = 0.
|
||||
///\param length The number of characters. Default = npos.
|
||||
//*************************************************************************
|
||||
etl::string<MAX_SIZE_> substr(size_t position = 0, size_t length_ = npos) const
|
||||
{
|
||||
etl::string<MAX_SIZE_> new_string;
|
||||
|
||||
if (position != this->size())
|
||||
{
|
||||
ETL_ASSERT(position < this->size(), ETL_ERROR(string_out_of_bounds));
|
||||
|
||||
length_ = etl::min(length_, this->size() - position);
|
||||
|
||||
new_string.assign(buffer + position, buffer + position + length_);
|
||||
}
|
||||
|
||||
return new_string;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
string& operator = (const string& rhs)
|
||||
{
|
||||
if (&rhs != this)
|
||||
{
|
||||
this->assign(rhs);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
string& operator = (const istring& rhs)
|
||||
{
|
||||
if (&rhs != this)
|
||||
{
|
||||
this->assign(rhs);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Assignment operator.
|
||||
//*************************************************************************
|
||||
string& operator = (const value_type* text)
|
||||
{
|
||||
this->assign(text);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
#ifdef ETL_ISTRING_REPAIR_ENABLE
|
||||
virtual
|
||||
#endif
|
||||
void repair()
|
||||
{
|
||||
etl::istring::repair_buffer(buffer);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
value_type buffer[MAX_SIZE + 1];
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Hash function.
|
||||
//*************************************************************************
|
||||
#if ETL_8BIT_SUPPORT
|
||||
template <>
|
||||
struct hash<etl::istring>
|
||||
{
|
||||
size_t operator()(const etl::istring& text) const
|
||||
{
|
||||
return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(&text[0]),
|
||||
reinterpret_cast<const uint8_t*>(&text[text.size()]));
|
||||
}
|
||||
};
|
||||
|
||||
template <const size_t SIZE>
|
||||
struct hash<etl::string<SIZE> >
|
||||
{
|
||||
size_t operator()(const etl::string<SIZE>& text) const
|
||||
{
|
||||
return etl::private_hash::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(&text[0]),
|
||||
reinterpret_cast<const uint8_t*>(&text[text.size()]));
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Make string from string literal or char array
|
||||
//***************************************************************************
|
||||
template<const size_t MAX_SIZE>
|
||||
etl::string<MAX_SIZE - 1> make_string(const char (&text) [MAX_SIZE])
|
||||
{
|
||||
return etl::string<MAX_SIZE - 1>(text, MAX_SIZE - 1);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Make string with max capacity from string literal or char array
|
||||
//***************************************************************************
|
||||
template<const size_t MAX_SIZE, const size_t SIZE>
|
||||
etl::string<MAX_SIZE> make_string_with_capacity(const char(&text)[SIZE])
|
||||
{
|
||||
return etl::string<MAX_SIZE>(text, SIZE - 1);
|
||||
}
|
||||
}
|
||||
|
||||
#include "private/minmax_pop.h"
|
||||
|
||||
#endif
|
||||
#include "string.h"
|
||||
|
||||
@ -32,9 +32,58 @@ SOFTWARE.
|
||||
#define ETL_CUMULATIVE_MOVING_AVERAGE_INCLUDED
|
||||
|
||||
#include "type_traits.h"
|
||||
#include "iterator.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
namespace private_cumulative_moving_average
|
||||
{
|
||||
//***************************************************
|
||||
/// add_insert_iterator
|
||||
/// An output iterator used to add new values.
|
||||
//***************************************************
|
||||
template <typename TCMA>
|
||||
class add_insert_iterator : public etl::iterator<ETL_OR_STD::output_iterator_tag, void, void, void, void>
|
||||
{
|
||||
public:
|
||||
|
||||
//***********************************
|
||||
explicit add_insert_iterator(TCMA& cma) ETL_NOEXCEPT
|
||||
: p_cma(&cma)
|
||||
{
|
||||
}
|
||||
|
||||
//***********************************
|
||||
add_insert_iterator& operator*() ETL_NOEXCEPT
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
//***********************************
|
||||
add_insert_iterator& operator++() ETL_NOEXCEPT
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
//***********************************
|
||||
add_insert_iterator& operator++(int) ETL_NOEXCEPT
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
//***********************************
|
||||
add_insert_iterator& operator =(typename TCMA::value_type value)
|
||||
{
|
||||
p_cma->add(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
TCMA* p_cma;
|
||||
};
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Cumulative Moving Average
|
||||
/// \tparam T The sample value type.
|
||||
@ -58,6 +107,10 @@ namespace etl
|
||||
template <typename T, const size_t SAMPLE_SIZE_, const size_t SCALING_>
|
||||
class cumulative_moving_average<T, SAMPLE_SIZE_, SCALING_, true, false>
|
||||
{
|
||||
private:
|
||||
|
||||
typedef cumulative_moving_average<T, SAMPLE_SIZE_, SCALING_, true, false> this_t;
|
||||
|
||||
typedef typename etl::conditional<etl::is_signed<T>::value, int32_t, uint32_t>::type scale_t;
|
||||
typedef typename etl::conditional<etl::is_signed<T>::value, int32_t, uint32_t>::type sample_t;
|
||||
|
||||
@ -66,6 +119,9 @@ namespace etl
|
||||
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef private_cumulative_moving_average::add_insert_iterator<this_t> add_insert_iterator;
|
||||
|
||||
static const size_t SAMPLE_SIZE = SAMPLE_SIZE_; ///< The number of samples averaged over.
|
||||
static const size_t SCALING = SCALING_; ///< The sample scaling factor.
|
||||
|
||||
@ -107,6 +163,15 @@ namespace etl
|
||||
return average;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets an iterator for input.
|
||||
/// \return An iterator.
|
||||
//*************************************************************************
|
||||
add_insert_iterator input()
|
||||
{
|
||||
return add_insert_iterator(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
T average; ///< The current cumulative average.
|
||||
@ -121,6 +186,8 @@ namespace etl
|
||||
template <typename T, const size_t SCALING_>
|
||||
class cumulative_moving_average<T, 0, SCALING_, true, false>
|
||||
{
|
||||
typedef cumulative_moving_average<T, 0, SCALING_, true, false> this_t;
|
||||
|
||||
typedef typename etl::conditional<etl::is_signed<T>::value, int32_t, uint32_t>::type scale_t;
|
||||
typedef typename etl::conditional<etl::is_signed<T>::value, int32_t, uint32_t>::type sample_t;
|
||||
|
||||
@ -128,6 +195,9 @@ namespace etl
|
||||
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef private_cumulative_moving_average::add_insert_iterator<this_t> add_insert_iterator;
|
||||
|
||||
static const size_t SCALING = SCALING_; ///< The sample scaling factor.
|
||||
|
||||
//*************************************************************************
|
||||
@ -178,6 +248,15 @@ namespace etl
|
||||
return average;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets an iterator for input.
|
||||
/// \return An iterator.
|
||||
//*************************************************************************
|
||||
add_insert_iterator input()
|
||||
{
|
||||
return add_insert_iterator(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
T average; ///< The current cumulative average.
|
||||
@ -193,8 +272,13 @@ namespace etl
|
||||
template <typename T, const size_t SAMPLE_SIZE_>
|
||||
class cumulative_moving_average<T, SAMPLE_SIZE_, 1U, false, true>
|
||||
{
|
||||
typedef cumulative_moving_average<T, SAMPLE_SIZE_, 1U, false, true> this_t;
|
||||
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef private_cumulative_moving_average::add_insert_iterator<this_t> add_insert_iterator;
|
||||
|
||||
static const size_t SAMPLE_SIZE = SAMPLE_SIZE_;
|
||||
|
||||
//*************************************************************************
|
||||
@ -234,6 +318,15 @@ namespace etl
|
||||
return average;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets an iterator for input.
|
||||
/// \return An iterator.
|
||||
//*************************************************************************
|
||||
add_insert_iterator input()
|
||||
{
|
||||
return add_insert_iterator(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
const T reciprocal_samples_plus_1; ///< Reciprocal of one greater than the sample size.
|
||||
@ -241,16 +334,21 @@ namespace etl
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// Cumulative Moving Average
|
||||
/// For floating point types.
|
||||
/// \tparam T The sample value type.
|
||||
/// \tparam SAMPLE_SIZE The number of samples to average over.
|
||||
//***************************************************************************
|
||||
/// Cumulative Moving Average
|
||||
/// For floating point types.
|
||||
/// \tparam T The sample value type.
|
||||
/// \tparam SAMPLE_SIZE The number of samples to average over.
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
class cumulative_moving_average<T, 0U, 1U, false, true>
|
||||
{
|
||||
typedef cumulative_moving_average<T, 0U, 1U, false, true> this_t;
|
||||
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef private_cumulative_moving_average::add_insert_iterator<this_t> add_insert_iterator;
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor
|
||||
/// \param initial_value The initial value for the average.
|
||||
@ -297,6 +395,15 @@ namespace etl
|
||||
return average;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Gets an iterator for input.
|
||||
/// \return An iterator.
|
||||
//*************************************************************************
|
||||
add_insert_iterator input()
|
||||
{
|
||||
return add_insert_iterator(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
T reciprocal_samples_plus_1; ///< Reciprocal of one greater than the sample size.
|
||||
|
||||
@ -41,12 +41,13 @@ SOFTWARE.
|
||||
|
||||
#if defined(ETL_DEBUG_COUNT)
|
||||
|
||||
#define ETL_DECLARE_DEBUG_COUNT etl::debug_count etl_debug_count;
|
||||
#define ETL_INCREMENT_DEBUG_COUNT ++etl_debug_count;
|
||||
#define ETL_DECREMENT_DEBUG_COUNT --etl_debug_count;
|
||||
#define ETL_ADD_DEBUG_COUNT(n) etl_debug_count += (n);
|
||||
#define ETL_SUBTRACT_DEBUG_COUNT(n) etl_debug_count -= (n);
|
||||
#define ETL_RESET_DEBUG_COUNT etl_debug_count.clear();
|
||||
#define ETL_DECLARE_DEBUG_COUNT etl::debug_count etl_debug_count;
|
||||
#define ETL_INCREMENT_DEBUG_COUNT ++etl_debug_count;
|
||||
#define ETL_DECREMENT_DEBUG_COUNT --etl_debug_count;
|
||||
#define ETL_ADD_DEBUG_COUNT(n) etl_debug_count += (n);
|
||||
#define ETL_SUBTRACT_DEBUG_COUNT(n) etl_debug_count -= (n);
|
||||
#define ETL_RESET_DEBUG_COUNT etl_debug_count.clear();
|
||||
#define ETL_OBJECT_RESET_DEBUG_COUNT(object) object.etl_debug_count.clear();
|
||||
|
||||
namespace etl
|
||||
{
|
||||
@ -122,6 +123,7 @@ namespace etl
|
||||
#define ETL_ADD_DEBUG_COUNT(n)
|
||||
#define ETL_SUBTRACT_DEBUG_COUNT(n)
|
||||
#define ETL_RESET_DEBUG_COUNT
|
||||
#define ETL_OBJECT_RESET_DEBUG_COUNT(object)
|
||||
#endif // ETL_DEBUG_COUNT
|
||||
|
||||
#endif
|
||||
|
||||
@ -51,14 +51,12 @@ Original publication: https://www.codeproject.com/Articles/1170503/The-Impossibl
|
||||
#include "platform.h"
|
||||
#include "error_handler.h"
|
||||
#include "exception.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#if ETL_CPP11_SUPPORTED == 0
|
||||
#error NOT SUPPORTED FOR C++03 OR BELOW
|
||||
#endif
|
||||
|
||||
#undef ETL_FILE
|
||||
#define ETL_FILE "51"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
//***************************************************************************
|
||||
@ -82,7 +80,7 @@ namespace etl
|
||||
public:
|
||||
|
||||
delegate_uninitialised(string_type file_name_, numeric_type line_number_)
|
||||
: delegate_exception(ETL_ERROR_TEXT("delegate:uninitialised", ETL_FILE"A"), file_name_, line_number_)
|
||||
: delegate_exception(ETL_ERROR_TEXT("delegate:uninitialised", ETL_DELEGATE_FILE_ID"A"), file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
@ -107,7 +105,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
// Constructor from lambda or functor.
|
||||
//*************************************************************************
|
||||
template <typename TLambda>
|
||||
template <typename TLambda, typename = typename etl::enable_if<etl::is_class<TLambda>::value, void>::type>
|
||||
delegate(const TLambda& instance)
|
||||
{
|
||||
assign((void*)(&instance), lambda_stub<TLambda>);
|
||||
@ -117,16 +115,16 @@ namespace etl
|
||||
/// Create from function (Compile time).
|
||||
//*************************************************************************
|
||||
template <TReturn(*Method)(TParams...)>
|
||||
static delegate create()
|
||||
constexpr static delegate create()
|
||||
{
|
||||
return delegate(nullptr, function_stub<Method>);
|
||||
return delegate(ETL_NULLPTR, function_stub<Method>);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Create from Lambda or Functor.
|
||||
//*************************************************************************
|
||||
template <typename TLambda>
|
||||
static delegate create(const TLambda& instance)
|
||||
template <typename TLambda, typename = typename etl::enable_if<etl::is_class<TLambda>::value, void>::type>
|
||||
constexpr static delegate create(const TLambda& instance)
|
||||
{
|
||||
return delegate((void*)(&instance), lambda_stub<TLambda>);
|
||||
}
|
||||
@ -135,7 +133,7 @@ namespace etl
|
||||
/// Create from instance method (Run time).
|
||||
//*************************************************************************
|
||||
template <typename T, TReturn(T::*Method)(TParams...)>
|
||||
static delegate create(T& instance)
|
||||
constexpr static delegate create(T& instance)
|
||||
{
|
||||
return delegate((void*)(&instance), method_stub<T, Method>);
|
||||
}
|
||||
@ -151,7 +149,7 @@ namespace etl
|
||||
/// Create from const instance method (Run time).
|
||||
//*************************************************************************
|
||||
template <typename T, TReturn(T::*Method)(TParams...) const>
|
||||
static delegate create(const T& instance)
|
||||
constexpr static delegate create(const T& instance)
|
||||
{
|
||||
return delegate((void*)(&instance), const_method_stub<T, Method>);
|
||||
}
|
||||
@ -160,13 +158,13 @@ namespace etl
|
||||
/// Disable create from rvalue instance method (Run time).
|
||||
//*************************************************************************
|
||||
template <typename T, TReturn(T::*Method)(TParams...) const>
|
||||
static delegate create(T&& instance) = delete;
|
||||
constexpr static delegate create(T&& instance) = delete;
|
||||
|
||||
//*************************************************************************
|
||||
/// Create from instance method (Compile time).
|
||||
//*************************************************************************
|
||||
template <typename T, T& Instance, TReturn(T::*Method)(TParams...)>
|
||||
static delegate create()
|
||||
constexpr static delegate create()
|
||||
{
|
||||
return delegate(method_instance_stub<T, Instance, Method>);
|
||||
}
|
||||
@ -175,7 +173,7 @@ namespace etl
|
||||
/// Create from const instance method (Compile time).
|
||||
//*************************************************************************
|
||||
template <typename T, T const& Instance, TReturn(T::*Method)(TParams...) const>
|
||||
static delegate create()
|
||||
constexpr static delegate create()
|
||||
{
|
||||
return delegate(const_method_instance_stub<T, Instance, Method>);
|
||||
}
|
||||
@ -186,7 +184,7 @@ namespace etl
|
||||
/// At the time of writing, GCC appears to have trouble with this.
|
||||
//*************************************************************************
|
||||
template <typename T, T& Instance>
|
||||
static delegate create()
|
||||
constexpr static delegate create()
|
||||
{
|
||||
return delegate(operator_instance_stub<T, Instance>);
|
||||
}
|
||||
@ -210,7 +208,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Create from Lambda or Functor.
|
||||
//*************************************************************************
|
||||
template <typename TLambda>
|
||||
template <typename TLambda, typename = typename etl::enable_if<etl::is_class<TLambda>::value, void>::type>
|
||||
delegate& operator =(const TLambda& instance)
|
||||
{
|
||||
assign((void*)(&instance), lambda_stub<TLambda>);
|
||||
@ -238,7 +236,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
bool is_valid() const
|
||||
{
|
||||
return invocation.stub != nullptr;
|
||||
return invocation.stub != ETL_NULLPTR;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -261,7 +259,7 @@ namespace etl
|
||||
invocation_element() = default;
|
||||
|
||||
//***********************************************************************
|
||||
invocation_element(void* object_, stub_type stub_)
|
||||
constexpr invocation_element(void* object_, stub_type stub_)
|
||||
: object(object_)
|
||||
, stub(stub_)
|
||||
{
|
||||
@ -280,26 +278,24 @@ namespace etl
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
void* object = nullptr;
|
||||
stub_type stub = nullptr;
|
||||
void* object = ETL_NULLPTR;
|
||||
stub_type stub = ETL_NULLPTR;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructs a delegate from an object and stub.
|
||||
//*************************************************************************
|
||||
delegate(void* object, stub_type stub)
|
||||
constexpr delegate(void* object, stub_type stub)
|
||||
: invocation(object, stub)
|
||||
{
|
||||
invocation.object = object;
|
||||
invocation.stub = stub;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructs a delegate from a stub.
|
||||
//*************************************************************************
|
||||
delegate(stub_type stub)
|
||||
constexpr delegate(stub_type stub)
|
||||
: invocation(ETL_NULLPTR, stub)
|
||||
{
|
||||
invocation.object = nullptr;
|
||||
invocation.stub = stub;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -386,6 +382,4 @@ namespace etl
|
||||
};
|
||||
}
|
||||
|
||||
#undef ETL_FILE
|
||||
|
||||
#endif
|
||||
|
||||
@ -5,7 +5,7 @@ The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
http://www.etlcpp.com
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2014 jwellbelove
|
||||
|
||||
@ -34,17 +34,11 @@ SOFTWARE.
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <new>
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#include "algorithm.h"
|
||||
#include "iterator.h"
|
||||
#include "utility.h"
|
||||
|
||||
#include "container.h"
|
||||
#include "alignment.h"
|
||||
#include "array.h"
|
||||
#include "memory.h"
|
||||
#include "exception.h"
|
||||
#include "error_handler.h"
|
||||
@ -52,16 +46,14 @@ SOFTWARE.
|
||||
#include "algorithm.h"
|
||||
#include "type_traits.h"
|
||||
#include "iterator.h"
|
||||
#include "placement_new.h"
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#include <initializer_list>
|
||||
#endif
|
||||
|
||||
#include "private/minmax_push.h"
|
||||
|
||||
#undef ETL_FILE
|
||||
#define ETL_FILE "1"
|
||||
|
||||
//*****************************************************************************
|
||||
///\defgroup deque deque
|
||||
/// A double ended queue with the capacity defined at compile time.
|
||||
@ -93,7 +85,7 @@ namespace etl
|
||||
public:
|
||||
|
||||
deque_full(string_type file_name_, numeric_type line_number_)
|
||||
: etl::deque_exception(ETL_ERROR_TEXT("deque:full", ETL_FILE"A"), file_name_, line_number_)
|
||||
: etl::deque_exception(ETL_ERROR_TEXT("deque:full", ETL_DEQUE_FILE_ID"A"), file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
@ -107,7 +99,7 @@ namespace etl
|
||||
public:
|
||||
|
||||
deque_empty(string_type file_name_, numeric_type line_number_)
|
||||
: etl::deque_exception(ETL_ERROR_TEXT("deque:empty", ETL_FILE"B"), file_name_, line_number_)
|
||||
: etl::deque_exception(ETL_ERROR_TEXT("deque:empty", ETL_DEQUE_FILE_ID"B"), file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
@ -121,7 +113,7 @@ namespace etl
|
||||
public:
|
||||
|
||||
deque_out_of_bounds(string_type file_name_, numeric_type line_number_)
|
||||
: etl::deque_exception(ETL_ERROR_TEXT("deque:bounds", ETL_FILE"C"), file_name_, line_number_)
|
||||
: etl::deque_exception(ETL_ERROR_TEXT("deque:bounds", ETL_DEQUE_FILE_ID"C"), file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
@ -135,7 +127,7 @@ namespace etl
|
||||
public:
|
||||
|
||||
deque_incompatible_type(string_type file_name_, numeric_type line_number_)
|
||||
: deque_exception(ETL_ERROR_TEXT("deque:type", ETL_FILE"D"), file_name_, line_number_)
|
||||
: deque_exception(ETL_ERROR_TEXT("deque:type", ETL_DEQUE_FILE_ID"D"), file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
@ -186,6 +178,15 @@ namespace etl
|
||||
return CAPACITY;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns the maximum possible size of the deque.
|
||||
///\return The maximum size of the deque.
|
||||
//*************************************************************************
|
||||
size_type capacity() const
|
||||
{
|
||||
return CAPACITY;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns the remaining capacity.
|
||||
///\return The remaining capacity.
|
||||
@ -202,8 +203,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
deque_base(size_t max_size_, size_t buffer_size_)
|
||||
: current_size(0),
|
||||
CAPACITY(max_size_),
|
||||
BUFFER_SIZE(buffer_size_)
|
||||
CAPACITY(max_size_),
|
||||
BUFFER_SIZE(buffer_size_)
|
||||
{
|
||||
}
|
||||
|
||||
@ -232,12 +233,12 @@ namespace etl
|
||||
|
||||
typedef T value_type;
|
||||
typedef size_t size_type;
|
||||
typedef T& reference;
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
typedef T&& rvalue_reference;
|
||||
typedef T&& rvalue_reference;
|
||||
#endif
|
||||
typedef T* pointer;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
typedef typename etl::iterator_traits<pointer>::difference_type difference_type;
|
||||
|
||||
@ -252,14 +253,16 @@ namespace etl
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
|
||||
//*************************************************************************
|
||||
/// Iterator
|
||||
//*************************************************************************
|
||||
struct iterator : public etl::iterator<ETL_OR_STD::random_access_iterator_tag, T>
|
||||
class iterator : public etl::iterator<ETL_OR_STD::random_access_iterator_tag, T>
|
||||
{
|
||||
public:
|
||||
|
||||
friend class ideque;
|
||||
friend struct const_iterator;
|
||||
friend class const_iterator;
|
||||
|
||||
//***************************************************
|
||||
iterator()
|
||||
@ -280,8 +283,8 @@ namespace etl
|
||||
//***************************************************
|
||||
iterator& operator =(const iterator& other)
|
||||
{
|
||||
index = other.index;
|
||||
p_deque = other.p_deque;
|
||||
index = other.index;
|
||||
p_deque = other.p_deque;
|
||||
p_buffer = other.p_buffer;
|
||||
|
||||
return *this;
|
||||
@ -377,12 +380,6 @@ namespace etl
|
||||
return &p_buffer[index];
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
bool operator <(const iterator& other) const
|
||||
{
|
||||
return ideque::distance(*this, other) > 0;
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
friend iterator operator +(const iterator& lhs, difference_type offset)
|
||||
{
|
||||
@ -411,6 +408,38 @@ namespace etl
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
friend bool operator < (const iterator& lhs, const iterator& rhs)
|
||||
{
|
||||
const difference_type lhs_index = lhs.get_index();
|
||||
const difference_type rhs_index = rhs.get_index();
|
||||
const difference_type reference_index = lhs.container().begin().get_index();
|
||||
const size_t buffer_size = lhs.container().max_size() + 1;
|
||||
|
||||
const difference_type lhs_distance = (lhs_index < reference_index) ? buffer_size + lhs_index - reference_index : lhs_index - reference_index;
|
||||
const difference_type rhs_distance = (rhs_index < reference_index) ? buffer_size + rhs_index - reference_index : rhs_index - reference_index;
|
||||
|
||||
return lhs_distance < rhs_distance;
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
friend bool operator <= (const iterator& lhs, const iterator& rhs)
|
||||
{
|
||||
return !(lhs > rhs);
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
friend bool operator > (const iterator& lhs, const iterator& rhs)
|
||||
{
|
||||
return (rhs < lhs);
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
friend bool operator >= (const iterator& lhs, const iterator& rhs)
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
difference_type get_index() const
|
||||
{
|
||||
@ -418,7 +447,7 @@ namespace etl
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
ideque& get_deque() const
|
||||
ideque& container() const
|
||||
{
|
||||
return *p_deque;
|
||||
}
|
||||
@ -439,6 +468,19 @@ namespace etl
|
||||
|
||||
private:
|
||||
|
||||
//***************************************************
|
||||
difference_type distance(difference_type firstIndex, difference_type index_) const
|
||||
{
|
||||
if (index_ < firstIndex)
|
||||
{
|
||||
return p_deque->BUFFER_SIZE + index_ - firstIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
return index_ - firstIndex;
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
iterator(difference_type index_, ideque& the_deque, pointer p_buffer_)
|
||||
: index(index_)
|
||||
@ -448,15 +490,17 @@ namespace etl
|
||||
}
|
||||
|
||||
difference_type index;
|
||||
ideque* p_deque;
|
||||
ideque* p_deque;
|
||||
pointer p_buffer;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Const Iterator
|
||||
//*************************************************************************
|
||||
struct const_iterator : public etl::iterator<ETL_OR_STD::random_access_iterator_tag, const T>
|
||||
class const_iterator : public etl::iterator<ETL_OR_STD::random_access_iterator_tag, const T>
|
||||
{
|
||||
public:
|
||||
|
||||
friend class ideque;
|
||||
|
||||
//***************************************************
|
||||
@ -486,8 +530,8 @@ namespace etl
|
||||
//***************************************************
|
||||
const_iterator& operator =(const const_iterator& other)
|
||||
{
|
||||
index = other.index;
|
||||
p_deque = other.p_deque;
|
||||
index = other.index;
|
||||
p_deque = other.p_deque;
|
||||
p_buffer = other.p_buffer;
|
||||
|
||||
return *this;
|
||||
@ -495,8 +539,8 @@ namespace etl
|
||||
|
||||
const_iterator& operator =(const typename ideque::iterator& other)
|
||||
{
|
||||
index = other.index;
|
||||
p_deque = other.p_deque;
|
||||
index = other.index;
|
||||
p_deque = other.p_deque;
|
||||
p_buffer = other.p_buffer;
|
||||
|
||||
return *this;
|
||||
@ -580,11 +624,7 @@ namespace etl
|
||||
return &p_buffer[index];
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
bool operator <(const const_iterator& other) const
|
||||
{
|
||||
return ideque::distance(*this, other) > 0;
|
||||
}
|
||||
|
||||
|
||||
//***************************************************
|
||||
friend const_iterator operator +(const const_iterator& lhs, difference_type offset)
|
||||
@ -614,6 +654,38 @@ namespace etl
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
friend bool operator < (const const_iterator& lhs, const const_iterator& rhs)
|
||||
{
|
||||
const difference_type lhs_index = lhs.get_index();
|
||||
const difference_type rhs_index = rhs.get_index();
|
||||
const difference_type reference_index = lhs.container().begin().get_index();
|
||||
const size_t buffer_size = lhs.container().max_size() + 1;
|
||||
|
||||
const difference_type lhs_distance = (lhs_index < reference_index) ? buffer_size + lhs_index - reference_index : lhs_index - reference_index;
|
||||
const difference_type rhs_distance = (rhs_index < reference_index) ? buffer_size + rhs_index - reference_index : rhs_index - reference_index;
|
||||
|
||||
return lhs_distance < rhs_distance;
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
friend bool operator <= (const const_iterator& lhs, const const_iterator& rhs)
|
||||
{
|
||||
return !(lhs > rhs);
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
friend bool operator > (const const_iterator& lhs, const const_iterator& rhs)
|
||||
{
|
||||
return (rhs < lhs);
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
friend bool operator >= (const const_iterator& lhs, const const_iterator& rhs)
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
difference_type get_index() const
|
||||
{
|
||||
@ -621,7 +693,7 @@ namespace etl
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
ideque& get_deque() const
|
||||
ideque& container() const
|
||||
{
|
||||
return *p_deque;
|
||||
}
|
||||
@ -635,13 +707,13 @@ namespace etl
|
||||
//***************************************************
|
||||
void swap(const_iterator& other)
|
||||
{
|
||||
swap(index, other.index);
|
||||
ETL_OR_STD::swap(index, other.index);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//***************************************************
|
||||
difference_type distance(difference_type firstIndex, difference_type index_)
|
||||
difference_type distance(difference_type firstIndex, difference_type index_) const
|
||||
{
|
||||
if (index_ < firstIndex)
|
||||
{
|
||||
@ -662,7 +734,7 @@ namespace etl
|
||||
}
|
||||
|
||||
difference_type index;
|
||||
ideque* p_deque;
|
||||
ideque* p_deque;
|
||||
pointer p_buffer;
|
||||
};
|
||||
|
||||
@ -696,9 +768,6 @@ namespace etl
|
||||
|
||||
initialise();
|
||||
|
||||
_begin.index = 0;
|
||||
_end.index = 0;
|
||||
|
||||
while (n > 0)
|
||||
{
|
||||
create_element_back(value);
|
||||
@ -1011,7 +1080,7 @@ namespace etl
|
||||
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is full.
|
||||
///\param insert_position>The insert position.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT)
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT
|
||||
template <typename ... Args>
|
||||
iterator emplace(const_iterator insert_position, Args && ... args)
|
||||
{
|
||||
@ -1027,7 +1096,7 @@ namespace etl
|
||||
p = etl::addressof(*_begin);
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
position = _begin;
|
||||
position = _begin;
|
||||
}
|
||||
else if (insert_position == end())
|
||||
{
|
||||
@ -1035,7 +1104,7 @@ namespace etl
|
||||
++_end;
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
position = _end - 1;
|
||||
position = _end - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1094,7 +1163,7 @@ namespace etl
|
||||
p = etl::addressof(*_begin);
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
position = _begin;
|
||||
position = _begin;
|
||||
}
|
||||
else if (insert_position == end())
|
||||
{
|
||||
@ -1102,7 +1171,7 @@ namespace etl
|
||||
++_end;
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
position = _end - 1;
|
||||
position = _end - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1159,7 +1228,7 @@ namespace etl
|
||||
p = etl::addressof(*_begin);
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
position = _begin;
|
||||
position = _begin;
|
||||
}
|
||||
else if (insert_position == end())
|
||||
{
|
||||
@ -1167,7 +1236,7 @@ namespace etl
|
||||
++_end;
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
position = _end - 1;
|
||||
position = _end - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1224,7 +1293,7 @@ namespace etl
|
||||
p = etl::addressof(*_begin);
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
position = _begin;
|
||||
position = _begin;
|
||||
}
|
||||
else if (insert_position == end())
|
||||
{
|
||||
@ -1232,7 +1301,7 @@ namespace etl
|
||||
++_end;
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
position = _end - 1;
|
||||
position = _end - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1289,7 +1358,7 @@ namespace etl
|
||||
p = etl::addressof(*_begin);
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
position = _begin;
|
||||
position = _begin;
|
||||
}
|
||||
else if (insert_position == end())
|
||||
{
|
||||
@ -1297,7 +1366,7 @@ namespace etl
|
||||
++_end;
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
position = _end - 1;
|
||||
position = _end - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1682,7 +1751,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT)
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT
|
||||
//*************************************************************************
|
||||
/// Emplaces an item to the back of the deque.
|
||||
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
|
||||
@ -1810,7 +1879,7 @@ namespace etl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT)
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT
|
||||
//*************************************************************************
|
||||
/// Emplaces an item to the front of the deque.
|
||||
/// If asserts or exceptions are enabled, throws an etl::deque_full if the deque is already full.
|
||||
@ -2022,7 +2091,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
ideque(pointer p_buffer_, size_t max_size_, size_t buffer_size_)
|
||||
: deque_base(max_size_, buffer_size_),
|
||||
p_buffer(p_buffer_)
|
||||
p_buffer(p_buffer_)
|
||||
{
|
||||
}
|
||||
|
||||
@ -2033,7 +2102,7 @@ namespace etl
|
||||
{
|
||||
if ETL_IF_CONSTEXPR(etl::is_trivially_destructible<T>::value)
|
||||
{
|
||||
current_size = 0;
|
||||
current_size = 0;
|
||||
ETL_RESET_DEBUG_COUNT
|
||||
}
|
||||
else
|
||||
@ -2045,7 +2114,7 @@ namespace etl
|
||||
}
|
||||
|
||||
_begin = iterator(0, *this, p_buffer);
|
||||
_end = iterator(0, *this, p_buffer);
|
||||
_end = iterator(0, *this, p_buffer);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -2056,7 +2125,7 @@ namespace etl
|
||||
p_buffer = p_buffer_;
|
||||
|
||||
_begin = iterator(_begin.index, *this, p_buffer);
|
||||
_end = iterator(_end.index, *this, p_buffer);
|
||||
_end = iterator(_end.index, *this, p_buffer);
|
||||
}
|
||||
|
||||
iterator _begin; ///Iterator to the _begin item in the deque.
|
||||
@ -2087,16 +2156,7 @@ namespace etl
|
||||
return;
|
||||
}
|
||||
|
||||
if (!empty())
|
||||
{
|
||||
--_begin;
|
||||
--n;
|
||||
}
|
||||
|
||||
if (n > 0)
|
||||
{
|
||||
_begin -= n;
|
||||
}
|
||||
_begin -= n;
|
||||
|
||||
iterator item = _begin;
|
||||
|
||||
@ -2106,7 +2166,7 @@ namespace etl
|
||||
++from;
|
||||
++current_size;
|
||||
ETL_INCREMENT_DEBUG_COUNT
|
||||
} while (n-- != 0);
|
||||
} while (--n != 0);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -2174,7 +2234,7 @@ namespace etl
|
||||
(*_begin).~T();
|
||||
--current_size;
|
||||
ETL_DECREMENT_DEBUG_COUNT
|
||||
++_begin;
|
||||
++_begin;
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -2207,8 +2267,8 @@ namespace etl
|
||||
static difference_type distance(const TIterator& other)
|
||||
{
|
||||
const difference_type index = other.get_index();
|
||||
const difference_type reference_index = other.get_deque()._begin.index;
|
||||
const size_t buffer_size = other.get_deque().BUFFER_SIZE;
|
||||
const difference_type reference_index = other.container()._begin.index;
|
||||
const size_t buffer_size = other.container().BUFFER_SIZE;
|
||||
|
||||
if (index < reference_index)
|
||||
{
|
||||
@ -2251,18 +2311,18 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
static const size_t MAX_SIZE = MAX_SIZE_;
|
||||
static ETL_CONSTANT size_t MAX_SIZE = MAX_SIZE_;
|
||||
|
||||
private:
|
||||
|
||||
static const size_t BUFFER_SIZE = MAX_SIZE + 1;
|
||||
static ETL_CONSTANT size_t BUFFER_SIZE = MAX_SIZE + 1;
|
||||
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
typedef T& reference;
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
typedef size_t size_type;
|
||||
typedef typename etl::iterator_traits<pointer>::difference_type difference_type;
|
||||
@ -2271,7 +2331,7 @@ namespace etl
|
||||
/// Default constructor.
|
||||
//*************************************************************************
|
||||
deque()
|
||||
: etl::ideque<T>(reinterpret_cast<T*>(&buffer[0]), MAX_SIZE, BUFFER_SIZE)
|
||||
: etl::ideque<T>(reinterpret_cast<T*>(buffer.raw), MAX_SIZE, BUFFER_SIZE)
|
||||
{
|
||||
this->initialise();
|
||||
}
|
||||
@ -2288,7 +2348,7 @@ namespace etl
|
||||
/// Copy constructor.
|
||||
//*************************************************************************
|
||||
deque(const deque& other)
|
||||
: etl::ideque<T>(reinterpret_cast<T*>(&buffer[0]), MAX_SIZE, BUFFER_SIZE)
|
||||
: etl::ideque<T>(reinterpret_cast<T*>(buffer.raw), MAX_SIZE, BUFFER_SIZE)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
@ -2301,7 +2361,7 @@ namespace etl
|
||||
/// Move constructor.
|
||||
//*************************************************************************
|
||||
deque(deque&& other)
|
||||
: etl::ideque<T>(reinterpret_cast<T*>(&buffer[0]), MAX_SIZE, BUFFER_SIZE)
|
||||
: etl::ideque<T>(reinterpret_cast<T*>(buffer.raw), MAX_SIZE, BUFFER_SIZE)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
@ -2313,8 +2373,6 @@ namespace etl
|
||||
this->push_back(etl::move(*itr));
|
||||
++itr;
|
||||
}
|
||||
|
||||
other.initialise();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -2322,9 +2380,9 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Assigns data to the deque.
|
||||
//*************************************************************************
|
||||
template <typename TIterator>
|
||||
template <typename TIterator, typename etl::enable_if<!etl::is_integral<TIterator>::value, int>::type = 0>
|
||||
deque(TIterator begin_, TIterator end_)
|
||||
: etl::ideque<T>(reinterpret_cast<T*>(&buffer[0]), MAX_SIZE, BUFFER_SIZE)
|
||||
: etl::ideque<T>(reinterpret_cast<T*>(buffer.raw), MAX_SIZE, BUFFER_SIZE)
|
||||
{
|
||||
this->assign(begin_, end_);
|
||||
}
|
||||
@ -2333,17 +2391,17 @@ namespace etl
|
||||
/// Assigns data to the deque.
|
||||
//*************************************************************************
|
||||
explicit deque(size_t n, const_reference value = value_type())
|
||||
: etl::ideque<T>(reinterpret_cast<T*>(&buffer[0]), MAX_SIZE, BUFFER_SIZE)
|
||||
: etl::ideque<T>(reinterpret_cast<T*>(buffer.raw), MAX_SIZE, BUFFER_SIZE)
|
||||
{
|
||||
this->assign(n, value);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
deque(std::initializer_list<T> init)
|
||||
: ideque<T>(reinterpret_cast<T*>(&buffer[0]), MAX_SIZE, BUFFER_SIZE)
|
||||
: ideque<T>(reinterpret_cast<T*>(buffer.raw), MAX_SIZE, BUFFER_SIZE)
|
||||
{
|
||||
this->assign(init.begin(), init.end());
|
||||
}
|
||||
@ -2377,8 +2435,6 @@ namespace etl
|
||||
this->push_back(etl::move(*itr));
|
||||
++itr;
|
||||
}
|
||||
|
||||
rhs.initialise();
|
||||
}
|
||||
|
||||
return *this;
|
||||
@ -2388,24 +2444,33 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
#ifdef ETL_IDEQUE_REPAIR_ENABLE
|
||||
virtual
|
||||
#endif
|
||||
void repair()
|
||||
#ifdef ETL_ISTRING_REPAIR_ENABLE
|
||||
ETL_OVERRIDE
|
||||
#endif
|
||||
{
|
||||
#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
|
||||
ETL_ASSERT(etl::is_trivially_copyable<T>::value, ETL_ERROR(etl::deque_incompatible_type));
|
||||
#endif
|
||||
|
||||
etl::ideque<T>::repair_buffer(reinterpret_cast<T*>(&buffer[0]));
|
||||
etl::ideque<T>::repair_buffer(reinterpret_cast<T*>(buffer.raw));
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/// The uninitialised buffer of T used in the deque.
|
||||
typename etl::aligned_storage<sizeof(T), etl::alignment_of<T>::value>::type buffer[BUFFER_SIZE];
|
||||
etl::uninitialized_buffer_of<T, BUFFER_SIZE> buffer;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
template <typename T, typename... Ts>
|
||||
deque(T, Ts...)
|
||||
->deque<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), T>, 1U + sizeof...(Ts)>;
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Equal operator.
|
||||
///\param lhs Reference to the _begin deque.
|
||||
@ -2443,9 +2508,9 @@ namespace etl
|
||||
bool operator <(const etl::ideque<T>& lhs, const etl::ideque<T>& rhs)
|
||||
{
|
||||
return etl::lexicographical_compare(lhs.begin(),
|
||||
lhs.end(),
|
||||
rhs.begin(),
|
||||
rhs.end());
|
||||
lhs.end(),
|
||||
rhs.begin(),
|
||||
rhs.end());
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -2488,8 +2553,6 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
#undef ETL_FILE
|
||||
|
||||
#include "private/minmax_pop.h"
|
||||
|
||||
#endif
|
||||
|
||||
@ -135,7 +135,7 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(ETL_NO_64BIT_TYPES)
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
//***************************************************************************
|
||||
inline uint64_t ntoh(const uint64_t network)
|
||||
{
|
||||
@ -182,7 +182,7 @@ namespace etl
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(ETL_NO_64BIT_TYPES)
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
//***************************************************************************
|
||||
inline uint64_t hton(const uint64_t host)
|
||||
{
|
||||
|
||||
@ -84,7 +84,7 @@ SOFTWARE.
|
||||
//*****************************************************************************
|
||||
#define ETL_DECLARE_ENUM_TYPE(TypeName, ValueType) \
|
||||
typedef ValueType value_type; \
|
||||
TypeName() {} \
|
||||
TypeName() : value(static_cast<enum_type>(value_type())) {} \
|
||||
TypeName(const TypeName &other) : value(other.value) {} \
|
||||
TypeName(enum_type value_) : value(value_) {} \
|
||||
TypeName& operator=(const TypeName &other) {value = other.value; return *this;} \
|
||||
|
||||
@ -41,21 +41,11 @@ SOFTWARE.
|
||||
#include "platform.h"
|
||||
#include "exception.h"
|
||||
#include "function.h"
|
||||
#include "nullptr.h"
|
||||
|
||||
#if defined(ETL_LOG_ERRORS) || defined(ETL_IN_UNIT_TEST)
|
||||
namespace etl
|
||||
{
|
||||
namespace private_error_handler
|
||||
{
|
||||
template <class dummy>
|
||||
struct wrapper
|
||||
{
|
||||
static etl::ifunction<const etl::exception&>* p_ifunction;
|
||||
};
|
||||
|
||||
template <class dummy>
|
||||
etl::ifunction<const etl::exception&>* wrapper<dummy>::p_ifunction = nullptr;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Error handler for when throwing exceptions is not required.
|
||||
///\ingroup error_handler
|
||||
@ -65,18 +55,18 @@ namespace etl
|
||||
public:
|
||||
|
||||
//*************************************************************************
|
||||
/// Callback class for free handler functions.
|
||||
/// Callback class for free handler functions. Deprecated.
|
||||
//*************************************************************************
|
||||
struct free_function : public etl::function<void, const etl::exception&>
|
||||
{
|
||||
free_function(void (*p_function_)(const etl::exception&))
|
||||
explicit free_function(void (*p_function_)(const etl::exception&))
|
||||
: etl::function<void, const etl::exception&>(p_function_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Callback class for member handler functions.
|
||||
/// Callback class for member handler functions. Deprecated.
|
||||
//*************************************************************************
|
||||
template <typename TObject>
|
||||
struct member_function : public etl::function<TObject, const etl::exception&>
|
||||
@ -88,12 +78,57 @@ namespace etl
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
/// Sets the error callback function.
|
||||
/// Sets the error callback function. Deprecated.
|
||||
///\param f A reference to an etl::function object that will handler errors.
|
||||
//*****************************************************************************
|
||||
static void set_callback(ifunction<const etl::exception&>& f)
|
||||
{
|
||||
private_error_handler::wrapper<void>::p_ifunction = &f;
|
||||
create((void*)(&f), ifunction_stub);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Create from function (Compile time).
|
||||
//*************************************************************************
|
||||
template <void(*Method)(const etl::exception&)>
|
||||
static void set_callback()
|
||||
{
|
||||
create(ETL_NULLPTR, function_stub<Method>);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Create from instance method (Run time).
|
||||
//*************************************************************************
|
||||
template <typename T, void(T::* Method)(const etl::exception&)>
|
||||
static void set_callback(T& instance)
|
||||
{
|
||||
create((void*)(&instance), method_stub<T, Method>);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Create from const instance method (Run time).
|
||||
//*************************************************************************
|
||||
template <typename T, void(T::* Method)(const etl::exception&) const>
|
||||
static void set_callback(const T& instance)
|
||||
{
|
||||
create((void*)(&instance), const_method_stub<T, Method>);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Create from instance method (Compile time).
|
||||
//*************************************************************************
|
||||
template <typename T, T& Instance, void(T::* Method)(const etl::exception&)>
|
||||
static void set_callback()
|
||||
{
|
||||
create(method_instance_stub<T, Instance, Method>);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Create from const instance method (Compile time).
|
||||
//*************************************************************************
|
||||
template <typename T, T const& Instance, void(T::* Method)(const etl::exception&) const>
|
||||
static void set_callback()
|
||||
{
|
||||
create(const_method_instance_stub<T, Instance, Method>);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
@ -102,13 +137,125 @@ namespace etl
|
||||
//*****************************************************************************
|
||||
static void error(const etl::exception& e)
|
||||
{
|
||||
if (private_error_handler::wrapper<void>::p_ifunction != nullptr)
|
||||
invocation_element& invocation = get_invocation_element();
|
||||
|
||||
if (invocation.stub != ETL_NULLPTR)
|
||||
{
|
||||
(*private_error_handler::wrapper<void>::p_ifunction)(e);
|
||||
(*invocation.stub)(invocation.object, e);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
typedef void(*stub_type)(void* object, const etl::exception&);
|
||||
|
||||
//*************************************************************************
|
||||
/// The internal invocation object.
|
||||
//*************************************************************************
|
||||
struct invocation_element
|
||||
{
|
||||
//***********************************************************************
|
||||
invocation_element()
|
||||
: object(ETL_NULLPTR)
|
||||
, stub(ETL_NULLPTR)
|
||||
{
|
||||
}
|
||||
|
||||
//***********************************************************************
|
||||
void* object;
|
||||
stub_type stub;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns the static invocation element.
|
||||
//*************************************************************************
|
||||
static invocation_element& get_invocation_element()
|
||||
{
|
||||
static invocation_element invocation;
|
||||
|
||||
return invocation;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructs a callback from an object and stub.
|
||||
//*************************************************************************
|
||||
static void create(void* object, stub_type stub)
|
||||
{
|
||||
invocation_element& invocation = get_invocation_element();
|
||||
|
||||
invocation.object = object;
|
||||
invocation.stub = stub;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructs a callback from a stub.
|
||||
//*************************************************************************
|
||||
static void create(stub_type stub)
|
||||
{
|
||||
invocation_element& invocation = get_invocation_element();
|
||||
|
||||
invocation.object = ETL_NULLPTR;
|
||||
invocation.stub = stub;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Stub call for a member function. Run time instance.
|
||||
//*************************************************************************
|
||||
template <typename T, void(T::* Method)(const etl::exception&)>
|
||||
static void method_stub(void* object, const etl::exception& e)
|
||||
{
|
||||
T* p = static_cast<T*>(object);
|
||||
return (p->*Method)(e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Stub call for a const member function. Run time instance.
|
||||
//*************************************************************************
|
||||
template <typename T, void(T::* Method)(const etl::exception&) const>
|
||||
static void const_method_stub(void* object, const etl::exception& e)
|
||||
{
|
||||
T* const p = static_cast<T*>(object);
|
||||
return (p->*Method)(e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Stub call for a member function. Compile time instance.
|
||||
//*************************************************************************
|
||||
template <typename T, T& Instance, void(T::* Method)(const etl::exception&)>
|
||||
static void method_instance_stub(void*, const etl::exception& e)
|
||||
{
|
||||
return (Instance.*Method)(e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Stub call for a const member function. Compile time instance.
|
||||
//*************************************************************************
|
||||
template <typename T, const T& Instance, void(T::* Method)(const etl::exception&) const>
|
||||
static void const_method_instance_stub(void*, const etl::exception& e)
|
||||
{
|
||||
(Instance.*Method)(e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Stub call for a free function.
|
||||
//*************************************************************************
|
||||
template <void(*Method)(const etl::exception&)>
|
||||
static void function_stub(void*, const etl::exception& e)
|
||||
{
|
||||
(Method)(e);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Stub call for a ifunction. Run time instance.
|
||||
//*************************************************************************
|
||||
static void ifunction_stub(void* object, const etl::exception& e)
|
||||
{
|
||||
etl::ifunction<const etl::exception&>* p = static_cast<etl::ifunction<const etl::exception&>*>(object);
|
||||
p->operator()(e);
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Asserts a condition.
|
||||
@ -133,20 +280,15 @@ namespace etl
|
||||
#endif
|
||||
#else
|
||||
#if defined(ETL_LOG_ERRORS)
|
||||
#if defined(NDEBUG)
|
||||
#define ETL_ASSERT(b, e) {if(!(b)) {etl::error_handler::error((e));}} // If the condition fails, calls the error handler
|
||||
#define ETL_ALWAYS_ASSERT(e) {etl::error_handler::error((e));} // Calls the error handler
|
||||
#else
|
||||
#define ETL_ASSERT(b, e) {if(!(b)) {etl::error_handler::error((e)); assert(false);}} // If the condition fails, calls the error handler then asserts.
|
||||
#define ETL_ALWAYS_ASSERT(e) {etl::error_handler::error((e)); assert(false);} // Calls the error handler then asserts.
|
||||
#endif
|
||||
#define ETL_ASSERT(b, e) {if(!(b)) {etl::error_handler::error((e));}} // If the condition fails, calls the error handler
|
||||
#define ETL_ALWAYS_ASSERT(e) {etl::error_handler::error((e));} // Calls the error handler
|
||||
#else
|
||||
#if defined(NDEBUG)
|
||||
#define ETL_ASSERT(b, e) // Does nothing.
|
||||
#define ETL_ALWAYS_ASSERT(e) // Does nothing.
|
||||
#else
|
||||
#if defined(ETL_DEBUG)
|
||||
#define ETL_ASSERT(b, e) assert((b)) // If the condition fails, asserts.
|
||||
#define ETL_ALWAYS_ASSERT(e) assert(false) // Asserts.
|
||||
#else
|
||||
#define ETL_ASSERT(b, e) // Does nothing.
|
||||
#define ETL_ALWAYS_ASSERT(e) // Does nothing.
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
509
include/etl/experimental/variant_new.h
Normal file
509
include/etl/experimental/variant_new.h
Normal file
@ -0,0 +1,509 @@
|
||||
///\file
|
||||
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2020 jwellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef ETL_VARIANT_NEW_INCLUDED
|
||||
#define ETL_VARIANT_NEW_INCLUDED
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "private/new.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "utility.h"
|
||||
#include "array.h"
|
||||
#include "largest.h"
|
||||
#include "exception.h"
|
||||
#include "type_traits.h"
|
||||
#include "integral_limits.h"
|
||||
#include "static_assert.h"
|
||||
#include "alignment.h"
|
||||
#include "error_handler.h"
|
||||
#include "null_type.h"
|
||||
|
||||
#if defined(ETL_COMPILER_KEIL)
|
||||
#pragma diag_suppress 940
|
||||
#pragma diag_suppress 111
|
||||
#endif
|
||||
|
||||
#undef ETL_FILE
|
||||
#define ETL_FILE "24"
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
|
||||
//*****************************************************************************
|
||||
///\defgroup variant variant
|
||||
/// A class that can contain one a several specified types in a type safe manner.
|
||||
///\ingroup containers
|
||||
//*****************************************************************************
|
||||
|
||||
namespace etl
|
||||
{
|
||||
//***************************************************************************
|
||||
/// Base exception for the variant class.
|
||||
///\ingroup variant
|
||||
//***************************************************************************
|
||||
class variant_exception : public exception
|
||||
{
|
||||
public:
|
||||
variant_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
|
||||
: exception(reason_, file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// 'Unsupported type' exception for the variant class.
|
||||
///\ingroup variant
|
||||
//***************************************************************************
|
||||
class variant_incorrect_type_exception : public variant_exception
|
||||
{
|
||||
public:
|
||||
variant_incorrect_type_exception(string_type file_name_, numeric_type line_number_)
|
||||
: variant_exception(ETL_ERROR_TEXT("variant: unsupported type", ETL_FILE"A"), file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// A template class that can store any of the types defined in the template parameter list.
|
||||
/// Supports up to 8 types.
|
||||
///\ingroup variant
|
||||
//***************************************************************************
|
||||
template <typename... TVariants>
|
||||
class variant
|
||||
{
|
||||
public:
|
||||
|
||||
//***************************************************************************
|
||||
/// The id a unsupported types.
|
||||
//***************************************************************************
|
||||
static ETL_CONST_OR_CONSTEXPR size_t npos = -1;
|
||||
|
||||
private:
|
||||
|
||||
// All types of variant are friends.
|
||||
template <typename... U>
|
||||
friend class variant;
|
||||
|
||||
//***************************************************************************
|
||||
/// The largest type.
|
||||
//***************************************************************************
|
||||
typedef typename largest_type<TVariants...>::type largest_t;
|
||||
|
||||
//***************************************************************************
|
||||
/// The largest size.
|
||||
//***************************************************************************
|
||||
static const size_t SIZE = sizeof(largest_t);
|
||||
|
||||
//***************************************************************************
|
||||
/// The largest alignment.
|
||||
//***************************************************************************
|
||||
static const size_t ALIGNMENT = etl::largest_alignment<TVariants...>::value;
|
||||
|
||||
public:
|
||||
|
||||
//***************************************************************************
|
||||
/// Destructor.
|
||||
//***************************************************************************
|
||||
~variant()
|
||||
{
|
||||
destruct_current();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Default constructor.
|
||||
/// Sets the state of the instance to containing no valid data.
|
||||
//***************************************************************************
|
||||
variant()
|
||||
: type_id(UNSUPPORTED_TYPE_ID)
|
||||
{
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Constructor that catches any types that are not supported.
|
||||
/// Forces a ETL_STATIC_ASSERT.
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
variant(const T& value)
|
||||
{
|
||||
ETL_STATIC_ASSERT(etl::index_of<T, TVariants>::value != etl::index_of<T, TVariants>::npos, "Unsupported type");
|
||||
|
||||
::new (static_cast<T*>(data)) T(value);
|
||||
type_id = etl::index_of<T, TVariants>::value;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Copy constructor.
|
||||
///\param other The other variant object to copy.
|
||||
//***************************************************************************
|
||||
variant(const variant& other)
|
||||
{
|
||||
switch (other.type_id)
|
||||
{
|
||||
case 0: ::new (static_cast<T1*>(data)) T1(other.get<T1>()); break;
|
||||
case 1: ::new (static_cast<T2*>(data)) T2(other.get<T2>()); break;
|
||||
case 2: ::new (static_cast<T3*>(data)) T3(other.get<T3>()); break;
|
||||
case 3: ::new (static_cast<T4*>(data)) T4(other.get<T4>()); break;
|
||||
case 4: ::new (static_cast<T5*>(data)) T5(other.get<T5>()); break;
|
||||
case 5: ::new (static_cast<T6*>(data)) T6(other.get<T6>()); break;
|
||||
case 6: ::new (static_cast<T7*>(data)) T7(other.get<T7>()); break;
|
||||
case 7: ::new (static_cast<T8*>(data)) T8(other.get<T8>()); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
type_id = other.type_id;
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && !defined(ETL_VARIANT_FORCE_CPP03)
|
||||
//*************************************************************************
|
||||
/// Emplace with variadic constructor parameters.
|
||||
//*************************************************************************
|
||||
template <typename T, typename... Args>
|
||||
T& emplace(Args&&... args)
|
||||
{
|
||||
ETL_STATIC_ASSERT(Type_Is_Supported<T>::value, "Unsupported type");
|
||||
|
||||
destruct_current();
|
||||
::new (static_cast<T*>(data)) T(etl::forward<Args>(args)...);
|
||||
type_id = Type_Id_Lookup<T>::type_id;
|
||||
|
||||
return *static_cast<T*>(data);
|
||||
}
|
||||
#else
|
||||
//***************************************************************************
|
||||
/// Emplace with one constructor parameter.
|
||||
//***************************************************************************
|
||||
template <typename T, typename TP1>
|
||||
T& emplace(const TP1& value1)
|
||||
{
|
||||
ETL_STATIC_ASSERT(Type_Is_Supported<T>::value, "Unsupported type");
|
||||
|
||||
destruct_current();
|
||||
::new (static_cast<T*>(data)) T(value1);
|
||||
type_id = Type_Id_Lookup<T>::type_id;
|
||||
|
||||
return *static_cast<T*>(data);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Emplace with two constructor parameters.
|
||||
//***************************************************************************
|
||||
template <typename T, typename TP1, typename TP2>
|
||||
T& emplace(const TP1& value1, const TP2& value2)
|
||||
{
|
||||
ETL_STATIC_ASSERT(Type_Is_Supported<T>::value, "Unsupported type");
|
||||
|
||||
destruct_current();
|
||||
::new (static_cast<T*>(data)) T(value1, value2);
|
||||
type_id = Type_Id_Lookup<T>::type_id;
|
||||
|
||||
return *static_cast<T*>(data);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Emplace with three constructor parameters.
|
||||
//***************************************************************************
|
||||
template <typename T, typename TP1, typename TP2, typename TP3>
|
||||
T& emplace(const TP1& value1, const TP2& value2, const TP3& value3)
|
||||
{
|
||||
ETL_STATIC_ASSERT(Type_Is_Supported<T>::value, "Unsupported type");
|
||||
|
||||
destruct_current();
|
||||
::new (static_cast<T*>(data)) T(value1, value2, value3);
|
||||
type_id = Type_Id_Lookup<T>::type_id;
|
||||
|
||||
return *static_cast<T*>(data);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Emplace with four constructor parameters.
|
||||
//***************************************************************************
|
||||
template <typename T, typename TP1, typename TP2, typename TP3, typename TP4>
|
||||
T& emplace(const TP1& value1, const TP2& value2, const TP3& value3, const TP4& value4)
|
||||
{
|
||||
ETL_STATIC_ASSERT(Type_Is_Supported<T>::value, "Unsupported type");
|
||||
|
||||
destruct_current();
|
||||
::new (static_cast<T*>(data)) T(value1, value2, value3, value4);
|
||||
type_id = Type_Id_Lookup<T>::type_id;
|
||||
|
||||
return *static_cast<T*>(data);
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Assignment operator for T1 type.
|
||||
///\param value The value to assign.
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
variant& operator =(const T& value)
|
||||
{
|
||||
ETL_STATIC_ASSERT(Type_Is_Supported<T>::value, "Unsupported type");
|
||||
|
||||
destruct_current();
|
||||
::new (static_cast<T*>(data)) T(value);
|
||||
type_id = Type_Id_Lookup<T>::type_id;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Assignment operator for variant type.
|
||||
///\param other The variant to assign.
|
||||
//***************************************************************************
|
||||
variant& operator =(const variant& other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
destruct_current();
|
||||
|
||||
switch (other.type_id)
|
||||
{
|
||||
case 0: ::new (static_cast<T1*>(data)) T1(other.get<T1>()); break;
|
||||
case 1: ::new (static_cast<T2*>(data)) T2(other.get<T2>()); break;
|
||||
case 2: ::new (static_cast<T3*>(data)) T3(other.get<T3>()); break;
|
||||
case 3: ::new (static_cast<T4*>(data)) T4(other.get<T4>()); break;
|
||||
case 4: ::new (static_cast<T5*>(data)) T5(other.get<T5>()); break;
|
||||
case 5: ::new (static_cast<T6*>(data)) T6(other.get<T6>()); break;
|
||||
case 6: ::new (static_cast<T7*>(data)) T7(other.get<T7>()); break;
|
||||
case 7: ::new (static_cast<T8*>(data)) T8(other.get<T8>()); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
type_id = other.type_id;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Checks if the type is the same as the current stored type.
|
||||
/// For variants with the same type declarations.
|
||||
///\return <b>true</b> if the types are the same, otherwise <b>false</b>.
|
||||
//***************************************************************************
|
||||
bool is_same_type(const variant& other) const
|
||||
{
|
||||
return type_id == other.type_id;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Checks if the type is the same as the current stored type.
|
||||
/// For variants with differing declarations.
|
||||
///\return <b>true</b> if the types are the same, otherwise <b>false</b>.
|
||||
//***************************************************************************
|
||||
template <typename U1, typename U2, typename U3, typename U4, typename U5, typename U6, typename U7, typename U8>
|
||||
bool is_same_type(const variant<U1, U2, U3, U4, U5, U6, U7, U8>& other) const
|
||||
{
|
||||
bool is_same = false;
|
||||
|
||||
switch (other.type_id)
|
||||
{
|
||||
case 0: is_same = (type_id == Type_Id_Lookup<U1>::type_id); break;
|
||||
case 1: is_same = (type_id == Type_Id_Lookup<U2>::type_id); break;
|
||||
case 2: is_same = (type_id == Type_Id_Lookup<U3>::type_id); break;
|
||||
case 3: is_same = (type_id == Type_Id_Lookup<U4>::type_id); break;
|
||||
case 4: is_same = (type_id == Type_Id_Lookup<U5>::type_id); break;
|
||||
case 5: is_same = (type_id == Type_Id_Lookup<U6>::type_id); break;
|
||||
case 6: is_same = (type_id == Type_Id_Lookup<U7>::type_id); break;
|
||||
case 7: is_same = (type_id == Type_Id_Lookup<U8>::type_id); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return is_same;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Calls the supplied reader instance.
|
||||
/// The 'read' function appropriate to the current type is called with the stored value.
|
||||
//***************************************************************************
|
||||
void call(reader& r)
|
||||
{
|
||||
switch (type_id)
|
||||
{
|
||||
case 0: r.read(static_cast<T1&>(data)); break;
|
||||
case 1: r.read(static_cast<T2&>(data)); break;
|
||||
case 2: r.read(static_cast<T3&>(data)); break;
|
||||
case 3: r.read(static_cast<T4&>(data)); break;
|
||||
case 4: r.read(static_cast<T5&>(data)); break;
|
||||
case 5: r.read(static_cast<T6&>(data)); break;
|
||||
case 6: r.read(static_cast<T7&>(data)); break;
|
||||
case 7: r.read(static_cast<T8&>(data)); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Checks whether a valid value is currently stored.
|
||||
///\return <b>true</b> if the value is valid, otherwise <b>false</b>.
|
||||
//***************************************************************************
|
||||
bool is_valid() const
|
||||
{
|
||||
return type_id != UNSUPPORTED_TYPE_ID;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Checks to see if the type currently stored is the same as that specified in the template parameter.
|
||||
///\return <b>true</b> if it is the specified type, otherwise <b>false</b>.
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
bool is_type() const
|
||||
{
|
||||
return type_id == Type_Id_Lookup<T>::type_id;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Gets the index of the type currently stored or UNSUPPORTED_TYPE_ID
|
||||
//***************************************************************************
|
||||
size_t index() const
|
||||
{
|
||||
return type_id;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Clears the value to 'no valid stored value'.
|
||||
//***************************************************************************
|
||||
void clear()
|
||||
{
|
||||
destruct_current();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Gets the value stored as the specified template type.
|
||||
/// Throws a variant_incorrect_type_exception if the actual type is not that specified.
|
||||
///\return A reference to the value.
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
T& get()
|
||||
{
|
||||
ETL_STATIC_ASSERT(Type_Is_Supported<T>::value, "Unsupported type");
|
||||
ETL_ASSERT(is_type<T>(), ETL_ERROR(variant_incorrect_type_exception));
|
||||
|
||||
return static_cast<T&>(data);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Gets the value stored as the specified template type.
|
||||
/// Throws a variant_incorrect_type_exception if the actual type is not that specified.
|
||||
///\return A const reference to the value.
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
const T& get() const
|
||||
{
|
||||
ETL_STATIC_ASSERT(Type_Is_Supported<T>::value, "Unsupported type");
|
||||
ETL_ASSERT(is_type<T>(), ETL_ERROR(variant_incorrect_type_exception));
|
||||
|
||||
return static_cast<const T&>(data);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Gets the value stored as the specified template type.
|
||||
///\return A reference to the value.
|
||||
//***************************************************************************
|
||||
template <typename TBase>
|
||||
TBase& upcast()
|
||||
{
|
||||
return upcast_functor<TBase, T1, T2, T3, T4, T5, T6, T7, T8>()(data, type_id);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Gets the value stored as the specified template type.
|
||||
///\return A const reference to the value.
|
||||
//***************************************************************************
|
||||
template <typename TBase>
|
||||
const TBase& upcast() const
|
||||
{
|
||||
return upcast_functor<TBase, T1, T2, T3, T4, T5, T6, T7, T8>()(data, type_id);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Conversion operators for each type.
|
||||
//***************************************************************************
|
||||
operator T1&() { return get<T1>(); }
|
||||
operator T2&() { return get<T2>(); }
|
||||
operator T3&() { return get<T3>(); }
|
||||
operator T4&() { return get<T4>(); }
|
||||
operator T5&() { return get<T5>(); }
|
||||
operator T6&() { return get<T6>(); }
|
||||
operator T7&() { return get<T7>(); }
|
||||
operator T8&() { return get<T8>(); }
|
||||
|
||||
//***************************************************************************
|
||||
/// Checks if the template type is supported by the implementation of variant..
|
||||
///\return <b>true</b> if the type is supported, otherwise <b>false</b>.
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
static bool is_supported_type()
|
||||
{
|
||||
return Type_Is_Supported<T>::value;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//***************************************************************************
|
||||
/// Destruct the current occupant of the variant.
|
||||
//***************************************************************************
|
||||
void destruct_current()
|
||||
{
|
||||
switch (type_id)
|
||||
{
|
||||
case 0: { static_cast<T1*>(data)->~T1(); break; }
|
||||
case 1: { static_cast<T2*>(data)->~T2(); break; }
|
||||
case 2: { static_cast<T3*>(data)->~T3(); break; }
|
||||
case 3: { static_cast<T4*>(data)->~T4(); break; }
|
||||
case 4: { static_cast<T5*>(data)->~T5(); break; }
|
||||
case 5: { static_cast<T6*>(data)->~T6(); break; }
|
||||
case 6: { static_cast<T7*>(data)->~T7(); break; }
|
||||
case 7: { static_cast<T8*>(data)->~T8(); break; }
|
||||
default: { break; }
|
||||
}
|
||||
|
||||
type_id = UNSUPPORTED_TYPE_ID;
|
||||
}
|
||||
|
||||
constexpr size_t NUMBER_OF_VARIANTS = sizeof...(TVariants);
|
||||
|
||||
//***************************************************************************
|
||||
/// The internal storage.
|
||||
/// Aligned on a suitable boundary, which should be good for all types.
|
||||
//***************************************************************************
|
||||
typename etl::aligned_storage<SIZE, ALIGNMENT>::type data;
|
||||
|
||||
//***************************************************************************
|
||||
/// The id of the current stored type.
|
||||
//***************************************************************************
|
||||
type_id_t type_id;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#undef ETL_FILE
|
||||
|
||||
#endif
|
||||
@ -49,7 +49,7 @@ namespace etl
|
||||
template <size_t N>
|
||||
struct factorial
|
||||
{
|
||||
static const size_t value = N * factorial<N - 1>::value;
|
||||
static ETL_CONSTANT size_t value = N * factorial<N - 1>::value;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
@ -58,8 +58,13 @@ namespace etl
|
||||
template <>
|
||||
struct factorial<0>
|
||||
{
|
||||
static const size_t value = 1;
|
||||
static ETL_CONSTANT size_t value = 1;
|
||||
};
|
||||
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
template <size_t N>
|
||||
inline constexpr size_t factorial_v = factorial<N>::value;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -49,7 +49,7 @@ namespace etl
|
||||
template <size_t N>
|
||||
struct fibonacci
|
||||
{
|
||||
static const size_t value = fibonacci<N - 1>::value + fibonacci<N - 2>::value;
|
||||
static ETL_CONSTANT size_t value = fibonacci<N - 1>::value + fibonacci<N - 2>::value;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
@ -58,7 +58,7 @@ namespace etl
|
||||
template <>
|
||||
struct fibonacci<1>
|
||||
{
|
||||
static const size_t value = 1;
|
||||
static ETL_CONSTANT size_t value = 1;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
@ -67,8 +67,13 @@ namespace etl
|
||||
template <>
|
||||
struct fibonacci<0>
|
||||
{
|
||||
static const size_t value = 0;
|
||||
static ETL_CONSTANT size_t value = 0;
|
||||
};
|
||||
|
||||
#if ETL_CPP17_SUPPORTED
|
||||
template <size_t N>
|
||||
inline constexpr size_t fibonacci_v = fibonacci<N>::value;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
95
include/etl/file_error_numbers.h
Normal file
95
include/etl/file_error_numbers.h
Normal file
@ -0,0 +1,95 @@
|
||||
///\file
|
||||
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2020 jwellbelove
|
||||
|
||||
Permission is hereby granted" free of charge" to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software")" to deal
|
||||
in the Software without restriction" including without limitation the rights
|
||||
to use" copy" modify" merge" publish" distribute" sublicense" and / or sell
|
||||
copies of the Software" and to permit persons to whom the Software is
|
||||
furnished to do so" subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS"" WITHOUT WARRANTY OF ANY KIND" EXPRESS OR
|
||||
IMPLIED" INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY"
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM" DAMAGES OR OTHER
|
||||
LIABILITY" WHETHER IN AN ACTION OF CONTRACT" TORT OR OTHERWISE" ARISING FROM"
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef ETL_FILE_ERROR_NUMBERS
|
||||
#define ETL_FILE_ERROR_NUMBERS
|
||||
|
||||
#define ETL_DEQUE_FILE_ID "1"
|
||||
#define ETL_FLAT_MAP_FILE_ID "2"
|
||||
#define ETL_FLAT_MULTIMAP_FILE_ID "3"
|
||||
#define ETL_FLAT_MULTISET_FILE_ID "4"
|
||||
#define ETL_FLAT_SET_FILE_ID "5"
|
||||
#define ETL_FORWARD_LIST_FILE_ID "6"
|
||||
#define ETL_LIST_FILE_ID "7"
|
||||
#define ETL_MAP_FILE_ID "8"
|
||||
#define ETL_MULTIMAP_FILE_ID "9"
|
||||
#define ETL_MULTISET_FILE_ID "10"
|
||||
#define ETL_POOL_FILE_ID "11"
|
||||
#define ETL_PRIORITY_QUEUE_FILE_ID "12"
|
||||
#define ETL_QUEUE_FILE_ID "13"
|
||||
#define ETL_SET_FILE_ID "14"
|
||||
#define ETL_STACK_FILE_ID "15"
|
||||
#define ETL_UNORDERED_MAP_FILE_ID "16"
|
||||
#define ETL_VECTOR_FILE_ID "17"
|
||||
#define ETL_OBSERVER_FILE_ID "18"
|
||||
#define ETL_IHASH_FILE_ID "19"
|
||||
#define ETL_INTRUSIVE_FORWARD_LIST_FILE_ID "20"
|
||||
#define ETL_INTRUSIVE_LIST_FILE_ID "21"
|
||||
#define ETL_INTRUSIVE_LINKS_FILE_ID "22"
|
||||
#define ETL_UNORDERED_SET_FILE_ID "23"
|
||||
#define ETL_VARIANT_FILE_ID "24"
|
||||
#define ETL_UNORDERED_MULTIMAP_FILE_ID "25"
|
||||
#define ETL_UNORDERED_MULTISET_FILE_ID "26"
|
||||
#define ETL_BASIC_STRING_FILE_ID "27"
|
||||
#define ETL_INTRUSIVE_STACK_FILE_ID "28"
|
||||
#define ETL_INTRUSIVE_QUEUE_FILE_ID "29"
|
||||
#define ETL_REFERENCE_FLAT_MAP_FILE_ID "30"
|
||||
#define ETL_REFERENCE_FLAT_MULTIMAP_FILE_ID "31"
|
||||
#define ETL_REFERENCE_FLAT_SET_FILE_ID "32"
|
||||
#define ETL_REFERENCE_FLAT_MULTISET_FILE_ID "33"
|
||||
#define ETL_FSM_FILE_ID "34"
|
||||
#define ETL_MESSAGE_ROUTER_FILE_ID "35"
|
||||
#define ETL_SCHEDULER_FILE_ID "36"
|
||||
#define ETL_TASK_FILE_ID "37"
|
||||
#define ETL_MESSAGE_FILE_ID "38"
|
||||
#define ETL_MESSAGE_BUS_FILE_ID "39"
|
||||
#define ETL_VARIANT_POOL_FILE_ID "40"
|
||||
#define ETL_ARRAY_VIEW_FILE_ID "41"
|
||||
#define ETL_STRING_VIEW_FILE_ID "42"
|
||||
#define ETL_CALLBACK_TIMER_FILE_ID "43"
|
||||
#define ETL_MESSAGE_TIMER_FILE_ID "44"
|
||||
#define ETL_TYPE_LOOKUP_FILE_ID "45"
|
||||
#define ETL_QUEUE_SPSC_ISR_FILE_ID "46"
|
||||
#define ETL_QUEUE_SPSC_ATOMIC_FILE_ID "47"
|
||||
#define ETL_QUEUE_MPMC_MUTEX_FILE_ID "48"
|
||||
#define ETL_TYPE_SELECT_FILE_ID "49"
|
||||
#define ETL_BINARY_FILE_ID "50"
|
||||
#define ETL_DELEGATE_FILE_ID "51"
|
||||
#define ETL_BITSET_FILE_ID "52"
|
||||
#define ETL_INDIRECT_VECTOR_FILE_ID "53"
|
||||
#define ETL_QUEUE_SPSC_LOCKED_FILE_ID "54"
|
||||
#define ETL_MESSAGE_PACKET_FILE_ID "55"
|
||||
#define ETL_CIRCULAR_BUFFER_FILE_ID "56"
|
||||
#define ETL_MULTI_LOOP_FILE_ID "57"
|
||||
#define ETL_REFERENCE_COUNTER_MESSAGE_POOL_FILE_ID "58"
|
||||
#define ETL_QUEUE_SPSC_LOCKABLE_FILE_ID "59"
|
||||
#define ETL_MESSAGE_ROUTER_REGISTRY_FILE_ID "60"
|
||||
|
||||
#endif
|
||||
@ -1,55 +0,0 @@
|
||||
1 deque
|
||||
2 flat_map
|
||||
3 flat_multimap
|
||||
4 flat_multiset
|
||||
5 flat_set
|
||||
6 forward_list
|
||||
7 list
|
||||
8 map
|
||||
9 multimap
|
||||
10 multiset
|
||||
11 pool
|
||||
12 priority_queue
|
||||
13 queue
|
||||
14 set
|
||||
15 stack
|
||||
16 unordered_map
|
||||
17 vector
|
||||
18 observer
|
||||
19 ihash
|
||||
20 intrusive_forward_list
|
||||
21 intrusive_list
|
||||
22 intrusive_links
|
||||
23 unordered_set
|
||||
24 variant
|
||||
25 unordered_multimap
|
||||
26 unordered_multiset
|
||||
27 basic_string
|
||||
28 intrusive_stack
|
||||
29 intrusive_queue
|
||||
30 reference_flat_map
|
||||
31 reference_flat_multimap
|
||||
32 reference_flat_set
|
||||
33 reference_flat_multiset
|
||||
34 fsm
|
||||
35 message_router
|
||||
36 scheduler
|
||||
37 task
|
||||
38 message
|
||||
39 message_bus
|
||||
40 factory / variant_pool
|
||||
41 array_view
|
||||
42 string_view
|
||||
43 callback_timer
|
||||
44 message_timer
|
||||
45 type_lookup
|
||||
46 queue_spsc_isr
|
||||
47 queue_spsc_atomic
|
||||
48 queue_mpmc_mutex
|
||||
49 type_select
|
||||
50 binary
|
||||
51 delegate
|
||||
52 bitset
|
||||
53 indirect_vector
|
||||
54 queue_spsc_locked
|
||||
55 message_packet
|
||||
118
include/etl/fixed_sized_memory_block_allocator.h
Normal file
118
include/etl/fixed_sized_memory_block_allocator.h
Normal file
@ -0,0 +1,118 @@
|
||||
///\file
|
||||
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2021 jwellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef ETL_FIXED_MEMORY_BLOCK_POOL_INCLUDED
|
||||
#define ETL_FIXED_MEMORY_BLOCK_POOL_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "imemory_block_allocator.h"
|
||||
#include "generic_pool.h"
|
||||
#include "alignment.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
//*************************************************************************
|
||||
/// The fixed sized memory block pool.
|
||||
/// The allocated memory blocks are all the same size.
|
||||
//*************************************************************************
|
||||
template <size_t VBlock_Size, size_t VAlignment, size_t VSize>
|
||||
class fixed_sized_memory_block_allocator : public imemory_block_allocator
|
||||
{
|
||||
public:
|
||||
|
||||
static ETL_CONSTANT size_t Block_Size = VBlock_Size;
|
||||
static ETL_CONSTANT size_t Alignment = VAlignment;
|
||||
static ETL_CONSTANT size_t Size = VSize;
|
||||
|
||||
//*************************************************************************
|
||||
/// Default constructor
|
||||
//*************************************************************************
|
||||
fixed_sized_memory_block_allocator()
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(ETL_IN_UNIT_TEST)
|
||||
//*************************************************************************
|
||||
/// Returns true if the allocator is the owner of the block.
|
||||
/// For unit testing purposes.
|
||||
//*************************************************************************
|
||||
bool is_owner_of(const void* const pblock) const
|
||||
{
|
||||
return pool.is_in_pool(pblock);
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
/// A structure that has the size Block_Size.
|
||||
struct block
|
||||
{
|
||||
char data[Block_Size];
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// The overridden virtual function to allocate a block.
|
||||
//*************************************************************************
|
||||
virtual void* allocate_block(size_t required_size, size_t required_alignment) ETL_OVERRIDE
|
||||
{
|
||||
if ((required_alignment <= Alignment) &&
|
||||
(required_size <= Block_Size) &&
|
||||
!pool.full())
|
||||
{
|
||||
return pool.template allocate<block>();
|
||||
}
|
||||
else
|
||||
{
|
||||
return ETL_NULLPTR;
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// The overridden virtual function to release a block.
|
||||
//*************************************************************************
|
||||
virtual bool release_block(const void* const pblock) ETL_OVERRIDE
|
||||
{
|
||||
if (pool.is_in_pool(pblock))
|
||||
{
|
||||
pool.release(static_cast<const block* const>(pblock));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// The generic pool from which allocate memory blocks.
|
||||
etl::generic_pool<Block_Size, Alignment, Size> pool;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
383
include/etl/flags.h
Normal file
383
include/etl/flags.h
Normal file
@ -0,0 +1,383 @@
|
||||
///\file
|
||||
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2020 jwellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef ETL_FLAGS_INCLUDED
|
||||
#define ETL_FLAGS_INCLUDED
|
||||
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "algorithm.h"
|
||||
#include "type_traits.h"
|
||||
#include "integral_limits.h"
|
||||
#include "static_assert.h"
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#include <initializer_list>
|
||||
#endif
|
||||
|
||||
namespace etl
|
||||
{
|
||||
//*************************************************************************
|
||||
/// flags
|
||||
/// Flags based around an integral value.
|
||||
//*************************************************************************
|
||||
template <typename T, T MASK = etl::integral_limits<T>::max>
|
||||
class flags
|
||||
{
|
||||
public:
|
||||
|
||||
ETL_STATIC_ASSERT(etl::is_integral<T>::value && etl::is_unsigned<T>::value, "Unsigned integral values only");
|
||||
|
||||
typedef T value_type;
|
||||
|
||||
static ETL_CONSTANT value_type ALL_SET = etl::integral_limits<value_type>::max & MASK;
|
||||
static ETL_CONSTANT value_type ALL_CLEAR = 0;
|
||||
|
||||
static const size_t NBITS = etl::integral_limits<value_type>::bits;
|
||||
|
||||
//*************************************************************************
|
||||
/// Constructor
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR flags() ETL_NOEXCEPT
|
||||
: data(value_type(0))
|
||||
{
|
||||
}
|
||||
|
||||
ETL_CONSTEXPR flags(value_type pattern) ETL_NOEXCEPT
|
||||
: data(pattern & MASK)
|
||||
{
|
||||
}
|
||||
|
||||
ETL_CONSTEXPR flags(const flags<T, MASK>& pattern) ETL_NOEXCEPT
|
||||
: data(pattern.value())
|
||||
{
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Tests bits.
|
||||
//*************************************************************************
|
||||
template <value_type pattern>
|
||||
ETL_CONSTEXPR bool test() const ETL_NOEXCEPT
|
||||
{
|
||||
return (data & pattern) != value_type(0);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR bool test(value_type pattern) const ETL_NOEXCEPT
|
||||
{
|
||||
return (data & pattern) != value_type(0);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Set the bits.
|
||||
//*************************************************************************
|
||||
template <value_type pattern, bool value>
|
||||
ETL_CONSTEXPR14 flags<T, MASK>& set() ETL_NOEXCEPT
|
||||
{
|
||||
value ? data |= (pattern & MASK) : data &= (~pattern & MASK);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
template <value_type pattern>
|
||||
ETL_CONSTEXPR14 flags<T, MASK>& set(bool value) ETL_NOEXCEPT
|
||||
{
|
||||
value ? data |= (pattern & MASK) : data &= (~pattern & MASK);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
template <value_type pattern>
|
||||
ETL_CONSTEXPR14 flags<T, MASK>& set() ETL_NOEXCEPT
|
||||
{
|
||||
data |= (pattern & MASK);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14 flags<T, MASK>& set(value_type pattern) ETL_NOEXCEPT
|
||||
{
|
||||
data |= (pattern & MASK);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14 flags<T, MASK>& set(value_type pattern, bool value) ETL_NOEXCEPT
|
||||
{
|
||||
value ? data |= (pattern & MASK) : data &= (~pattern & MASK);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Clear all of the flags.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 flags<T, MASK>& clear() ETL_NOEXCEPT
|
||||
{
|
||||
data = ALL_CLEAR;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Reset the bit at the pattern.
|
||||
//*************************************************************************
|
||||
template <value_type pattern>
|
||||
ETL_CONSTEXPR14 flags<T, MASK>& reset() ETL_NOEXCEPT
|
||||
{
|
||||
data &= ~pattern;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14 flags<T, MASK>& reset(value_type pattern) ETL_NOEXCEPT
|
||||
{
|
||||
data &= ~pattern;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Flip bits.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 flags<T, MASK>& flip() ETL_NOEXCEPT
|
||||
{
|
||||
data = (~data & MASK);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
template <value_type pattern>
|
||||
ETL_CONSTEXPR14 flags<T, MASK>& flip() ETL_NOEXCEPT
|
||||
{
|
||||
data ^= pattern & MASK;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14 flags<T, MASK>& flip(value_type pattern) ETL_NOEXCEPT
|
||||
{
|
||||
data ^= pattern & MASK;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
// Are all the bits sets?
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR bool all() const ETL_NOEXCEPT
|
||||
{
|
||||
return data == MASK;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
template <value_type pattern>
|
||||
ETL_CONSTEXPR bool all_of() const ETL_NOEXCEPT
|
||||
{
|
||||
return (data & (pattern & MASK)) == (pattern & MASK);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR bool all_of(value_type pattern) const ETL_NOEXCEPT
|
||||
{
|
||||
return (data & (pattern & MASK)) == (pattern & MASK);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Are none of the bits set?
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR bool none() const ETL_NOEXCEPT
|
||||
{
|
||||
return (data & MASK) == ALL_CLEAR;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
template <value_type pattern>
|
||||
ETL_CONSTEXPR bool none_of() const ETL_NOEXCEPT
|
||||
{
|
||||
return !any_of(pattern);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR bool none_of(value_type pattern) const ETL_NOEXCEPT
|
||||
{
|
||||
return !any_of(pattern);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Are any of the bits set?
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR bool any() const ETL_NOEXCEPT
|
||||
{
|
||||
return (data & MASK) != value_type(0);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
template <value_type pattern>
|
||||
ETL_CONSTEXPR bool any_of() const ETL_NOEXCEPT
|
||||
{
|
||||
return (data & (pattern & MASK)) != value_type(0);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR bool any_of(value_type pattern) const
|
||||
{
|
||||
return (data & (pattern & MASK)) != value_type(0);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Return the value of the flags.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR value_type value() const ETL_NOEXCEPT
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Set the value of the flags.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 flags<T, MASK>& value(value_type pattern) ETL_NOEXCEPT
|
||||
{
|
||||
data = pattern & MASK;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Return the value of the flags.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR operator value_type() const ETL_NOEXCEPT
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// operator &=
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 flags<T, MASK>& operator &=(value_type pattern) ETL_NOEXCEPT
|
||||
{
|
||||
data &= pattern;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// operator |=
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 flags<T, MASK>& operator |=(value_type pattern) ETL_NOEXCEPT
|
||||
{
|
||||
data |= (pattern & MASK);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// operator ^=
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 flags<T, MASK>& operator ^=(value_type pattern) ETL_NOEXCEPT
|
||||
{
|
||||
data ^= (pattern & MASK);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// operator =
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 flags<T, MASK>& operator =(flags<T, MASK> other) ETL_NOEXCEPT
|
||||
{
|
||||
data = other.data;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// operator =
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14 flags<T, MASK>& operator =(value_type pattern) ETL_NOEXCEPT
|
||||
{
|
||||
data = (pattern & MASK);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// swap
|
||||
//*************************************************************************
|
||||
void swap(flags<T, MASK>& other) ETL_NOEXCEPT
|
||||
{
|
||||
using ETL_OR_STD::swap;
|
||||
swap(data, other.data);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
value_type data;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// operator ==
|
||||
//***************************************************************************
|
||||
template <typename T, T MASK>
|
||||
ETL_CONSTEXPR bool operator == (flags<T, MASK> lhs, flags<T, MASK> rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return lhs.value() == rhs.value();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// operator !=
|
||||
//***************************************************************************
|
||||
template <typename T, T MASK>
|
||||
ETL_CONSTEXPR bool operator != (flags<T, MASK> lhs, flags<T, MASK> rhs) ETL_NOEXCEPT
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// swap
|
||||
//*************************************************************************
|
||||
template <typename T, T MASK>
|
||||
void swap(etl::flags<T, MASK>& lhs, etl::flags<T, MASK>& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -5,7 +5,7 @@ The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
http://www.etlcpp.com
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2015 jwellbelove
|
||||
|
||||
@ -31,24 +31,22 @@ SOFTWARE.
|
||||
#ifndef ETL_FLAT_MAP_INCLUDED
|
||||
#define ETL_FLAT_MAP_INCLUDED
|
||||
|
||||
#include <new>
|
||||
|
||||
#include "platform.h"
|
||||
#include "reference_flat_map.h"
|
||||
#include "pool.h"
|
||||
#include "placement_new.h"
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
#include <initializer_list>
|
||||
#endif
|
||||
#include "utility.h"
|
||||
|
||||
#undef ETL_FILE
|
||||
#define ETL_FILE "2"
|
||||
|
||||
//*****************************************************************************
|
||||
///\defgroup flat_map flat_map
|
||||
/// A flat_map with the capacity defined at compile time.
|
||||
/// Has insertion of O(N) and flat_map of O(logN)
|
||||
/// A flat_map based on a sorted vector with the capacity defined at
|
||||
/// compile time. This container is best used for tables that are occasionally
|
||||
/// updated and spend most of their time being searched.
|
||||
/// Has insertion of O(N) and find of O(logN).
|
||||
/// Duplicate entries are not allowed.
|
||||
///\ingroup containers
|
||||
//*****************************************************************************
|
||||
@ -382,7 +380,7 @@ namespace etl
|
||||
return emplace(value.first, value.second);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT)
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT
|
||||
//*************************************************************************
|
||||
/// Emplaces a value to the map.
|
||||
//*************************************************************************
|
||||
@ -938,14 +936,14 @@ namespace etl
|
||||
///\param first The iterator to the first element.
|
||||
///\param last The iterator to the last element + 1.
|
||||
//*************************************************************************
|
||||
template <typename TIterator>
|
||||
template <typename TIterator, typename etl::enable_if<!etl::is_integral<TIterator>::value, int>::type = 0>
|
||||
flat_map(TIterator first, TIterator last)
|
||||
: etl::iflat_map<TKey, TValue, TCompare>(lookup, storage)
|
||||
{
|
||||
this->assign(first, last);
|
||||
}
|
||||
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_STLPORT) && !defined(ETL_NO_STL)
|
||||
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
//*************************************************************************
|
||||
/// Construct from initializer_list.
|
||||
//*************************************************************************
|
||||
@ -1002,8 +1000,17 @@ namespace etl
|
||||
/// The vector that stores pointers to the nodes.
|
||||
etl::vector<node_t*, MAX_SIZE> lookup;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// Template deduction guides.
|
||||
//*************************************************************************
|
||||
#if ETL_CPP17_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
|
||||
template <typename T, typename... Ts>
|
||||
flat_map(T, Ts...)
|
||||
->flat_map<etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), typename T::first_type>,
|
||||
etl::enable_if_t<(etl::is_same_v<T, Ts> && ...), typename T::second_type>,
|
||||
1U + sizeof...(Ts)>;
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef ETL_FILE
|
||||
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user