CommRaT 2.0.0
C++20 Real-Time Messaging Framework
Loading...
Searching...
No Matches
commrat::IntrospectionHelper< UserRegistry > Struct Template Reference

Registry-wide introspection and schema export. More...

#include <commrat/introspection/introspection_helper.hpp>

Static Public Member Functions

template<typename T , typename Writer = rfl::json::Writer>
static std::string export_as ()
 Export complete schema for a message type.
 
template<typename Writer = rfl::json::Writer>
static std::string export_all ()
 Export complete schemas for all registered messages.
 
template<typename Writer = rfl::json::Writer>
static void write_to_file (const std::string &filename)
 Convenience: write all schemas to file.
 

Detailed Description

template<typename UserRegistry>
struct commrat::IntrospectionHelper< UserRegistry >

Registry-wide introspection and schema export.

Provides methods to export complete message schemas (CommRaT metadata + SeRTial layout) for individual messages or all messages in a registry.

Format-agnostic - supports any rfl format (JSON, YAML, TOML, XML, etc.) via Writer type.

Template Parameters
UserRegistryThe CommRaT registry to introspect

Usage:

// Export single message schema to JSON (default)
auto json = MyApp::Introspection::export_as<TempData>();
// Export single message schema to YAML
auto yaml = MyApp::Introspection::export_as<TempData, rfl::yaml::Writer>();
// Export all message schemas to JSON
auto all_json = MyApp::Introspection::export_all();
// Export all message schemas to TOML
auto all_toml = MyApp::Introspection::export_all<rfl::toml::Writer>();
// Write all schemas to file
MyApp::Introspection::write_to_file<rfl::json>("schemas.json");
CommRaT Application Template - Main User-Facing Interface.
Definition commrat.hpp:111
Message definition with compile-time ID assignment.

Definition at line 61 of file introspection_helper.hpp.

Member Function Documentation

◆ export_all()

template<typename UserRegistry >
template<typename Writer = rfl::json::Writer>
static std::string commrat::IntrospectionHelper< UserRegistry >::export_all ( )
inlinestatic

Export complete schemas for all registered messages.

Returns array/collection of MessageSchema instances, one per registered type. Each contains full CommRaT metadata + SeRTial layout.

Useful for:

  • Generating documentation for all message types
  • Providing schema catalog to viewer/logger tools
  • Runtime type discovery and validation
Template Parameters
Formatrfl format (json, yaml, toml, xml, etc.)
Returns
Formatted collection (array/list) of all message schemas

Example Output (JSON):

[
{
"commrat": { "message_id": 123, "payload_type": "TempData", ... },
"layout": { "num_fields": 2, ... }
},
{
"commrat": { "message_id": 456, "payload_type": "StatusData", ... },
"layout": { "num_fields": 3, ... }
}
]
Template Parameters
Writerrfl Writer type (default: rfl::json::Writer)
Returns
Formatted collection of all message schemas
See also
export_as for single message export
write_to_file for file output convenience

Definition at line 158 of file introspection_helper.hpp.

◆ export_as()

template<typename UserRegistry >
template<typename T , typename Writer = rfl::json::Writer>
static std::string commrat::IntrospectionHelper< UserRegistry >::export_as ( )
inlinestatic

Export complete schema for a message type.

Exports MessageSchema<T, Registry> which includes:

  • CommRaT metadata (message_id, type_names, max_size)
  • TimsMessage<T> structure (header + payload)
  • SeRTial layout (fields, offsets, sizes, variable flags)
Template Parameters
TPayload type (must be registered in UserRegistry)
Formatrfl format (json, yaml, toml, xml, etc.)
Returns
Formatted string containing complete message schema

Example Output (JSON):

{
"commrat": {
"message_id": 2847561283,
"payload_type": "TemperatureData",
"full_type": "commrat::TimsMessage<TemperatureData>",
"max_message_size": 4096,
"registry_name": "MyApp"
},
"layout": {
"num_fields": 2,
"sizeof_bytes": 72,
"base_packed_size": 68,
"max_packed_size": 68,
"has_variable_fields": false,
"fields": [
{
"name": "header",
"type": "TimsHeader",
"offset": 0,
"size": 64,
"is_variable": false
},
{
"name": "payload",
"type": "TemperatureData",
"offset": 64,
"size": 8,
"is_variable": false
}
]
}
}
Template Parameters
TPayload type to export schema for
Writerrfl Writer type (default: rfl::json::Writer)
Returns
Formatted string containing the message schema
Note
All metadata computed at compile time - no runtime cost
See also
MessageSchema for complete schema structure

Definition at line 118 of file introspection_helper.hpp.

◆ write_to_file()

template<typename UserRegistry >
template<typename Writer = rfl::json::Writer>
static void commrat::IntrospectionHelper< UserRegistry >::write_to_file ( const std::string &  filename)
inlinestatic

Convenience: write all schemas to file.

Exports all message schemas and writes to specified file. File format determined by Format template parameter.

Template Parameters
Formatrfl format (json, yaml, toml, xml, etc.)
Parameters
filenameOutput file path

Usage:

// Write JSON schemas (default)
MyApp::Introspection::write_to_file("schemas.json");
// Write YAML schemas
MyApp::Introspection::write_to_file<rfl::yaml::Writer>("schemas.yaml");
// Write TOML schemas
MyApp::Introspection::write_to_file<rfl::toml::Writer>("schemas.toml");
Template Parameters
Writerrfl Writer type (default: rfl::json::Writer)
Parameters
filenameOutput file path
Note
Creates file if it doesn't exist, overwrites if it does

Definition at line 190 of file introspection_helper.hpp.


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