Merge branch 'feature/message_router_registry' into development

This commit is contained in:
John Wellbelove 2021-03-05 20:50:09 +00:00
commit 7c0fc9ee52
167 changed files with 829 additions and 182 deletions

View File

@ -90,5 +90,6 @@ SOFTWARE.
#define ETL_MULTI_LOOP_ID "57"
#define ETL_REFERENCE_COUNTER_MESSAGE_POOL_ID "58"
#define ETL_QUEUE_SPSC_LOCKABLE "59"
#define ETL_MESSAGE_ROUTER_REGISTRY "60"
#endif

View File

@ -0,0 +1,311 @@
/******************************************************************************
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_MESSAGE_ROUTER_REGISTRY_INCLUDED
#define ETL_MESSAGE_ROUTER_REGISTRY_INCLUDED
#include <stdint.h>
#include "platform.h"
#include "file_error_numbers.h"
#include "message_router.h"
#include "flat_map.h"
#include "exception.h"
#include "error_handler.h"
#undef ETL_FILE
#define ETL_FILE ETL_MESSAGE_ROUTER_REGISTRY
namespace etl
{
//***************************************************************************
/// Base exception class for message router registry.
//***************************************************************************
class message_router_registry_exception : public etl::exception
{
public:
message_router_registry_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
: etl::exception(reason_, file_name_, line_number_)
{
}
};
//***************************************************************************
/// The registry is full.
//***************************************************************************
class message_router_registry_full : public etl::message_router_registry_exception
{
public:
message_router_registry_full(string_type file_name_, numeric_type line_number_)
: message_router_registry_exception(ETL_ERROR_TEXT("message router registry:full", ETL_FILE"A"), file_name_, line_number_)
{
}
};
//***************************************************************************
/// This is the base of all message router registries.
//***************************************************************************
class imessage_router_registry
{
public:
//********************************************
/// Registers a router.
/// If the registry is full then an ETL assert is called.
//********************************************
void add(etl::imessage_router& router)
{
if (!registry.full())
{
typename IRegistry::value_type element(router.get_message_router_id(), &router);
registry.insert(element);
}
else
{
ETL_ALWAYS_ASSERT(ETL_ERROR(etl::message_router_registry_full));
}
}
//********************************************
/// Registers a router.
/// If the registry is full then an ETL assert is called.
//********************************************
void add(etl::imessage_router* p_router)
{
if (p_router != ETL_NULLPTR)
{
add(*p_router);
}
}
//********************************************
/// Registers a list of routers.
/// If the registry is full then an ETL assert is called.
//********************************************
template <typename TIterator>
void add(TIterator first, const TIterator& last)
{
while (first != last)
{
add(*first++);
}
}
//********************************************
/// Unregisters a router.
//********************************************
void remove(etl::message_router_id_t id)
{
registry.erase(id);
}
//********************************************
/// Get a pointer to a router that has the specified ID.
/// Returns ETL_NULLPTR if not found.
//********************************************
etl::imessage_router* get(etl::message_router_id_t id) const
{
IRegistry::const_iterator itr = registry.find(id);
if (itr != registry.end())
{
return itr->second;
}
else
{
return ETL_NULLPTR;
}
}
//********************************************
/// Returns <b>true</b> if the registry contains a router that has the specified ID.
/// Returns <b>false</b> if not found.
//********************************************
bool contains(const etl::message_router_id_t id) const
{
return registry.find(id) != registry.end();
}
//********************************************
/// Returns <b>true</b> if the registry contains the router.
/// Returns <b>false</b> if not found.
//********************************************
bool contains(const etl::imessage_router* const p_router) const
{
if (p_router == ETL_NULLPTR)
{
return false;
}
return registry.find(p_router->get_message_router_id()) != registry.end();
}
//********************************************
/// Returns <b>true</b> if the registry contains the router.
/// Returns <b>false</b> if not found.
//********************************************
bool contains(const etl::imessage_router& router) const
{
return registry.find(router.get_message_router_id()) != registry.end();
}
//********************************************
/// Returns <b>true</b> if the registry is empty, otherwise <b>false</b>.
//********************************************
bool empty() const
{
return registry.empty();
}
//********************************************
/// Returns <b>true</b> if the registry is full, otherwise <b>false</b>.
//********************************************
bool full() const
{
return registry.full();
}
//********************************************
/// Returns the size of the registry.
//********************************************
size_t size() const
{
return registry.size();
}
//********************************************
/// Returns the available size of the registry.
//********************************************
size_t available() const
{
return registry.available();
}
//********************************************
/// Returns the maximum size of the registry.
//********************************************
size_t max_size() const
{
return registry.max_size();
}
protected:
typedef etl::iflat_map<etl::message_router_id_t, etl::imessage_router*> IRegistry;
//********************************************
// Constructor.
//********************************************
imessage_router_registry(IRegistry& registry_)
: registry(registry_)
{
}
private:
IRegistry& registry;
};
//***************************************************************************
/// Message router registry.
//***************************************************************************
template <size_t MaxRouters>
class message_router_registry : public etl::imessage_router_registry
{
public:
//********************************************
// Default constructor.
//********************************************
message_router_registry()
: imessage_router_registry(registry)
{
}
//********************************************
/// Constructor.
/// Constructs from an iterator range.
//********************************************
template <typename TIterator>
message_router_registry(TIterator first, const TIterator& last)
: imessage_router_registry(registry)
{
while (first != last)
{
this->add(*first++);
}
}
#if ETL_CPP11_SUPPORTED && ETL_USING_STL
//********************************************
// Initializer_list constructor.
//********************************************
message_router_registry(std::initializer_list<etl::imessage_router*> init)
: imessage_router_registry(registry)
{
std::initializer_list<etl::imessage_router*>::const_iterator itr = init.begin();
while (itr != init.end())
{
this->add(*itr++);
}
}
#endif
//********************************************
// Copy constructor.
//********************************************
message_router_registry(const message_router_registry& rhs)
: imessage_router_registry(registry)
{
registry = rhs.registry;
}
//********************************************
// Assignment operator.
//********************************************
message_router_registry& operator =(const message_router_registry& rhs)
{
registry = rhs.registry;
return *this;
}
private:
typedef etl::flat_map<etl::message_router_id_t, etl::imessage_router*, MaxRouters> Registry;
Registry registry;
};
}
#undef ETL_FILE
#endif

View File

@ -25,7 +25,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
int main()
{

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/algorithm.h"
#include "etl/container.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/alignment.h"
#include "etl/type_traits.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/array.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/array_view.h"
#include "etl/array.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/array_wrapper.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/platform.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/platform.h"
#include "etl/atomic/atomic_std.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <cstdint>
#include <type_traits>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/bit_stream.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <limits>
#include <type_traits>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <vector>
#include <string.h>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/bresenham_line.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <iterator>
#include <string>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <thread>
#include <vector>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/function.h"
#include "etl/callback_service.h"

View File

@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "ExtraCheckMacros.h"
#include "unit_test_framework.h"
#include "etl/callback_timer.h"
#include "etl/function.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <iterator>
#include <string>

View File

@ -26,7 +26,7 @@
//SOFTWARE.
//******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/circular_buffer.h"
#include "etl/integral_limits.h"

View File

@ -26,7 +26,7 @@
//SOFTWARE.
//******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/circular_buffer.h"
#include "etl/integral_limits.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/compare.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/platform.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/constant.h"
#include "etl/integral_limits.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/container.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <iterator>
#include <string>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <array>
#include <algorithm>

View File

@ -28,7 +28,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/cyclic_value.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/debounce.h"

View File

@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "ExtraCheckMacros.h"
#include "unit_test_framework.h"
#include "etl/delegate.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/delegate.h"
#include "etl/delegate_service.h"

View File

@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "ExtraCheckMacros.h"
#include "unit_test_framework.h"
#include "etl/deque.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <string>
#include "etl/endianness.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <string>
#include "etl/enum_type.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <iostream>
#include <string>
#include <string.h>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <string>
#include "etl/exception.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <vector>
#include <ostream>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/fixed_sized_memory_block_allocator.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/flags.h"
#include "etl/binary.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <map>
#include <array>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <map>
#include <array>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <set>
#include <array>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <set>
#include <array>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <iterator>
#include <string>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <ostream>
#include <sstream>

View File

@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "ExtraCheckMacros.h"
#include "unit_test_framework.h"
#include "data.h"

View File

@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "ExtraCheckMacros.h"
#include "unit_test_framework.h"
#include "data.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/fsm.h"
#include "etl/enum_type.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/function.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/functional.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <iterator>
#include <string>

View File

@ -26,7 +26,7 @@
//SOFTWARE.
//******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <vector>
#include <array>

View File

@ -26,7 +26,7 @@
//SOFTWARE.
//******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <vector>
#include <array>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/instance_count.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <limits>
#include <type_traits>

View File

@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "ExtraCheckMacros.h"
#include "unit_test_framework.h"
#include "data.h"

View File

@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "ExtraCheckMacros.h"
#include "unit_test_framework.h"
#include "data.h"

View File

@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "ExtraCheckMacros.h"
#include "unit_test_framework.h"
#include "data.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/intrusive_queue.h"
#include "etl/intrusive_links.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/intrusive_stack.h"
#include "etl/intrusive_links.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/io_port.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <string>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <iterator>
#include <string>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/largest.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/limits.h"
#include <limits>

View File

@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "ExtraCheckMacros.h"
#include "unit_test_framework.h"
#include "etl/list.h"

View File

@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "ExtraCheckMacros.h"
#include "unit_test_framework.h"
#include "etl/list.h"
#include "etl/pool.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <string>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <map>
#include <array>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/log.h"
#include "etl/power.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/memory.h"
#include "etl/debug_count.h"

View File

@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "ExtraCheckMacros.h"
#include "unit_test_framework.h"
#include "etl/message_router.h"
#include "etl/message_bus.h"

View File

@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "ExtraCheckMacros.h"
#include "unit_test_framework.h"
#include "etl/message_packet.h"

View File

@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "ExtraCheckMacros.h"
#include "unit_test_framework.h"
#include "etl/message_router.h"
#include "etl/queue.h"

View File

@ -0,0 +1,309 @@
/******************************************************************************
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.
******************************************************************************/
#include "unit_test_framework.h"
#include "etl/message_router.h"
#include "etl/message_router_registry.h"
#include "etl/array.h"
//***************************************************************************
// The set of messages.
//***************************************************************************
namespace
{
enum
{
ROUTER1 = 10,
ROUTER2 = 20,
ROUTER3 = 30,
ROUTER4 = 40,
ROUTER5 = 50
};
constexpr size_t Registry_Size = 4U;
struct Message1 : public etl::message<1>
{
};
//***************************************************************************
// Router1
//***************************************************************************
class Router1 : public etl::message_router<Router1, Message1>
{
public:
Router1()
: message_router(ROUTER1)
{
}
void on_receive(const Message1& msg)
{
}
void on_receive_unknown(const etl::imessage&)
{
}
};
//***************************************************************************
// Router2
//***************************************************************************
class Router2 : public etl::message_router<Router2, Message1>
{
public:
Router2()
: message_router(ROUTER2)
{
}
void on_receive(const Message1& msg)
{
}
void on_receive_unknown(const etl::imessage&)
{
}
};
//***************************************************************************
// Router3
//***************************************************************************
class Router3 : public etl::message_router<Router2, Message1>
{
public:
Router3()
: message_router(ROUTER3)
{
}
void on_receive(const Message1& msg)
{
}
void on_receive_unknown(const etl::imessage&)
{
}
};
//***************************************************************************
// Router4
//***************************************************************************
class Router4 : public etl::message_router<Router4, Message1>
{
public:
Router4()
: message_router(ROUTER4)
{
}
void on_receive(const Message1& msg)
{
}
void on_receive_unknown(const etl::imessage&)
{
}
};
//***************************************************************************
// Router5
//***************************************************************************
class Router5 : public etl::message_router<Router5, Message1>
{
public:
Router5()
: message_router(ROUTER5)
{
}
void on_receive(const Message1& msg)
{
}
void on_receive_unknown(const etl::imessage&)
{
}
};
Router1 router1;
Router2 router2;
Router3 router3;
Router4 router4;
Router5 router5;
SUITE(test_message_router_registry)
{
//*************************************************************************
TEST(test_default_construction)
{
etl::message_router_registry<Registry_Size> registry;
CHECK(registry.empty());
CHECK(!registry.full());
CHECK_EQUAL(0U, registry.size());
CHECK_EQUAL(Registry_Size, registry.available());
CHECK_EQUAL(Registry_Size, registry.max_size());
}
//*************************************************************************
TEST(test_iterator_construction)
{
etl::array<etl::imessage_router*, Registry_Size> routers{ &router1, &router2, &router3, &router4 };
etl::message_router_registry<Registry_Size> registry(routers.begin(), routers.end());
CHECK(!registry.empty());
CHECK(registry.full());
CHECK_EQUAL(Registry_Size, registry.size());
CHECK_EQUAL(0U, registry.available());
CHECK_EQUAL(Registry_Size, registry.max_size());
}
//*************************************************************************
TEST(test_iterator_construction_excess)
{
etl::array<etl::imessage_router*, Registry_Size + 1U> routers{ &router1, &router2, &router3, &router4, &router5 };
etl::message_router_registry<Registry_Size> registry;
CHECK_THROW((registry.add(routers.begin(), routers.end())), etl::message_router_registry_full);
CHECK(!registry.empty());
CHECK(registry.full());
CHECK_EQUAL(Registry_Size, registry.size());
CHECK_EQUAL(0U, registry.available());
CHECK_EQUAL(Registry_Size, registry.max_size());
}
//*************************************************************************
TEST(test_initializer_list_construction)
{
etl::message_router_registry<Registry_Size> registry = { &router1, &router2, &router3, &router4 };
CHECK(!registry.empty());
CHECK(registry.full());
CHECK_EQUAL(Registry_Size, registry.size());
CHECK_EQUAL(0U, registry.available());
CHECK_EQUAL(Registry_Size, registry.max_size());
}
//*************************************************************************
TEST(test_initializer_list_construction_part_full)
{
etl::message_router_registry<Registry_Size> registry = { &router1, &router2, &router3 };
CHECK(!registry.empty());
CHECK(!registry.full());
CHECK_EQUAL(Registry_Size - 1U, registry.size());
CHECK_EQUAL(1U, registry.available());
CHECK_EQUAL(Registry_Size, registry.max_size());
}
//*************************************************************************
TEST(test_copy_construction)
{
etl::message_router_registry<Registry_Size> registry = { &router1, &router2, &router3, &router4 };
etl::message_router_registry<Registry_Size> registry2(registry);
CHECK(!registry2.empty());
CHECK(registry2.full());
CHECK_EQUAL(Registry_Size, registry2.size());
CHECK_EQUAL(0U, registry2.available());
CHECK_EQUAL(Registry_Size, registry2.max_size());
}
//*************************************************************************
TEST(test_assignment)
{
etl::message_router_registry<Registry_Size> registry = { &router1, &router2, &router3, &router4 };
etl::message_router_registry<Registry_Size> registry2;
registry2 = registry;
CHECK(!registry2.empty());
CHECK(registry2.full());
CHECK_EQUAL(Registry_Size, registry2.size());
CHECK_EQUAL(0U, registry2.available());
CHECK_EQUAL(Registry_Size, registry2.max_size());
}
//*************************************************************************
TEST(test_registery_contains)
{
etl::message_router_registry<Registry_Size> registry = { &router1, &router2, &router3 };
CHECK(registry.contains(ROUTER1));
CHECK(registry.contains(ROUTER2));
CHECK(registry.contains(ROUTER3));
CHECK(!registry.contains(ROUTER4));
CHECK(registry.contains(router1));
CHECK(registry.contains(router2));
CHECK(registry.contains(router3));
CHECK(!registry.contains(router4));
CHECK(registry.contains(&router1));
CHECK(registry.contains(&router2));
CHECK(registry.contains(&router3));
CHECK(!registry.contains(&router4));
}
//*************************************************************************
TEST(test_get_message_router)
{
etl::message_router_registry<Registry_Size> registry = { &router1, &router2, &router3 };
CHECK_EQUAL(&router1, registry.get(ROUTER1));
CHECK_EQUAL(&router2, registry.get(ROUTER2));
CHECK_EQUAL(&router3, registry.get(ROUTER3));
CHECK_EQUAL(nullptr, registry.get(ROUTER4));
}
//*************************************************************************
TEST(test_unregister_message_router)
{
etl::message_router_registry<Registry_Size> registry = { &router1, &router2, &router3, &router4 };
registry.remove(ROUTER3);
CHECK(!registry.contains(router3));
CHECK_EQUAL(&router1, registry.get(ROUTER1));
CHECK_EQUAL(&router2, registry.get(ROUTER2));
CHECK_EQUAL(nullptr, registry.get(ROUTER3));
CHECK_EQUAL(&router4, registry.get(ROUTER4));
}
};
}

View File

@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "ExtraCheckMacros.h"
#include "unit_test_framework.h"
#include "etl/message_router.h"
#include "etl/message_bus.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/array.h"
#include "etl/multi_array.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/multi_range.h"
#include "etl/functional.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <map>
#include <array>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <set>
#include <array>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "murmurhash3.h" // The 'C' reference implementation.

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/numeric.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/observer.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <string>
#include <ostream>

View File

@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "ExtraCheckMacros.h"
#include "unit_test_framework.h"
#include "etl/packet.h"
#include "etl/largest.h"

View File

@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "ExtraCheckMacros.h"
#include "unit_test_framework.h"
#include "etl/parameter_pack.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <string>
#include <ostream>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <iterator>
#include <string>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <iterator>
#include <string>

View File

@ -26,8 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "ExtraCheckMacros.h"
#include "unit_test_framework.h"
#include "data.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <queue>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <queue>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/queue_lockable.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include "etl/queue_lockable.h"

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <queue>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <thread>
#include <chrono>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <thread>
#include <chrono>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <thread>
#include <chrono>

View File

@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "UnitTest++/UnitTest++.h"
#include "unit_test_framework.h"
#include <thread>
#include <chrono>

Some files were not shown because too many files have changed in this diff Show More