36 void add(std::unique_ptr<Entry> entry) {
37 for (
const std::string& name : entry->names()) {
38 if (
find(name) !=
nullptr)
39 throw std::logic_error(
"The name '" + name +
"' is already registered");
41 entries_.push_back(std::move(entry));
45 [[nodiscard]]
const Entry*
find(
const std::string& name)
const {
46 for (
const auto& entry : entries_) {
47 for (
const std::string& entry_name : entry->names()) {
48 if (entry_name == name)
56 [[nodiscard]]
const std::vector<std::unique_ptr<Entry>>&
entries()
const {
66 for (
const auto& entry : entries_) {
69 joined += entry->names().front();
75 std::vector<std::unique_ptr<Entry>> entries_;
An ordered set of interchangeable implementations of Entry, found by name.
std::string canonical_names(const std::string &separator) const
const std::vector< std::unique_ptr< Entry > > & entries() const
Every entry, in registration order.
const Entry * find(const std::string &name) const
The entry answering to name, or nullptr when none does.
void add(std::unique_ptr< Entry > entry)
Add entry; throws std::logic_error when one of its names is already registered.