16 #error no need to expose this header to Swig
20 #ifndef BORNAGAIN_SAMPLE_SAMPLEBUILDERENGINE_IREGISTRY_H
21 #define BORNAGAIN_SAMPLE_SAMPLEBUILDERENGINE_IREGISTRY_H
35 const ValueType*
getItem(
const std::string& key)
const
37 auto it =
m_data.find(key);
39 throw std::runtime_error(
"Key '" + key +
"' not found in registry");
40 return it->second.get();
43 std::vector<std::string>
keys()
const
45 std::vector<std::string> result;
46 for (
const auto& it :
m_data)
47 result.push_back(it.first);
54 void add(
const std::string& key, ValueType* item)
57 throw std::runtime_error(
"Key '" + key +
"' already in registry");
58 m_data[key] = std::unique_ptr<ValueType>(item);
62 std::map<std::string, std::unique_ptr<ValueType>>
m_data;
Templated object registry.
std::map< std::string, std::unique_ptr< ValueType > > m_data
void add(const std::string &key, ValueType *item)
const ValueType * getItem(const std::string &key) const
std::vector< std::string > keys() const