29#ifndef ETL_MESSAGE_ROUTER_REGISTRY_INCLUDED
30#define ETL_MESSAGE_ROUTER_REGISTRY_INCLUDED
39#include "message_router.h"
52 message_router_registry_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
65 message_router_registry_full(string_type file_name_, numeric_type line_number_)
66 : message_router_registry_exception(ETL_ERROR_TEXT(
"message router registry:full", ETL_MESSAGE_ROUTER_REGISTRY_FILE_ID
"A"), file_name_,
75 class imessage_router_registry
88 class iterator :
public etl::iterator<ETL_OR_STD::forward_iterator_tag, etl::imessage_router*>
92 friend class imessage_router_registry;
93 friend class const_iterator;
99 iterator(
const iterator& other)
105 iterator& operator=(
const iterator& other)
114 return *(itr->second);
120 return *(itr->second);
136 iterator& operator++()
143 iterator operator++(
int)
145 iterator temp(*
this);
151 friend bool operator==(
const iterator& lhs,
const iterator& rhs)
153 return lhs.itr == rhs.itr;
157 friend bool operator!=(
const iterator& lhs,
const iterator& rhs)
159 return !(lhs == rhs);
165 iterator(IRegistry::iterator itr_)
170 IRegistry::iterator itr;
176 class const_iterator :
etl::iterator<ETL_OR_STD::forward_iterator_tag, const etl::imessage_router*>
180 friend class imessage_router_registry;
192 const_iterator(
const const_iterator& other)
198 const_iterator& operator=(
const const_iterator& other)
207 return *(itr->second);
217 const_iterator& operator++()
224 const_iterator operator++(
int)
226 const_iterator temp(*
this);
232 friend bool operator==(
const const_iterator& lhs,
const const_iterator& rhs)
234 return lhs.itr == rhs.itr;
238 friend bool operator!=(
const const_iterator& lhs,
const const_iterator& rhs)
240 return !(lhs == rhs);
246 const_iterator(IRegistry::const_iterator itr_)
251 IRegistry::const_iterator itr;
267 const_iterator cbegin()
const
269 return const_iterator(registry.
cbegin());
285 const_iterator cend()
const
287 return const_iterator(registry.
cend());
295 IRegistry::iterator itr = registry.find(
id);
297 if (registry.find(
id) != registry.end())
309 IRegistry::const_iterator itr = registry.
find(
id);
311 if (registry.
find(
id) != registry.
end())
326 return iterator(registry.lower_bound(
id));
339 return iterator(registry.upper_bound(
id));
353 if (!registry.full() && !
contains(router))
355 IRegistry::value_type element(router.get_message_router_id(), &router);
357 registry.insert(element);
371 if (p_router != ETL_NULLPTR)
381 template <
typename TIterator>
382 void add(TIterator first,
const TIterator& last)
384 while (first != last)
403 bool contains(
const etl::message_router_id_t
id)
const
405 return find(
id) != ETL_NULLPTR;
416 if (p_router == ETL_NULLPTR)
421 IRegistry::const_iterator irouter = registry.find(p_router->get_message_router_id());
423 return (irouter != registry.cend()) && (irouter->second == p_router);
432 IRegistry::const_iterator irouter = registry.find(router.get_message_router_id());
434 return (irouter != registry.cend()) && (irouter->second == &router);
440 size_t count(
const etl::message_router_id_t
id)
const
442 return registry.count(
id);
450 return registry.empty();
458 return registry.full();
466 return registry.size();
474 return registry.available();
482 return registry.max_size();
491 : registry(registry_)
503 template <
size_t MaxRouters>
511 message_router_registry()
512 : imessage_router_registry(registry)
520 template <
typename TIterator>
522 : imessage_router_registry(registry)
524 while (first != last)
531#if ETL_HAS_INITIALIZER_LIST
538 std::initializer_list<etl::imessage_router*>::const_iterator itr = init.
begin();
540 while (itr != init.end())
551 message_router_registry(
const message_router_registry& rhs)
552 : imessage_router_registry(registry)
554 registry = rhs.registry;
560 message_router_registry& operator=(
const message_router_registry& rhs)
562 registry = rhs.registry;
569 typedef etl::flat_multimap<etl::message_router_id_t, etl::imessage_router*, MaxRouters> Registry;
Const Iterator.
Definition message_router_registry.h:177
Iterator.
Definition message_router_registry.h:89
This is the base of all message router registries.
Definition message_router_registry.h:76
void add(etl::imessage_router *p_router)
Definition message_router_registry.h:369
iterator lower_bound(etl::message_router_id_t id)
Get the lower bound in the registry with the specified ID.
Definition message_router_registry.h:324
bool contains(const etl::message_router_id_t id) const
Definition message_router_registry.h:403
bool contains(const etl::imessage_router &router) const
Definition message_router_registry.h:430
bool full() const
Returns true if the registry is full, otherwise false.
Definition message_router_registry.h:456
etl::imessage_router * find(etl::message_router_id_t id)
Get the first router in the registry with the specified ID.
Definition message_router_registry.h:293
bool empty() const
Returns true if the registry is empty, otherwise false.
Definition message_router_registry.h:448
void add(TIterator first, const TIterator &last)
Definition message_router_registry.h:382
size_t size() const
Returns the size of the registry.
Definition message_router_registry.h:464
size_t available() const
Returns the available size of the registry.
Definition message_router_registry.h:472
iterator upper_bound(etl::message_router_id_t id)
Get the upper bound in the registry with the specified ID.
Definition message_router_registry.h:337
bool contains(const etl::imessage_router *const p_router) const
Definition message_router_registry.h:414
size_t max_size() const
Returns the maximum size of the registry.
Definition message_router_registry.h:480
iterator end()
Get the end of the registry.
Definition message_router_registry.h:275
void add(etl::imessage_router &router)
Definition message_router_registry.h:351
iterator begin()
Get the beginning of the registry.
Definition message_router_registry.h:257
void remove(etl::message_router_id_t id)
Unregisters a router.
Definition message_router_registry.h:394
size_t count(const etl::message_router_id_t id) const
Returns the number of routers with the specified ID.
Definition message_router_registry.h:440
This is the base of all message routers.
Definition message_router.h:138
Base exception class for message router registry.
Definition message_router_registry.h:49
The registry is full.
Definition message_router_registry.h:62
Message router registry.
Definition message_router_registry.h:505
message_router_registry(TIterator first, const TIterator &last)
Definition message_router_registry.h:521
ETL_CONSTEXPR14 bool operator!=(const etl::bitset< Active_Bits, TElement > &lhs, const etl::bitset< Active_Bits, TElement > &rhs) ETL_NOEXCEPT
Definition bitset_new.h:2529
Definition exception.h:59
iterator end()
Definition flat_multimap.h:146
const_iterator cbegin() const
Definition flat_multimap.h:164
const_iterator cend() const
Definition flat_multimap.h:173
iterator upper_bound(const_key_reference key)
Definition flat_multimap.h:682
iterator find(const_key_reference key)
Definition flat_multimap.h:587
iterator lower_bound(const_key_reference key)
Definition flat_multimap.h:644
Definition flat_multimap.h:63
bitset_ext
Definition absolute.h:40
iterator
Definition iterator.h:424