52template<
typename Dict_by_ptr_t,
typename Dict_by_val_t>
63 using Cfg =
typename Dict_by_ptr::Cfg;
65 static_assert(std::is_same_v<Cfg, typename Dict_by_val::Cfg>,
66 "The two dictionary types must hold the same-typed Cfg payloads.");
88 void insert(
const std::type_info& type,
Cfg cfg,
bool type_info_ptr_is_uniq);
103 bool lookup(
const std::type_info& type,
Cfg* cfg)
const;
146template<
typename Map_to_cfg_t>
155 using Cfg =
typename Map_to_cfg::mapped_type;
176 void insert(
const std::type_info& type,
Cfg cfg);
191 bool lookup(
const std::type_info& type,
Cfg* cfg)
const;
214template<
typename Cfg_t>
232 void insert(
const std::type_info& type,
Cfg cfg);
241 bool lookup(
const std::type_info& type,
Cfg* cfg)
const;
276template<
typename Cfg_t>
294 void insert(
const std::type_info& type,
Cfg cfg);
303 bool lookup(
const std::type_info& type,
Cfg* cfg)
const;
344template<
typename Map_to_cfg_t>
352 using Cfg =
typename Map_to_cfg::mapped_type;
370 void insert(
const std::type_info& type,
Cfg cfg);
379 bool lookup(
const std::type_info& type,
Cfg* cfg)
const;
413template<
typename Cfg_t>
431 void insert(
const std::type_info& type,
Cfg cfg);
440 bool lookup(
const std::type_info& type,
Cfg* cfg)
const;
464 std::vector<std::pair<const std::type_info*, Cfg>>
m_dict;
474template<
typename Cfg_t>
492 void insert(
const std::type_info& type,
Cfg cfg);
501 bool lookup(
const std::type_info& type,
Cfg* cfg)
const;
528template<
typename Map_to_cfg_t>
534 m_dict.try_emplace(&type, cfg);
535 assert(result.second &&
"By contract duplicate insertion is disallowed.");
538template<
typename Map_to_cfg_t>
541 const auto it = m_dict.find(&type);
542 if (it == m_dict.end())
551template<
typename Map_to_cfg_t>
554 const std::type_index key{type};
559 m_dict.try_emplace(key, cfg);
560 assert(result.second &&
"By contract duplicate insertion is disallowed.");
563template<
typename Map_to_cfg_t>
566 const std::type_index key{type};
567 const auto it = m_dict.find(key);
569 if (it == m_dict.end())
578template<
typename Cfg_t>
581 m_dict_keys.emplace_back(&type);
582 m_dict_vals.emplace_back(cfg);
585template<
typename Cfg_t>
588 const auto it_begin = m_dict_keys.begin();
589 const auto it_end = m_dict_keys.end();
591 const auto it = std::find(it_begin, it_end, &type);
612 *cfg = m_dict_vals[it - it_begin];
616template<
typename Cfg_t>
619 m_dict.emplace_back(&type, cfg);
622template<
typename Cfg_t>
625 const auto it_end = m_dict.end();
627 const auto it = std::find_if(m_dict.begin(), it_end,
628 [&type](
const auto& key_and_val) ->
bool { return *key_and_val.first == type; });
643template<
typename Cfg_t>
648 const auto it = std::lower_bound(m_dict_sorted.begin(), m_dict_sorted.end(), &type,
649 [](
const auto& key_and_val,
const std::type_info* key) ->
bool
650 { return key_and_val.first < key; });
651 m_dict_sorted.emplace(it, &type, cfg);
654template<
typename Cfg_t>
657 const auto it_end = m_dict_sorted.end();
661 const auto it = std::lower_bound(m_dict_sorted.begin(), it_end, &type,
662 [](
const auto& key_and_val,
const std::type_info* key) ->
bool
663 { return key_and_val.first < key; });
666 if ((it == it_end) || (it->first != &type))
675template<
typename Cfg_t>
678 const auto it = std::lower_bound(m_dict_sorted.begin(), m_dict_sorted.end(), &type,
679 [](
const auto& key_and_val,
const std::type_info* key) ->
bool
680 { return key_and_val.first->before(*key); });
681 m_dict_sorted.emplace(it, &type, cfg);
684template<
typename Cfg_t>
687 const auto it_end = m_dict_sorted.end();
691 const auto it = std::lower_bound(m_dict_sorted.begin(), it_end, &type,
692 [](
const auto& key_and_val,
const std::type_info* key) ->
bool
693 { return key_and_val.first->before(*key); });
698 if ((it == it_end) || (*it->first != type))
707template<
typename Dict_by_ptr_t,
typename Dict_by_val_t>
709 bool type_info_ptr_is_uniq)
711 if (type_info_ptr_is_uniq)
713 m_dict_by_type_ptr.insert(type, cfg);
717 m_dict_by_type.insert(type, cfg);
721template<
typename Dict_by_ptr_t,
typename Dict_by_val_t>
724 return m_dict_by_type_ptr.lookup(type, cfg) || m_dict_by_type.lookup(type, cfg);
Exactly equivalent to Component_payload_type_dict_by_ptr_via_map but with impl = array with optimized...
bool lookup(const std::type_info &type, Cfg *cfg) const
See Component_payload_type_dict_by_ptr_via_map.
std::vector< Cfg > m_dict_vals
The values cfg passed to insert(), in the order in which they were invoked.
Cfg_t Cfg
See Component_payload_type_dict_by_ptr_via_map.
void insert(const std::type_info &type, Cfg cfg)
See Component_payload_type_dict_by_ptr_via_map.
static constexpr bool S_BY_PTR_ELSE_VAL
See Component_payload_type_dict_by_ptr_via_map.
std::vector< const std::type_info * > m_dict_keys
The values &type passed to insert(), in the order in which they were invoked.
An internal-use dictionary for fast lookup of small Cfg values keyed by type_info objects,...
typename Map_to_cfg::mapped_type Cfg
Convenience alias for the mapped-type looked-up by a *this.
bool lookup(const std::type_info &type, Cfg *cfg) const
Looks up a value previously added via insert(), or indicates no such value has yet been added.
Map_to_cfg_t Map_to_cfg
Convenience alias for template arg.
void insert(const std::type_info &type, Cfg cfg)
Adds a mapping from the given type to a Cfg value, so it can be obtained by lookup().
static constexpr bool S_BY_PTR_ELSE_VAL
For meta-programming convenience: true indicates for us type_info equality <=> &type_info equality; m...
Map_to_cfg m_dict
A ...map<type_info*, Cfg>, wherein insert() simply performs m_dict[&type] = cfg.
Exactly equivalent to Component_payload_type_dict_by_ptr_via_array but with impl = sorted array susce...
bool lookup(const std::type_info &type, Cfg *cfg) const
See Component_payload_type_dict_by_ptr_via_map.
void insert(const std::type_info &type, Cfg cfg)
See Component_payload_type_dict_by_ptr_via_map.
std::vector< std::pair< const std::type_info *, Cfg > > m_dict_sorted
The values pairs (&type, cfg) passed to insert(), in order of increasing &type (pointer) value.
static constexpr bool S_BY_PTR_ELSE_VAL
See Component_payload_type_dict_by_ptr_via_map.
Cfg_t Cfg
See Component_payload_type_dict_by_ptr_via_map.
Exactly equivalent to Component_payload_type_dict_by_val_via_map but with impl = array with linear se...
void insert(const std::type_info &type, Cfg cfg)
See Component_payload_type_dict_by_ptr_via_map.
std::vector< std::pair< const std::type_info *, Cfg > > m_dict
The values pairs (&type, cfg) passed to insert(), in the order in which they were invoked.
Cfg_t Cfg
See Component_payload_type_dict_by_ptr_via_map.
bool lookup(const std::type_info &type, Cfg *cfg) const
See Component_payload_type_dict_by_ptr_via_map.
static constexpr bool S_BY_PTR_ELSE_VAL
See Component_payload_type_dict_by_val_via_map.
An internal-use dictionary for fast lookup of small Cfg values keyed by type_info objects,...
Map_to_cfg m_dict
A ...map<type_index, Cfg>, wherein insert() simply performs m_dict[type_index(type)] = cfg.
typename Map_to_cfg::mapped_type Cfg
See Component_payload_type_dict_by_ptr_via_map.
Map_to_cfg_t Map_to_cfg
See Component_payload_type_dict_by_ptr_via_map.
static constexpr bool S_BY_PTR_ELSE_VAL
For meta-programming convenience: false indicates for us type_info equality <=> &type_info equality i...
void insert(const std::type_info &type, Cfg cfg)
See Component_payload_type_dict_by_ptr_via_map.
bool lookup(const std::type_info &type, Cfg *cfg) const
See Component_payload_type_dict_by_ptr_via_map.
Exactly equivalent to Component_payload_type_dict_by_val_via_array but with impl = sorted array susce...
std::vector< std::pair< const std::type_info *, Cfg > > m_dict_sorted
The values pairs (&type, cfg) passed to insert(), in order of increasing type value,...
bool lookup(const std::type_info &type, Cfg *cfg) const
See Component_payload_type_dict_by_ptr_via_map.
void insert(const std::type_info &type, Cfg cfg)
See Component_payload_type_dict_by_ptr_via_map.
Cfg_t Cfg
See Component_payload_type_dict_by_ptr_via_map.
static constexpr bool S_BY_PTR_ELSE_VAL
See Component_payload_type_dict_by_val_via_map.
An internal-use dictionary for fast lookup of small Cfg values keyed by type_info objects; impl = 1 C...
Dict_by_ptr_t Dict_by_ptr
Convenience alias for template arg.
Dict_by_ptr m_dict_by_type_ptr
The "fast" dictionary (wherein insert(type, ..., true)-originated values are stored).
Dict_by_val m_dict_by_type
The "slow" dictionary (wherein insert(type, ..., false)-originated values are stored).
Dict_by_val_t Dict_by_val
Convenience alias for template arg.
typename Dict_by_ptr::Cfg Cfg
Convenience alias for the mapped-type looked-up by a *this.
void insert(const std::type_info &type, Cfg cfg, bool type_info_ptr_is_uniq)
Adds a mapping from the given type to a Cfg value, so it can be obtained by lookup().
bool lookup(const std::type_info &type, Cfg *cfg) const
Looks up a value previously added via insert(), or indicates no such value has yet been added.
Flow module providing logging functionality.