Toast Engine
Loading...
Searching...
No Matches
toast::NodeInfo Struct Reference

Complete reflection record for a registered Node type. More...

#include <reflect_node.hpp>

Collaboration diagram for toast::NodeInfo:

Public Types

using Factory = Node* (*)()
using Deleter = void (*)(Node*)

Public Member Functions

auto getSignal (std::string_view field_name) const -> const SignalInfo *
 Finds a signal by name in this type's signals, then walks base_type if not found.
auto getSignal (std::string_view declaring_type, std::string_view signal_name) const -> const SignalInfo *
template<typename F>
void forEachSignal (F &&callback) const
auto getField (std::string_view field_name) const -> const FieldInfo *
 Finds a field by name in this type's all_fields, then walks base_type if not found.
auto getMethod (std::string_view method_name) const -> const FunctionInfo *
 Finds a reflected function by name in this type, then walks base_type if not found.
template<typename R = void, typename... Args>
auto call (void *obj, std::string_view method_name, Args &&... args) const -> R
 Walks base->derived calling every inheritance level that defines method_name, then fires Lua scripts.
auto callAllDynamic (void *obj, std::string_view method_name, std::span< const std::any > args) const -> std::any
 Walks base->derived via dynamic invokers, calling every level that defines method_name.
auto isA (const NodeInfo *other) const -> bool
 Checks whether this type is the same as or a subtype of another.
auto hasFunction (TickFunctionList mask) const -> bool
 Checks whether this type or any base type implements the given lifecycle phase(s).
constexpr auto id () const -> uint32_t
 FNV-1a hash of the type string; not the same as a Node's runtime UID.
auto getGroup (std::string_view group_name) const -> const GroupInfo *
 Finds a group by name, walking base_type if not found.
auto search (std::string_view field_name) const -> const FieldInfo *
 Finds a field by name, walking the full inheritance chain.
template<typename F>
void forEachBaseType (F &&fn) const
 Calls fn for each NodeInfo in the inheritance chain, from the root base down to this type.

Public Attributes

std::string_view type
const NodeInfo * base_type
std::span< const SignalInfo > signals
std::span< const FieldInfo > all_fields
std::span< const FieldInfo *const > fields
std::span< const GroupInfo > groups
std::span< const FunctionInfo > methods
TickFunctions functions
Factory construct = nullptr
Deleter destroy = nullptr

Detailed Description

Complete reflection record for a registered Node type.

Populated by the generated Reflect<T> specialization at program startup. base_type chains through C++ inheritance so that field lookups and isA() checks traverse the full type hierarchy without RTTI.

Note
NodeInfo instances are static globals; comparing two NodeInfo pointers for equality is a valid way to test for identical types

Member Function Documentation

◆ call()

template<typename R = void, typename... Args>
auto toast::NodeInfo::call ( void * obj,
std::string_view method_name,
Args &&... args ) const -> R
inline

Walks base->derived calling every inheritance level that defines method_name, then fires Lua scripts.

Returns
the most-derived level's return value

◆ callAllDynamic()

auto toast::NodeInfo::callAllDynamic ( void * obj,
std::string_view method_name,
std::span< const std::any > args ) const -> std::any
inlinenodiscard

Walks base->derived via dynamic invokers, calling every level that defines method_name.

Returns
the most-derived level's return value

◆ forEachBaseType()

template<typename F>
void toast::NodeInfo::forEachBaseType ( F && fn) const
inline

Calls fn for each NodeInfo in the inheritance chain, from the root base down to this type.

Parameters
fnCallable taking a const NodeInfo&; called once per type in base-first order
Note
Useful for collecting all fields including inherited ones without duplicates

◆ getField()

auto toast::NodeInfo::getField ( std::string_view field_name) const -> const FieldInfo *
inlinenodiscard

Finds a field by name in this type's all_fields, then walks base_type if not found.

Parameters
field_nameThe reflected field name to look up
Returns
Pointer to the matching FieldInfo, or nullptr if the field is not reflected anywhere in the hierarchy

◆ getGroup()

auto toast::NodeInfo::getGroup ( std::string_view group_name) const -> const GroupInfo *
inlinenodiscard

Finds a group by name, walking base_type if not found.

Parameters
group_nameThe group name to look up
Returns
Pointer to the matching GroupInfo, or nullptr if no such group exists in this type or its bases

◆ getMethod()

auto toast::NodeInfo::getMethod ( std::string_view method_name) const -> const FunctionInfo *
inlinenodiscard

Finds a reflected function by name in this type, then walks base_type if not found.

Parameters
method_nameThe reflected function name to look up
Returns
Pointer to the matching FunctionInfo, or nullptr if the function is not reflected anywhere in the hierarchy
Here is the caller graph for this function:

◆ getSignal()

auto toast::NodeInfo::getSignal ( std::string_view field_name) const -> const SignalInfo *
inlinenodiscard

Finds a signal by name in this type's signals, then walks base_type if not found.

Parameters
signal_nameThe reflected signal name to look up
Returns
Pointer to the matching SignalInfo, or nullptr if the signal is not reflected anywhere in the hierarchy

◆ hasFunction()

auto toast::NodeInfo::hasFunction ( TickFunctionList mask) const -> bool
inlinenodiscard

Checks whether this type or any base type implements the given lifecycle phase(s).

Parameters
maskA TickFunctionList bitflag; use tick_mask to check for any per-frame phase
Returns
true if any bit in mask is set in functions.list anywhere in the inheritance chain

◆ isA()

auto toast::NodeInfo::isA ( const NodeInfo * other) const -> bool
inlinenodiscard

Checks whether this type is the same as or a subtype of another.

Parameters
otherThe NodeInfo to test against
Returns
true if this type's inheritance chain passes through other; equivalent to dynamic_cast but without RTTI

◆ search()

auto toast::NodeInfo::search ( std::string_view field_name) const -> const FieldInfo *
inlinenodiscard

Finds a field by name, walking the full inheritance chain.

Parameters
field_nameThe reflected field name to look up
Returns
Pointer to the matching FieldInfo, or nullptr if not found
Note
Prefer getField() for new code; this is an alias kept for backwards compatibility

The documentation for this struct was generated from the following file: