29#include <unordered_map>
88 }
catch (std::out_of_range
const &) {
89 throw std::domain_error(
"Class '" + name +
"' not found.");
100 return m_map.contains(name);
108 template <
typename Derived>
void register_new(std::string
const &name) {
109 if (m_map.contains(name)) {
110 throw std::runtime_error(
"Name '" + name +
"' was already registered.");
113 m_type_map[
typeid(
Derived)] = name;
131 return m_type_map.at(
typeid(
o));
136 std::unordered_map<std::string, builder_type> m_map;
138 std::unordered_map<std::type_index, std::string> m_type_map;
pointer_type(*)() builder_type
Type of the constructor functions.
void register_new(std::string const &name)
Register a new type with the default construction function.
bool has_builder(std::string const &name) const
Check if the factory knows how to make name.
pointer_type make(std::string const &name) const
Construct an instance by name.
std::unique_ptr< Base > pointer_type
The returned pointer type.
auto const & type_name(Base const &o) const
Look up name for type.
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.