#include <Types.h>
|
template<typename Self > |
using | SelfRef = TSharedRef<std::decay_t<Self>> |
|
|
virtual | ~IHaveType ()=default |
|
template<typename Self > |
SelfRef< Self > | WithType (this Self &&self) |
|
FORCEINLINE FName const & | GetType () const |
|
template<typename Derived , typename Self > |
TSharedPtr< Derived > | AsExactly (this Self &&self) |
|
|
template<typename Self > |
void | SetType (this Self &&self) |
|
A barebones base class for types which may store their type-name as a string
- Todo
- C++ 26 has promising proposal for static value-based reflection, which can gather metadata from classes or even emit them. The best summary I found so far is a stack-overflow answer https://stackoverflow.com/a/77477029 Once that's available we can gather base classes in compile time, and do dynamic casting of objects without the need for intrusive extra syntax, or extra work at construction. Currently GCC's
__bases
would be perfect for the job, but other popular compilers don't have similar intrinsics.
Definition at line 41 of file Types.h.
◆ SelfRef
◆ ~IHaveType()
virtual Mcro::Types::IHaveType::~IHaveType |
( |
| ) |
|
|
virtualdefault |
◆ AsExactly()
template<typename Derived , typename Self >
TSharedPtr< Derived > Mcro::Types::IHaveType::AsExactly |
( |
this Self && | self | ) |
|
|
inline |
Very simple dynamic casting of this object to a derived top-level type.
- Template Parameters
-
Derived | Only return the desired type when the current object is exactly that type, and doesn't have deeper inheritance. Proper dynamic casting regarding the entire inheritance tree still without RTTI will come once proposed C++26 value-typed reflection becomes available. |
- Returns
- Object cast to desired type when that's possible (see
Derived
) or nullptr;
Definition at line 81 of file Types.h.
◆ GetType()
FORCEINLINE FName const & Mcro::Types::IHaveType::GetType |
( |
| ) |
const |
|
inline |
◆ SetType()
template<typename Self >
void Mcro::Types::IHaveType::SetType |
( |
this Self && | self | ) |
|
|
inlineprotected |
This function needs to be called on top level derived type for runtime reflection to work
Definition at line 51 of file Types.h.
◆ WithType()
template<typename Self >
SelfRef< Self > Mcro::Types::IHaveType::WithType |
( |
this Self && | self | ) |
|
|
inline |
Fluent API for setting tpye for deferred initialization (for example in factory functions)
Definition at line 62 of file Types.h.
◆ TypeName
FName Mcro::Types::IHaveType::TypeName |
|
protected |
The documentation for this class was generated from the following file: