EntropyEngine::Networking::ComponentSchemaRegistry
EntropyEngine::Networking::ComponentSchemaRegistry
Section titled “EntropyEngine::Networking::ComponentSchemaRegistry”Thread-safe registry for component schemas. More…
#include <ComponentSchemaRegistry.h>
Public Types
Section titled “Public Types”| Name | |
|---|---|
| using std::function< void(ComponentTypeHash typeHash)> | SchemaUnpublishedCallback Callback invoked when a schema is unpublished (made private). |
| using std::function< void(ComponentSchemaRegistry &)> | SchemaRegistrationCallback Callback for auto-registration during construction. |
| using std::function< void(ComponentTypeHash typeHash, const ComponentSchema &schema)> | SchemaPublishedCallback Callback invoked when a schema is published (made public). |
Public Functions
Section titled “Public Functions”| Name | |
|---|---|
| ~ComponentSchemaRegistry() =default | |
| Result< void > | validateDetailedCompatibility(ComponentTypeHash source, ComponentTypeHash target) const Validate detailed compatibility. |
| Result< void > | unpublishSchema(ComponentTypeHash typeHash) Unpublish a public schema. |
| void | setSchemaUnpublishedCallback(SchemaUnpublishedCallback callback) Set callback for schema unpublish events. |
| void | setSchemaPublishedCallback(SchemaPublishedCallback callback) Set callback for schema publish events. |
| size_t | schemaCount() const Get total schema count. |
| Result< ComponentTypeHash > | registerSchema(const ComponentSchema & schema) Register a component schema. |
| Result< void > | publishSchema(ComponentTypeHash typeHash) Publish a private schema. |
| size_t | publicSchemaCount() const Get public schema count. |
| ComponentSchemaRegistry & | operator=(const ComponentSchemaRegistry & ) =delete |
| ComponentSchemaRegistry & | operator=(ComponentSchemaRegistry && ) =delete |
| bool | isRegistered(ComponentTypeHash typeHash) const Check if schema is registered. |
| bool | isPublic(ComponentTypeHash typeHash) const Check if schema is public. |
| void | getStats(size_t & totalCount, size_t & publicCount, std::vector< ComponentSchema > & publicSchemas) const Get consistent snapshot of registry stats. |
| std::optional< ComponentSchema > | getSchema(ComponentTypeHash typeHash) const Lookup schema by type hash. |
| std::vector< ComponentSchema > | getPublicSchemas() const Get all public schemas. |
| std::vector< ComponentTypeHash > | findCompatibleSchemas(ComponentTypeHash typeHash) const Find schemas compatible with given type hash. |
| bool | areCompatible(ComponentTypeHash a, ComponentTypeHash b) const Check if two schemas are structurally compatible. |
| ComponentSchemaRegistry() =default | |
| ComponentSchemaRegistry(SchemaRegistrationCallback initCallback) Construct with auto-registration callback. | |
| ComponentSchemaRegistry(const ComponentSchemaRegistry & ) =delete | |
| ComponentSchemaRegistry(ComponentSchemaRegistry && ) =delete |
Detailed Description
Section titled “Detailed Description”class EntropyEngine::Networking::ComponentSchemaRegistry;Thread-safe registry for component schemas.
Provides opt-in schema discovery and compatibility validation. Applications can:
- Register schemas (public or private)
- Query schemas by hash
- Find compatible schemas
- Validate compatibility
Default behavior: Schemas are private unless explicitly published.
Thread Safety:
- All operations are thread-safe using shared_mutex
- Multiple concurrent readers, single writer
- Pre-lock validation for performance
Memory Efficiency:
- Single registry instance per server
- Structural hash indexing for fast compatibility queries
- Public/private schema separation
Public Types Documentation
Section titled “Public Types Documentation”using SchemaUnpublishedCallback
Section titled “using SchemaUnpublishedCallback”using EntropyEngine::Networking::ComponentSchemaRegistry::SchemaUnpublishedCallback = std::function<void(ComponentTypeHash typeHash)>;Callback invoked when a schema is unpublished (made private).
using SchemaRegistrationCallback
Section titled “using SchemaRegistrationCallback”using EntropyEngine::Networking::ComponentSchemaRegistry::SchemaRegistrationCallback = std::function<void(ComponentSchemaRegistry&)>;Callback for auto-registration during construction.
using SchemaPublishedCallback
Section titled “using SchemaPublishedCallback”using EntropyEngine::Networking::ComponentSchemaRegistry::SchemaPublishedCallback = std::function<void(ComponentTypeHash typeHash, const ComponentSchema& schema)>;Callback invoked when a schema is published (made public).
Public Functions Documentation
Section titled “Public Functions Documentation”function ~ComponentSchemaRegistry
Section titled “function ~ComponentSchemaRegistry”~ComponentSchemaRegistry() =defaultfunction validateDetailedCompatibility
Section titled “function validateDetailedCompatibility”Result< void > validateDetailedCompatibility( ComponentTypeHash source, ComponentTypeHash target) constValidate detailed compatibility.
Parameters:
- source Source schema
- target Target schema
Return: Result with detailed error messages if incompatible
Performs field-by-field validation. More expensive than structural hash check. Application decides what to do with the result.
@threadsafety Thread-safe (read lock)
function unpublishSchema
Section titled “function unpublishSchema”Result< void > unpublishSchema( ComponentTypeHash typeHash)Unpublish a public schema.
Parameters:
- typeHash Component type hash
Return: Result indicating success or error
Makes a public schema private (no longer discoverable).
@threadsafety Thread-safe (write lock)
function setSchemaUnpublishedCallback
Section titled “function setSchemaUnpublishedCallback”void setSchemaUnpublishedCallback( SchemaUnpublishedCallback callback)Set callback for schema unpublish events.
Parameters:
- callback Function to call on unpublish (invoked under lock)
Called when unpublishSchema() makes a public schema private. Useful for notifying clients that schema is no longer available.
@threadsafety Not thread-safe - set before unpublishing schemas
function setSchemaPublishedCallback
Section titled “function setSchemaPublishedCallback”void setSchemaPublishedCallback( SchemaPublishedCallback callback)Set callback for schema publish events.
Parameters:
- callback Function to call on publish (invoked under lock)
Called when publishSchema() makes a private schema public. Useful for broadcasting schema availability to connected clients.
@threadsafety Not thread-safe - set before publishing schemas
function schemaCount
Section titled “function schemaCount”size_t schemaCount() constGet total schema count.
Return: Number of registered schemas (public + private)
@threadsafety Thread-safe (read lock)
function registerSchema
Section titled “function registerSchema”Result< ComponentTypeHash > registerSchema( const ComponentSchema & schema)Register a component schema.
Parameters:
- schema Component schema to register
Return: Result with ComponentTypeHash on success
Schemas are private by default unless isPublic=true. Re-registering the same schema (same typeHash) is idempotent.
@threadsafety Thread-safe (write lock)
ComponentSchemaRegistry registry;auto schema = ComponentSchema::create("App", "Transform", 1, properties, 40, false);if (schema.success()) { auto result = registry.registerSchema(schema.value()); if (result.success()) { ENTROPY_LOG_INFO("Registered schema: {}", toString(result.value())); }}function publishSchema
Section titled “function publishSchema”Result< void > publishSchema( ComponentTypeHash typeHash)Publish a private schema.
Parameters:
- typeHash Component type hash
Return: Result indicating success or error
Makes a previously private schema public for discovery.
@threadsafety Thread-safe (write lock)
function publicSchemaCount
Section titled “function publicSchemaCount”size_t publicSchemaCount() constGet public schema count.
Return: Number of public schemas
@threadsafety Thread-safe (read lock)
function operator=
Section titled “function operator=”ComponentSchemaRegistry & operator=( const ComponentSchemaRegistry &) =deletefunction operator=
Section titled “function operator=”ComponentSchemaRegistry & operator=( ComponentSchemaRegistry &&) =deletefunction isRegistered
Section titled “function isRegistered”bool isRegistered( ComponentTypeHash typeHash) constCheck if schema is registered.
Parameters:
- typeHash Component type hash
Return: true if registered (public or private)
@threadsafety Thread-safe (read lock)
function isPublic
Section titled “function isPublic”bool isPublic( ComponentTypeHash typeHash) constCheck if schema is public.
Parameters:
- typeHash Component type hash
Return: true if schema is published for discovery
@threadsafety Thread-safe (read lock)
function getStats
Section titled “function getStats”void getStats( size_t & totalCount, size_t & publicCount, std::vector< ComponentSchema > & publicSchemas) constGet consistent snapshot of registry stats.
Parameters:
- totalCount Total number of schemas
- publicCount Number of public schemas
- publicSchemas Vector of public schemas
Returns all stats under a single lock to ensure consistency. Useful for concurrent readers that need consistent view of state.
@threadsafety Thread-safe (read lock)
function getSchema
Section titled “function getSchema”std::optional< ComponentSchema > getSchema( ComponentTypeHash typeHash) constLookup schema by type hash.
Parameters:
- typeHash Component type hash
Return: Optional schema if found
Returns schema if registered (public or private).
@threadsafety Thread-safe (read lock)
function getPublicSchemas
Section titled “function getPublicSchemas”std::vector< ComponentSchema > getPublicSchemas() constGet all public schemas.
Return: Vector of public schemas
Returns only schemas marked as public. Used for schema discovery by other applications.
@threadsafety Thread-safe (read lock)
function findCompatibleSchemas
Section titled “function findCompatibleSchemas”std::vector< ComponentTypeHash > findCompatibleSchemas( ComponentTypeHash typeHash) constFind schemas compatible with given type hash.
Parameters:
- typeHash Component type hash to match
Return: Vector of compatible component type hashes
Returns all public schemas that are structurally compatible (matching structural hash).
@threadsafety Thread-safe (read lock)
function areCompatible
Section titled “function areCompatible”bool areCompatible( ComponentTypeHash a, ComponentTypeHash b) constCheck if two schemas are structurally compatible.
Parameters:
- a First component type hash
- b Second component type hash
Return: true if structurally compatible
Fast check using structural hash comparison.
@threadsafety Thread-safe (read lock)
function ComponentSchemaRegistry
Section titled “function ComponentSchemaRegistry”ComponentSchemaRegistry() =defaultfunction ComponentSchemaRegistry
Section titled “function ComponentSchemaRegistry”explicit ComponentSchemaRegistry( SchemaRegistrationCallback initCallback)Construct with auto-registration callback.
Parameters:
- initCallback Function called during construction to register schemas
Allows registering schemas during construction, e.g., for built-in schemas.
ComponentSchemaRegistry registry([](ComponentSchemaRegistry& reg) { EntropyCanvas::Schema::registerBuiltinSchemas(reg);});function ComponentSchemaRegistry
Section titled “function ComponentSchemaRegistry”ComponentSchemaRegistry( const ComponentSchemaRegistry &) =deletefunction ComponentSchemaRegistry
Section titled “function ComponentSchemaRegistry”ComponentSchemaRegistry( ComponentSchemaRegistry &&) =deleteUpdated on 2026-01-26 at 17:14:35 -0500