mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
* Added compare_message_id * Added new C++11 and up message routing code using a sorted type_list * Renamed compare_message)id to compare_message_id_less * Added documenation for compare_message_id_less Added static asserts for message type template parameters * Added optimisation for contiguous message IDs Added more Doxygen documentation * Added etl::type_list_all_of, etl::type_list_any_of, and etl::type_list_none_of * Added etl::type_list_is_unique * Added common definitions to all router types * Added static_asserts to check message types * Added etl::type_list to etl::nth_type * Added missing 'typename' to type_list nth_type * Added type_list_is_empty * indentation fix * Renamed type_list_prepend & type_list_append to type_list_push_front & type_list_push_back respectively * Added tests for make_index_sequence & make_index_sequence_with_offset * Add more features to etl::type_list (#1307) * Remove AppVeyor build status badge Removed AppVeyor build status badge from README. * Update README.md * Update CONTRIBUTING.md Updated the instructions for contributing. * Added etl::type_list to etl::observer * Added etl::type_list to etl::nth_type * Added missing 'typename' to type_list nth_type * Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277) * Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`. * Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`. * Added type_list definitions for nth_type and observer * Added etl::type_list to etl::variant * Updated comments * Addedetl::type~_list to message_router, observer, visitor # Conflicts: # include/etl/observer.h # test/vs2022/etl.vcxproj.filters * Added member type_list type to tuple * Work in progress * Copy changes from other source * Removed unused tests * Fix iter_swap namespace * Add type_list functionality to etl::variant using etl::variant_from_type_list * Add type_list functionality to etl::message_packet using etl::message_packet_from_type_list * Add type_list functionality to etl::message_router using etl::message_router_from_type_list * Add type_list functionality to etl::observer using etl::observer_from_type_list * Add type_list functionality to etl::tuple using etl::tuple_from_type_list * Allow etl::make_index_sequence to be created from an etl::type_list * Add type_list functionality to etl::visitor using etl::visitor_from_type_list * Fix iter_swap namespace * Allow creation of a message_packet with no message types * Allow creation of a message_router with no message types * Updated VS2022 project files * Added missing test files CMakeLists.txt * Fix C++03 compatibility Fixed unused aregument warnings * Synced message_packet generator to updated code * Synced message_router generator to updated code * Synced message_router generator to updated code # Conflicts: # include/etl/generators/message_router_generator.h # include/etl/message_router.h * Fixed missing zero message specialisation for <= C++14 * Fixed missing zero message specialisation for <= C++14 * Fix year_month arithmetic and correct chrono API behavior (#1257) * Fix & add more tests for year_month arithmetic * Minor addtions to previous commit * More missing values to be uninitialized * Update the default constructors to = default and correct default constructor tests accordingly * Fix & add more tests for year_month arithmetic * Minor addtions to previous commit * More missing values to be uninitialized * Update the default constructors to = default and correct default constructor tests accordingly * Restore default constructor behavior for chrono calender * Suppress warnings from std in optimized builds (#1259) When testing with ./run-tests.sh 23 3 10, some warnings from std surfaced which resulted in build errors. * Add template deduction guide for span from vector (#1264) * Create span from vector deduction * Use ivector for deduction. Add vector_ext to test * Add vector pointer to test * Finish tests * Initialize pdata_ext and others * Document how to implement platform specifics (#1262) Some interfaces need to be implemented in every project or platform using the ETL: * etl_get_high_resolution_clock * etl_get_system_clock * etl_get_steady_clock * etl_putchar Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com> * Fix etl::as_bytes for etl::span<const T> (#1266) A missing 'const' in the etl::as_bytes implementation was causing a compile-time error when etl::as_bytes was called on a span of const values. Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com> * Remove some UB in test_vector_non_trivial.cpp (#1268) Some of the tests' UB are detectable by Gcc15 and thus give a compile error due to warnings-as-error flag. Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com> * Update C++26 deprecated constructs to ensure future standard compliance (#1267) * Update C++26 deprecated constructs to ensure future standard compliance I replaced std::is_trivial with a combination of std::is_trivially_default_constructible and std::is_trivially_copyable. Additionally, I added the required comma before the ellipsis in variadic functions to match updated language specifications. * Some additional is_trivial related changes not found directly when compiling tests in C++26 --------- Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com> * Fix return value of get_token_list (#1271) Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com> * Fix etl::tuple template signature error in pair assignment operator (#1265) * Fix etl::tuple template signature error in pair assignment operator * Remove AppVeyor build status badge Removed AppVeyor build status badge from README. * Update README.md * Update etl::tuple to explicitly use etl::pair or std::pair in assignment operator * Added tests for etl::tuple assignment from pair --------- Co-authored-by: Bryton Flecker <bflecker@swe.com> Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com> * Remove advance() on static spans (#1281) * Remove AppVeyor build status badge Removed AppVeyor build status badge from README. * Update README.md * Update CONTRIBUTING.md Updated the instructions for contributing. * Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277) * Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`. * Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`. * Remove advance() on static spans Since the size of a static span is constant, we can't reasonably advance() on it. --------- Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com> Co-authored-by: Sergei <sergej.shirokov@gmail.com> * Add missing includes (#1286) * Remove AppVeyor build status badge Removed AppVeyor build status badge from README. * Update README.md * Update CONTRIBUTING.md Updated the instructions for contributing. * Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277) * Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`. * Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`. * Add missing includes Before this change, the includes needed to be done explicitly by files using basic_string_stream.h, and be included first. This was error prone, especially if includes are reordered (e.g. via the currently defined clang-format rules). --------- Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com> Co-authored-by: Sergei <sergej.shirokov@gmail.com> * Move comparison operators of etl::expected to namespace etl (#1287) * Remove AppVeyor build status badge Removed AppVeyor build status badge from README. * Update README.md * Update CONTRIBUTING.md Updated the instructions for contributing. * Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277) * Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`. * Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`. * Move comparison operators of etl::expected to namespace etl --------- Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com> Co-authored-by: Sergei <sergej.shirokov@gmail.com> * Make typed_storage constructor constexpr (#1291) * Remove AppVeyor build status badge Removed AppVeyor build status badge from README. * Update README.md * Update CONTRIBUTING.md Updated the instructions for contributing. * Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277) * Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`. * Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`. * Make typed_storage constructor constexpr --------- Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com> Co-authored-by: Sergei <sergej.shirokov@gmail.com> * Add basic_format_arg constructor for ibasic_string (#1288) * Allow string as format arg * Remove AppVeyor build status badge Removed AppVeyor build status badge from README. * Update README.md * Update CONTRIBUTING.md Updated the instructions for contributing. * Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277) * Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`. * Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`. * Added test string escaped * Add temporary string test --------- Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com> Co-authored-by: Sergei <sergej.shirokov@gmail.com> * QR Code for Github * Added etl::visitor_from_type_list * accepts(id) for empty router passes on to a sucessor * Fixed incorrect comment from 'tuple' to 'message_router' * PR review changes * PR review changes * Fixed internal constexptr flag in message_packet * Fixed unused variable in unti test * Added new type_list features Added make_index_sequence_with_offset * Renamed type_list_select_from_sequence to type_list_select_from_index_sequence * Replaced type_list_size<TTypeList>::value with TTypeList::size internally for better clarity. * Added etl::type_list_remove, etl::type_list_remove_if, etl::type_list_unique, etl::type_list_pop_front, etl::type_list_pop_back * Add ref-qualifiers to basic_format_spec (#1292) * Remove AppVeyor build status badge Removed AppVeyor build status badge from README. * Update README.md * Update CONTRIBUTING.md Updated the instructions for contributing. * Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277) * Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`. * Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`. * feat: use ref-qualifiers for basic_format_spec Converted the l-value methods to ref-qualified and also added r-value ref-qualified methods. --------- Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com> Co-authored-by: Sergei <sergej.shirokov@gmail.com> * Add support for size_t and unsigned long to etl::format (#1290) * Remove AppVeyor build status badge Removed AppVeyor build status badge from README. * Update README.md * Update CONTRIBUTING.md Updated the instructions for contributing. * Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277) * Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`. * Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`. * Add support for size_t and unsigned long to etl::format * Document list of supported types in etl::supported_format_types * Add further types and tests for etl::format --------- Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com> Co-authored-by: Sergei <sergej.shirokov@gmail.com> * Deduce underlying storage size when constructing string_ext from char[]. (#1269) * Deduce underlying storage size when constructing string_ext from char[]. This removes the need for passing sizeof(storage) to the constructor. * Add array constructors for the other string types. - u16string_ext - u32string_ext - u8string_ext - wstring_ext * Add additional constructors to match existing API. * Fix inconsistent test argument order. --------- Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com> * Added etl::type_list_all_of, etl::type_list_any_of, and etl::type_list_none_of * Added etl::type_list_is_unique * Added type_list_is_empty * indentation fix * Fix merge error * Renamed type_list_prepend & type_list_append to type_list_push_front & type_list_push_back respectively * Added tests for make_index_sequence & make_index_sequence_with_offset * Resolve coderabbit review issues * Resolve coderabbit review issues * Resolve coderabbit review issues * Resolve coderabbit review issues * Added etl::type_list_indices_of_type which create an etl::index_sequence of all of the indexes of a specified type in an etl::type_list * Updated comments * Resolve coderabbit review issues Added index_sequence utility to support type_list utilities. Added additional index_sequence utilities for completeness * Added etl::index_sequence_cat, etl::index_sequence_pop_front, etl::index_sequence_pop_back, etl::index_sequence_at * Fix 'unused variable' error in index_sequence tests --------- Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.co.uk> Co-authored-by: Sergei <sergej.shirokov@gmail.com> Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.com> Co-authored-by: Bo Rydberg <2945606+bolry@users.noreply.github.com> Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de> Co-authored-by: Mike Bloom <91038685+mike919192@users.noreply.github.com> Co-authored-by: taltenbach <92919739+taltenbach@users.noreply.github.com> Co-authored-by: Bryton Flecker <fleckerbr@gmail.com> Co-authored-by: Bryton Flecker <bflecker@swe.com> Co-authored-by: Drew Rife <drew.rife95@gmail.com> Co-authored-by: Marco Nilsson <marco@zyax.se> * Moved O(1)/O(logN) index search test to get_dispatch_index_from_message_id Updated message_router generator * Fixed C++03 compatibilty * Replaced is_base_of with is_message * Missing 'return' in chrono example * Fixed doxygen comments * Check message inherits from etl::message<> * Copilot & coderabbit review changes Check for no duplicated message IDs Added diagnostic disable Make Message_Id_Start an etl::message_id_t type * Synchronised message_router_generator.h * Modified the "All message IDs must be unique" static_assert to directly use the index_sequence of message IDs Added addition index_sequence utilities to support this change. * Changed Router1 definition to use unordered message ids to check message sorting in message_router * Added has_message_id and compare_message_id_less to message.h * Moved member type definitions to a traits class message_packet, message_types, sorted_message_types * Sync message_router_generator to changes * Fixed C++03 compatibility --------- Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.com> Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.co.uk> Co-authored-by: Sergei <sergej.shirokov@gmail.com> Co-authored-by: Bo Rydberg <2945606+bolry@users.noreply.github.com> Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de> Co-authored-by: Mike Bloom <91038685+mike919192@users.noreply.github.com> Co-authored-by: taltenbach <92919739+taltenbach@users.noreply.github.com> Co-authored-by: Bryton Flecker <fleckerbr@gmail.com> Co-authored-by: Bryton Flecker <bflecker@swe.com> Co-authored-by: Drew Rife <drew.rife95@gmail.com> Co-authored-by: Marco Nilsson <marco@zyax.se>
369 lines
12 KiB
C++
369 lines
12 KiB
C++
/******************************************************************************
|
|
The MIT License(MIT)
|
|
|
|
Embedded Template Library.
|
|
https://github.com/ETLCPP/etl
|
|
https://www.etlcpp.com
|
|
|
|
Copyright(c) 2017 John Wellbelove
|
|
|
|
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_MESSAGE_INCLUDED
|
|
#define ETL_MESSAGE_INCLUDED
|
|
|
|
#include "platform.h"
|
|
#include "error_handler.h"
|
|
#include "exception.h"
|
|
#include "message_types.h"
|
|
#include "type_traits.h"
|
|
#include "static_assert.h"
|
|
|
|
#include <stdint.h>
|
|
|
|
namespace etl
|
|
{
|
|
//***************************************************************************
|
|
class message_exception : public etl::exception
|
|
{
|
|
public:
|
|
|
|
message_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
|
|
: exception(reason_, file_name_, line_number_)
|
|
{
|
|
}
|
|
};
|
|
|
|
//***************************************************************************
|
|
class unhandled_message_exception : public etl::message_exception
|
|
{
|
|
public:
|
|
|
|
unhandled_message_exception(string_type file_name_, numeric_type line_number_)
|
|
: message_exception(ETL_ERROR_TEXT("message:unknown", ETL_MESSAGE_FILE_ID"A"), file_name_, line_number_)
|
|
{
|
|
}
|
|
};
|
|
|
|
class message_tag {};
|
|
|
|
#if ETL_HAS_VIRTUAL_MESSAGES
|
|
//***************************************************************************
|
|
/// Message interface.
|
|
/// Virtual.
|
|
//***************************************************************************
|
|
class imessage
|
|
{
|
|
public:
|
|
|
|
//***********************************
|
|
virtual ~imessage() ETL_NOEXCEPT
|
|
{
|
|
}
|
|
|
|
//***********************************
|
|
ETL_NODISCARD virtual etl::message_id_t get_message_id() const ETL_NOEXCEPT = 0;
|
|
};
|
|
|
|
//***************************************************************************
|
|
/// Message type.
|
|
/// Virtual.
|
|
//***************************************************************************
|
|
template <etl::message_id_t ID_, typename TBase = etl::imessage>
|
|
class message : public TBase, public etl::message_tag
|
|
{
|
|
public:
|
|
|
|
ETL_STATIC_ASSERT((etl::is_base_of<etl::imessage, TBase>::value), "TBase is not derived from etl::imessage");
|
|
|
|
typedef TBase base_type;
|
|
|
|
//***********************************
|
|
ETL_NODISCARD virtual etl::message_id_t get_message_id() const ETL_NOEXCEPT ETL_OVERRIDE
|
|
{
|
|
return ID;
|
|
}
|
|
|
|
//***********************************
|
|
static ETL_CONSTANT etl::message_id_t ID = ID_;
|
|
};
|
|
|
|
#else
|
|
|
|
//***************************************************************************
|
|
/// Message interface.
|
|
/// Non-virtual.
|
|
//***************************************************************************
|
|
class imessage
|
|
{
|
|
public:
|
|
|
|
//***********************************
|
|
ETL_NODISCARD etl::message_id_t get_message_id() const ETL_NOEXCEPT
|
|
{
|
|
return id;
|
|
}
|
|
|
|
protected:
|
|
|
|
//***********************************
|
|
imessage(etl::message_id_t id_) ETL_NOEXCEPT
|
|
: id(id_)
|
|
{
|
|
}
|
|
|
|
//***********************************
|
|
imessage(const imessage& other) ETL_NOEXCEPT
|
|
: id(other.id)
|
|
{
|
|
}
|
|
|
|
//***********************************
|
|
imessage& operator =(const imessage& rhs) ETL_NOEXCEPT
|
|
{
|
|
id = rhs.id;
|
|
return *this;
|
|
}
|
|
|
|
//***********************************
|
|
etl::message_id_t id;
|
|
|
|
private:
|
|
|
|
imessage() ETL_DELETE;
|
|
};
|
|
|
|
//***************************************************************************
|
|
/// Message type.
|
|
/// Non-virtual.
|
|
//***************************************************************************
|
|
template <etl::message_id_t ID_, typename TBase = etl::imessage>
|
|
class message : public TBase, public etl::message_tag
|
|
{
|
|
public:
|
|
|
|
ETL_STATIC_ASSERT((etl::is_base_of<etl::imessage, TBase>::value), "TBase is not derived from etl::imessage");
|
|
|
|
typedef TBase base_type;
|
|
|
|
//***********************************
|
|
message() ETL_NOEXCEPT
|
|
: TBase(ID)
|
|
{
|
|
}
|
|
|
|
//***********************************
|
|
message(const message&) ETL_NOEXCEPT
|
|
: TBase(ID)
|
|
{
|
|
}
|
|
|
|
//***********************************
|
|
message& operator =(const message&) ETL_NOEXCEPT
|
|
{
|
|
return *this;
|
|
}
|
|
|
|
//***********************************
|
|
static ETL_CONSTANT etl::message_id_t ID = ID_;
|
|
};
|
|
#endif
|
|
|
|
//***************************************************************************
|
|
/// The message's static ID.
|
|
//***************************************************************************
|
|
template <etl::message_id_t ID_, typename TBase>
|
|
ETL_CONSTANT etl::message_id_t etl::message<ID_, TBase>::ID;
|
|
|
|
//***************************************************************************
|
|
/// Is T an etl::imessage?
|
|
//***************************************************************************
|
|
template <typename T>
|
|
struct is_imessage : public etl::bool_constant<etl::is_same<etl::imessage, typename etl::remove_cvref<T>::type>::value>
|
|
{
|
|
};
|
|
|
|
//***************************************************************************
|
|
/// Is T ultimately derived from etl::imessage?
|
|
//***************************************************************************
|
|
template <typename T>
|
|
struct is_message : public etl::bool_constant<etl::is_base_of<etl::imessage, typename etl::remove_cvref<T>::type>::value>
|
|
{
|
|
};
|
|
|
|
//***************************************************************************
|
|
/// Is T an etl::message<> or derived from etl::message<>
|
|
//***************************************************************************
|
|
template <typename T>
|
|
struct is_message_type : public etl::bool_constant<etl::is_base_of<etl::message_tag, typename etl::remove_cvref<T>::type>::value>
|
|
{
|
|
};
|
|
|
|
//***************************************************************************
|
|
/// Is T a base of etl::message<T>
|
|
//***************************************************************************
|
|
template <typename T>
|
|
struct is_message_base : public etl::bool_constant<etl::is_message<T>::value && !etl::is_message_type<T>::value>
|
|
{
|
|
};
|
|
|
|
//***************************************************************************
|
|
/// Is T a user defined base of etl::message<T> and not an etl::imessage
|
|
//***************************************************************************
|
|
template <typename T>
|
|
struct is_user_message_base : public etl::bool_constant<etl::is_message_base<T>::value && !etl::is_imessage<T>::value>
|
|
{
|
|
};
|
|
|
|
#if ETL_USING_CPP17
|
|
//***************************************************************************
|
|
/// Is T an etl::imessage?
|
|
//***************************************************************************
|
|
template <typename T>
|
|
inline constexpr bool is_imessage_v = is_imessage<T>::value;
|
|
|
|
//***************************************************************************
|
|
/// Is T ultimately derived from etl::imessage?
|
|
//***************************************************************************
|
|
template <typename T>
|
|
inline constexpr bool is_message_v = is_message<T>::value;
|
|
|
|
//***************************************************************************
|
|
/// Is T derived from etl::message<>
|
|
//***************************************************************************
|
|
template <typename T>
|
|
inline constexpr bool is_message_type_v = is_message_type<T>::value;
|
|
|
|
//***************************************************************************
|
|
/// Is T a base of etl::message<T>
|
|
//***************************************************************************
|
|
template <typename T>
|
|
inline constexpr bool is_message_base_v = is_message_base<T>::value;
|
|
|
|
//***************************************************************************
|
|
/// Is T a user defined base of etl::message<T>
|
|
//***************************************************************************
|
|
template <typename T>
|
|
inline constexpr bool is_user_message_base_v = is_user_message_base<T>::value;
|
|
#endif
|
|
|
|
//***************************************************************************
|
|
/// Detects presence of a static ID member.
|
|
//***************************************************************************
|
|
template <typename T>
|
|
struct has_message_id
|
|
{
|
|
private:
|
|
|
|
ETL_STATIC_ASSERT(etl::is_message<T>::value, "T is not an ETL message");
|
|
|
|
typedef char yes;
|
|
struct no { char value[2]; };
|
|
|
|
template <typename U>
|
|
static yes test(char (*)[sizeof(&U::ID)]);
|
|
|
|
template <typename>
|
|
static no test(...);
|
|
|
|
public:
|
|
|
|
static const bool value = sizeof(test<typename etl::remove_cv<T>::type>(0)) == sizeof(yes);
|
|
};
|
|
|
|
template <typename T>
|
|
const bool has_message_id<T>::value;
|
|
|
|
#if ETL_USING_CPP17
|
|
template <typename T>
|
|
inline constexpr bool has_message_id_v = has_message_id<T>::value;
|
|
#endif
|
|
|
|
#if ETL_USING_CPP11
|
|
namespace private_message
|
|
{
|
|
template <typename TMsg1, typename TMsg2, bool HasIDs>
|
|
struct compare_message_id_less_impl;
|
|
|
|
//**********************************************
|
|
// Compare the message ID of two messages.
|
|
// \tparam TMsg1 The first message type.
|
|
// \tparam TMsg2 The second message type.
|
|
// Only selected if both TMsg1 or TMsg2 don't have an ID.
|
|
//**********************************************
|
|
template <typename TMsg1, typename TMsg2>
|
|
struct compare_message_id_less_impl<TMsg1, TMsg2, false>
|
|
{
|
|
ETL_STATIC_ASSERT(etl::has_message_id<TMsg1>::value, "TMsg1 does not have an ID");
|
|
ETL_STATIC_ASSERT(etl::has_message_id<TMsg2>::value, "TMsg2 does not have an ID");
|
|
ETL_STATIC_ASSERT(etl::is_message_type<TMsg1>::value, "TMsg1 is not derived from etl::message<>");
|
|
ETL_STATIC_ASSERT(etl::is_message_type<TMsg2>::value, "TMsg2 is not derived from etl::message<>");
|
|
};
|
|
|
|
//**********************************************
|
|
// Compare the message ID of two messages.
|
|
// \tparam TMsg1 The first message type.
|
|
// \tparam TMsg2 The second message type.
|
|
// value is true if TMsg1::ID < TMsg2::ID.
|
|
// Only selected if both TMsg1 and TMsg2 have an ID.
|
|
//***********************************************
|
|
template <typename TMsg1, typename TMsg2>
|
|
struct compare_message_id_less_impl<TMsg1, TMsg2, true>
|
|
: etl::bool_constant < TMsg1::ID < TMsg2::ID>
|
|
{
|
|
ETL_STATIC_ASSERT(etl::is_message_type<TMsg1>::value, "TMsg1 is not derived from etl::message<>");
|
|
ETL_STATIC_ASSERT(etl::is_message_type<TMsg2>::value, "TMsg2 is not derived from etl::message<>");
|
|
};
|
|
}
|
|
|
|
//**********************************************
|
|
/// Compare the message ID of two messages.
|
|
/// \tparam TMsg1 The first message type.
|
|
/// \tparam TMsg2 The second message type.
|
|
/// value is true if TMsg1::ID < TMsg2::ID.
|
|
//**********************************************
|
|
template <typename TMsg1, typename TMsg2>
|
|
struct compare_message_id_less : public private_message::compare_message_id_less_impl<TMsg1, TMsg2, has_message_id<TMsg1>::value && has_message_id<TMsg2>::value>
|
|
{
|
|
};
|
|
#else
|
|
//**********************************************
|
|
/// Compare the message ID of two messages.
|
|
/// \tparam TMsg1 The first message type.
|
|
/// \tparam TMsg2 The second message type.
|
|
/// value is true if TMsg1::ID < TMsg2::ID.
|
|
//**********************************************
|
|
template <typename TMsg1, typename TMsg2>
|
|
struct compare_message_id_less
|
|
: etl::bool_constant<TMsg1::ID < TMsg2::ID>
|
|
{
|
|
ETL_STATIC_ASSERT(etl::is_message_type<TMsg1>::value, "TMsg1 is not derived from etl::message<>");
|
|
ETL_STATIC_ASSERT(etl::is_message_type<TMsg2>::value, "TMsg2 is not derived from etl::message<>");
|
|
};
|
|
#endif
|
|
|
|
#if ETL_USING_CPP17
|
|
template <typename TMsg1, typename TMsg2>
|
|
inline constexpr bool compare_message_id_less_v = compare_message_id_less<TMsg1, TMsg2>::value;
|
|
#endif
|
|
}
|
|
|
|
#endif
|