rigProject 0.1.1
RigKit pack API - rigProject
Loading...
Searching...
No Matches
AddSerializer.h File Reference

Templates that register one component codec on a document registry. More...

#include <functional>
#include <string>
#include "ecs/MEcs.h"
#include "ComponentSerializerRegistry.h"
Include dependency graph for AddSerializer.h:

Functions

template<typename T>
void rigkit::project::addSerializer (ComponentSerializerRegistry &registry, const char *key, const char *schemaId, std::function< bool(entt::registry &, entt::entity, ordered_json &)> serializeFn, std::function< bool(entt::registry &, entt::entity, const ordered_json &)> deserializeFn, std::function< void(entt::registry &, const EntityIdMap &)> remapReferences={})
 Register a typed component codec on a document registry.
template<typename T>
void rigkit::project::registerComponent (MEcs &ecs, ComponentSerializerRegistry &registry, const char *name, const char *schemaId, std::function< bool(entt::registry &, entt::entity, ordered_json &)> serializeFn, std::function< bool(entt::registry &, entt::entity, const ordered_json &)> deserializeFn, std::function< void(entt::registry &, const EntityIdMap &)> remapReferences={})
 Announce a portable component and file its document codec.
template<typename T, bool T::* Member>
void rigkit::project::addBoolMemberSerializer (ComponentSerializerRegistry &registry, const char *key, const char *schemaId, const char *fieldName)
 Single bool field under a Contract / extension key (e.g.
template<typename T>
void rigkit::project::addMarkerSerializer (ComponentSerializerRegistry &registry, const char *key, const char *schemaId)
 Empty marker component - wire value is {}.

Detailed Description

Templates that register one component codec on a document registry.

They stay inline so rigProject never needs to see the component type.

Function Documentation

◆ addBoolMemberSerializer()

template<typename T, bool T::* Member>
void rigkit::project::addBoolMemberSerializer ( ComponentSerializerRegistry & registry,
const char * key,
const char * schemaId,
const char * fieldName )

Single bool field under a Contract / extension key (e.g.

selectable.enabled).

◆ addSerializer()

template<typename T>
void rigkit::project::addSerializer ( ComponentSerializerRegistry & registry,
const char * key,
const char * schemaId,
std::function< bool(entt::registry &, entt::entity, ordered_json &)> serializeFn,
std::function< bool(entt::registry &, entt::entity, const ordered_json &)> deserializeFn,
std::function< void(entt::registry &, const EntityIdMap &)> remapReferences = {} )

Register a typed component codec on a document registry.

Packs that own portable PODs call this from setup() (via rigProject::registerSerializer / the registry). One schema id per call.

◆ registerComponent()

template<typename T>
void rigkit::project::registerComponent ( MEcs & ecs,
ComponentSerializerRegistry & registry,
const char * name,
const char * schemaId,
std::function< bool(entt::registry &, entt::entity, ordered_json &)> serializeFn,
std::function< bool(entt::registry &, entt::entity, const ordered_json &)> deserializeFn,
std::function< void(entt::registry &, const EntityIdMap &)> remapReferences = {} )

Announce a portable component and file its document codec.

Owning data packs call this from setup() when rigProject is loaded. One schema id per call. A second schema on the same POD stays addSerializer.