vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
Vkm::Engine::BehaviorFieldVisitor Class Referenceabstract

Type-erased visitor over a behavior's reflected authoring fields. More...

#include <behavior_field_visitor.h>

Public Member Functions

virtual void enumField (const char *name, int &index, const char *const *names, std::size_t count)=0
 Visit an enum field, type-erased to (name index, name table).
virtual void assetField (const char *name, std::string &assetName, AssetType type)=0
 Visit a field that names an asset, type-erased to (name, kind).
virtual bool beginStruct (const char *name)=0
 Enter a nested reflected-struct field; return true to descend.
virtual void endStruct ()=0
 Leave the struct opened by a beginStruct() that returned true.

Detailed Description

Type-erased visitor over a behavior's reflected authoring fields.

ReflectedBehavior::visitFields dispatches each field: leaves to a field() overload (the one closed set; add an overload for a new type), VKM_ENUM_NAMES enums to enumField(), AssetRef<Asset> to assetField(), and VKM_REFLECT-ed structs through beginStruct()/endStruct().

Member Function Documentation

◆ enumField()

virtual void Vkm::Engine::BehaviorFieldVisitor::enumField ( const char * name,
int & index,
const char *const * names,
std::size_t count )
pure virtual

Visit an enum field, type-erased to (name index, name table).

Serialize by name (names[index]), never the integer, so reordering values keeps scenes valid.

Parameters
nameField name.
indexIn: current value. Out: the visitor's chosen value.
namesValue-ordered names[count] from the enum's EnumNames.
countNumber of names.

◆ assetField()

virtual void Vkm::Engine::BehaviorFieldVisitor::assetField ( const char * name,
std::string & assetName,
AssetType type )
pure virtual

Visit a field that names an asset, type-erased to (name, kind).

The name, not a handle, is the serializable identity; a serializer needs type to save the asset too, or the reference resolves to nothing on load.

Parameters
nameField name.
assetNameIn: the current reference, empty for none. Out: the visitor's chosen one.
typeAsset kind the field may reference.

◆ beginStruct()

virtual bool Vkm::Engine::BehaviorFieldVisitor::beginStruct ( const char * name)
pure virtual

Enter a nested reflected-struct field; return true to descend.

False skips the children and no endStruct() follows, so open per-struct scope (a JSON sub-object, a tree node) only on the true path.

Parameters
nameField name of the nested struct.
Returns
True to visit its sub-fields and then endStruct().

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