Class MessageTypeRegistry
A global registry that maps MessageTypeId values to deserialization functions and generic invocation delegates for all registered IMessage types.
Inherited Members
Namespace: Unity.SimulationPro.Foundation
Assembly: Unity.SimulationPro.Foundation.dll
Syntax
public static class MessageTypeRegistry
Remarks
Message types are registered automatically at startup by generated code via Register<T>(MessageTypeId, Func<IMessageDeserializer, T>). Use GetMessageTypeId<T>() and GetMessageTypeName<T>() to look up type metadata at runtime.
Methods
GetDeserializeFunction(MessageTypeId)
Returns the deserialization function for the given MessageTypeId.
Declaration
public static Func<IMessageDeserializer, IMessage> GetDeserializeFunction(MessageTypeId messageTypeId)
Parameters
| Type | Name | Description |
|---|---|---|
| MessageTypeId | messageTypeId | The message type to look up. |
Returns
| Type | Description |
|---|---|
| Func<IMessageDeserializer, IMessage> | A function that deserializes an IMessage from an IMessageDeserializer. |
GetDeserializeFunction<T>()
Returns the strongly-typed deserialization function for T.
Declaration
public static Func<IMessageDeserializer, T> GetDeserializeFunction<T>() where T : IMessage
Returns
| Type | Description |
|---|---|
| Func<IMessageDeserializer, T> | A function that deserializes a |
Type Parameters
| Name | Description |
|---|---|
| T | The IMessage type to look up. |
GetDisambiguator<T>()
Returns the MessageDisambiguator for T.
Declaration
public static MessageDisambiguator GetDisambiguator<T>() where T : IMessage
Returns
| Type | Description |
|---|---|
| MessageDisambiguator | The disambiguator value used to distinguish this type from others with the same name. |
Type Parameters
| Name | Description |
|---|---|
| T | The IMessage type to look up. |
GetGenericInvoker(string, MessageDisambiguator)
Returns the generic invoker delegate for the specified message type name and disambiguator.
Declaration
public static Func<MessageTypeRegistry.IGenericInvokable, object, object> GetGenericInvoker(string messageTypeName, MessageDisambiguator disambiguator = MessageDisambiguator.Default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | messageTypeName | The ROS message type name string. |
| MessageDisambiguator | disambiguator | The disambiguator for the message type. |
Returns
| Type | Description |
|---|---|
| Func<MessageTypeRegistry.IGenericInvokable, object, object> | A delegate that invokes an MessageTypeRegistry.IGenericInvokable for the matched type, or |
GetMessageTypeId<T>()
Returns the MessageTypeId for T.
Declaration
public static MessageTypeId GetMessageTypeId<T>() where T : IMessage
Returns
| Type | Description |
|---|---|
| MessageTypeId | The MessageTypeId registered for this message type. |
Type Parameters
| Name | Description |
|---|---|
| T | The IMessage type to look up. |
GetMessageTypeName<T>()
Returns the ROS message type name string for T.
Declaration
public static string GetMessageTypeName<T>() where T : IMessage
Returns
| Type | Description |
|---|---|
| string | The ROS message type name (e.g., |
Type Parameters
| Name | Description |
|---|---|
| T | The IMessage type to look up. |
InvokeGeneric(IGenericInvokable, object, string, MessageDisambiguator)
Invokes a generic operation on the registered type matching the given message type name and disambiguator.
Declaration
public static object InvokeGeneric(MessageTypeRegistry.IGenericInvokable invokable, object arg, string messageType, MessageDisambiguator disambiguator = MessageDisambiguator.Default)
Parameters
| Type | Name | Description |
|---|---|---|
| MessageTypeRegistry.IGenericInvokable | invokable | The operation to invoke. |
| object | arg | An argument passed to the invocation. |
| string | messageType | The ROS message type name string. |
| MessageDisambiguator | disambiguator | The disambiguator for the message type. |
Returns
| Type | Description |
|---|---|
| object | The result of the invocation, or |
Register<T>(MessageTypeId, Func<IMessageDeserializer, T>)
Registers a message type with its MessageTypeId and deserialization function.
Declaration
public static void Register<T>(MessageTypeId messageTypeId, Func<IMessageDeserializer, T> deserialize) where T : IMessage
Parameters
| Type | Name | Description |
|---|---|---|
| MessageTypeId | messageTypeId | The unique identifier for this message type. |
| Func<IMessageDeserializer, T> | deserialize | A function that deserializes a message of type |
Type Parameters
| Name | Description |
|---|---|
| T | The IMessage type being registered. |