opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
component_registry_entry.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <memory>
6#include <string_view>
7#include <utility>
8
9namespace opyn
10{
11 template<typename T>
13 public:
15 std::string_view name_,
16 std::string_view description_,
17 std::shared_ptr<const T> prototype_) :
18
19 ComponentRegistryEntryBase{name_, description_, std::move(prototype_)}
20 {}
21
22 const T& prototype() const
23 {
24 const auto& base = static_cast<const ComponentRegistryEntryBase&>(*this);
25 return static_cast<const T&>(base.prototype());
26 }
27
28 std::unique_ptr<T> instantiate() const
29 {
30 const auto& base = static_cast<const ComponentRegistryEntryBase&>(*this);
31 return std::unique_ptr<T>{static_cast<T*>(base.instantiate().release())};
32 }
33 };
34}
Definition component_registry_entry_base.h:12
Definition component_registry_entry.h:12
const T & prototype() const
Definition component_registry_entry.h:22
std::unique_ptr< T > instantiate() const
Definition component_registry_entry.h:28
ComponentRegistryEntry(std::string_view name_, std::string_view description_, std::shared_ptr< const T > prototype_)
Definition component_registry_entry.h:14
Definition component_registry.h:14