Fast DDS  Version 3.6.1.0
Fast DDS
Loading...
Searching...
No Matches
TopicDataType Class Referenceabstract

Class TopicDataType used to provide the DomainRTPSParticipant with the methods to serialize, deserialize and get the key of a specific data type. More...

#include <TopicDataType.hpp>

Inheritance diagram for TopicDataType:

Classes

struct  Context
 An interface to provide the user with a context when serializing and deserializing data. More...

Public Member Functions

FASTDDS_EXPORTED_API TopicDataType ()=default
 Constructor.
virtual FASTDDS_EXPORTED_API ~TopicDataType ()=default
 Destructor.
virtual FASTDDS_EXPORTED_API bool serialize (const void *const data, rtps::SerializedPayload_t &payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation)=0
 Serialize method, it should be implemented by the user, since it is abstract.
virtual FASTDDS_EXPORTED_API bool serialize_ctx (const std::shared_ptr< Context > &context, const void *const data, rtps::SerializedPayload_t &payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation)
 Serialize method with context, it can be reimplemented by the user to perform custom serialization depending on the context received.
virtual FASTDDS_EXPORTED_API bool deserialize (rtps::SerializedPayload_t &payload, void *data)=0
 Deserialize method, it should be implemented by the user, since it is abstract.
virtual FASTDDS_EXPORTED_API bool deserialize_ctx (const std::shared_ptr< Context > &context, rtps::SerializedPayload_t &payload, void *data)
 Deserialize method with context, it can be reimplemented by the user to perform custom deserialization depending on the context received.
virtual FASTDDS_EXPORTED_API uint32_t calculate_serialized_size (const void *const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation)=0
 Calculates the serialized size of the provided data.
virtual FASTDDS_EXPORTED_API uint32_t calculate_serialized_size_ctx (const std::shared_ptr< Context > &context, const void *const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation)
 Calculates the serialized size of the provided data with context.
virtual FASTDDS_EXPORTED_API void * create_data ()=0
 Create a Data Type.
virtual FASTDDS_EXPORTED_API void * create_data_ctx (const std::shared_ptr< Context > &context)
 Create a Data Type with context.
virtual FASTDDS_EXPORTED_API void delete_data (void *data)=0
 Remove a previously created object.
virtual FASTDDS_EXPORTED_API void delete_data_ctx (const std::shared_ptr< Context > &context, void *data)
 Remove a previously created object with context.
virtual FASTDDS_EXPORTED_API bool compute_key (rtps::SerializedPayload_t &payload, rtps::InstanceHandle_t &ihandle, bool force_md5=false)=0
 Get the key associated with the data.
virtual FASTDDS_EXPORTED_API bool compute_key_ctx (const std::shared_ptr< Context > &context, rtps::SerializedPayload_t &payload, rtps::InstanceHandle_t &ihandle, bool force_md5=false)
 Get the key associated with the data with context.
virtual FASTDDS_EXPORTED_API bool compute_key (const void *const data, rtps::InstanceHandle_t &ihandle, bool force_md5=false)=0
 Get the key associated with the data.
virtual FASTDDS_EXPORTED_API bool compute_key_ctx (const std::shared_ptr< Context > &context, const void *const data, rtps::InstanceHandle_t &ihandle, bool force_md5=false)
 Get the key associated with the data with context.
FASTDDS_EXPORTED_API void set_name (const std::string &nam)
 Set topic data type name.
FASTDDS_EXPORTED_API void set_name (std::string &&nam)
 Set topic data type name.
FASTDDS_EXPORTED_API const std::string & get_name () const
 Get topic data type name.
FASTDDS_EXPORTED_API const xtypes::TypeIdentifierPairtype_identifiers () const
 Get the type identifiers.
virtual FASTDDS_EXPORTED_API bool is_bounded () const
 Checks if the type is bounded.
virtual FASTDDS_EXPORTED_API bool is_bounded_ctx (const std::shared_ptr< Context > &context) const
 Checks if the type is bounded with context.
virtual FASTDDS_EXPORTED_API bool is_plain (DataRepresentationId_t) const
 Checks if the type is plain when using a specific encoding.
virtual FASTDDS_EXPORTED_API bool is_plain_ctx (const std::shared_ptr< Context > &context, DataRepresentationId_t representation) const
 Checks if the type is plain when using a specific encoding and a context It can be reimplemented by the user to perform custom checks depending on the context received.
virtual FASTDDS_EXPORTED_API bool construct_sample (void *memory) const
 Construct a sample on a memory location.
virtual FASTDDS_EXPORTED_API bool construct_sample_ctx (const std::shared_ptr< Context > &context, void *memory) const
 Construct a sample on a memory location using a context.
virtual FASTDDS_EXPORTED_API void register_type_object_representation ()
 Register TypeObject type representation.
virtual FASTDDS_EXPORTED_API void register_type_object_representation_ctx (const std::shared_ptr< Context > &context)
 Register TypeObject type representation It can be reimplemented by the user to perform custom registration depending on the context received.
virtual FASTDDS_EXPORTED_API uint32_t get_max_serialized_size_ctx (const std::shared_ptr< Context > &context)
 Get the maximum serialized size of the type using a context It can be reimplemented by the user to perform custom calculations depending on the context received.

Public Attributes

uint32_t max_serialized_type_size {0}
 Maximum serialized size of the type in bytes.
bool is_compute_key_provided {false}
 Indicates whether the method to obtain the key has been implemented.

Protected Attributes

xtypes::TypeIdentifierPair type_identifiers_

Detailed Description

Class TopicDataType used to provide the DomainRTPSParticipant with the methods to serialize, deserialize and get the key of a specific data type.

The user should created a class that inherits from this one, where Serialize and deserialize methods MUST be implemented.

Constructor & Destructor Documentation

◆ TopicDataType()

FASTDDS_EXPORTED_API TopicDataType ( )
default

Constructor.

◆ ~TopicDataType()

virtual FASTDDS_EXPORTED_API ~TopicDataType ( )
virtualdefault

Destructor.

Member Function Documentation

◆ calculate_serialized_size()

virtual FASTDDS_EXPORTED_API uint32_t calculate_serialized_size ( const void *const data,
eprosima::fastdds::dds::DataRepresentationId_t data_representation )
pure virtual

Calculates the serialized size of the provided data.

Parameters
[in]dataPointer to data.
[in]data_representationRepresentation that should be used for calculating the serialized size.
Returns
Serialized size of the data.

Implemented in DynamicPubSubType.

◆ calculate_serialized_size_ctx()

virtual FASTDDS_EXPORTED_API uint32_t calculate_serialized_size_ctx ( const std::shared_ptr< Context > & context,
const void *const data,
eprosima::fastdds::dds::DataRepresentationId_t data_representation )
inlinevirtual

Calculates the serialized size of the provided data with context.

It can be reimplemented by the user to perform custom calculations depending on the context received. The default implementation falls back to using the callback without context.

Parameters
[in]contextContext that can be used during computation.
[in]dataPointer to data.
[in]data_representationRepresentation that should be used for calculating the serialized size.
Returns
Serialized size of the data.

◆ compute_key() [1/2]

virtual FASTDDS_EXPORTED_API bool compute_key ( const void *const data,
rtps::InstanceHandle_t & ihandle,
bool force_md5 = false )
pure virtual

Get the key associated with the data.

Parameters
[in]dataPointer to the data.
[out]ihandlePointer to the Handle.
[in]force_md5Force MD5 checking.
Returns
True if correct.

Implemented in DynamicPubSubType.

◆ compute_key() [2/2]

virtual FASTDDS_EXPORTED_API bool compute_key ( rtps::SerializedPayload_t & payload,
rtps::InstanceHandle_t & ihandle,
bool force_md5 = false )
pure virtual

Get the key associated with the data.

Parameters
[in]payloadPointer to the payload containing the data.
[out]ihandlePointer to the Handle.
[in]force_md5Force MD5 checking.
Returns
True if correct.

Implemented in DynamicPubSubType.

◆ compute_key_ctx() [1/2]

virtual FASTDDS_EXPORTED_API bool compute_key_ctx ( const std::shared_ptr< Context > & context,
const void *const data,
rtps::InstanceHandle_t & ihandle,
bool force_md5 = false )
inlinevirtual

Get the key associated with the data with context.

It can be reimplemented by the user to perform custom key computation depending on the context received. The default implementation falls back to using the callback without context.

Parameters
[in]contextContext that can be used during computation.
[in]dataPointer to the data.
[out]ihandlePointer to the Handle.
[in]force_md5Force MD5 checking.
Returns
True if correct.

◆ compute_key_ctx() [2/2]

virtual FASTDDS_EXPORTED_API bool compute_key_ctx ( const std::shared_ptr< Context > & context,
rtps::SerializedPayload_t & payload,
rtps::InstanceHandle_t & ihandle,
bool force_md5 = false )
inlinevirtual

Get the key associated with the data with context.

It can be reimplemented by the user to perform custom key computation depending on the context received. The default implementation falls back to using the callback without context.

Parameters
[in]contextContext that can be used during computation.
[in]payloadPointer to the payload containing the data.
[out]ihandlePointer to the Handle.
[in]force_md5Force MD5 checking.
Returns
True if correct.

◆ construct_sample()

virtual FASTDDS_EXPORTED_API bool construct_sample ( void * memory) const
inlinevirtual

Construct a sample on a memory location.

Parameters
memoryPointer to the memory location where the sample should be constructed.
Returns
whether this type supports in-place construction or not.

◆ construct_sample_ctx()

virtual FASTDDS_EXPORTED_API bool construct_sample_ctx ( const std::shared_ptr< Context > & context,
void * memory ) const
inlinevirtual

Construct a sample on a memory location using a context.

It can be reimplemented by the user to perform custom construction depending on the context received. The default implementation falls back to using the callback without context.

Parameters
[in]contextContext that can be used during construction.
memoryPointer to the memory location where the sample should be constructed.
Returns
whether this type supports in-place construction or not.

◆ create_data()

virtual FASTDDS_EXPORTED_API void * create_data ( )
pure virtual

Create a Data Type.

Returns
Void pointer to the created object.

Implemented in DynamicPubSubType.

◆ create_data_ctx()

virtual FASTDDS_EXPORTED_API void * create_data_ctx ( const std::shared_ptr< Context > & context)
inlinevirtual

Create a Data Type with context.

It can be reimplemented by the user to perform custom creation depending on the context received. The default implementation falls back to using the callback without context.

Parameters
contextContext that can be used during creation.
Returns
Void pointer to the created object.

◆ delete_data()

virtual FASTDDS_EXPORTED_API void delete_data ( void * data)
pure virtual

Remove a previously created object.

Parameters
dataPointer to the created Data.

Implemented in DynamicPubSubType.

◆ delete_data_ctx()

virtual FASTDDS_EXPORTED_API void delete_data_ctx ( const std::shared_ptr< Context > & context,
void * data )
inlinevirtual

Remove a previously created object with context.

It can be reimplemented by the user to perform custom deletion depending on the context received The default implementation falls back to using the callback without context.

Parameters
contextContext that can be used during deletion.
dataPointer to the created Data.

◆ deserialize()

virtual FASTDDS_EXPORTED_API bool deserialize ( rtps::SerializedPayload_t & payload,
void * data )
pure virtual

Deserialize method, it should be implemented by the user, since it is abstract.

Parameters
[in]payloadPointer to the payload
[out]dataPointer to the data
Returns
True if correct.

Implemented in DynamicPubSubType.

◆ deserialize_ctx()

virtual FASTDDS_EXPORTED_API bool deserialize_ctx ( const std::shared_ptr< Context > & context,
rtps::SerializedPayload_t & payload,
void * data )
inlinevirtual

Deserialize method with context, it can be reimplemented by the user to perform custom deserialization depending on the context received.

The default implementation falls back to using the callback without context.

Parameters
[in]contextContext that can be used during deserialization.
[in]payloadPointer to the payload
[out]dataPointer to the data
Returns
True if correct.

◆ get_max_serialized_size_ctx()

virtual FASTDDS_EXPORTED_API uint32_t get_max_serialized_size_ctx ( const std::shared_ptr< Context > & context)
inlinevirtual

Get the maximum serialized size of the type using a context It can be reimplemented by the user to perform custom calculations depending on the context received.

The default implementation just returns the maximum serialized size without using the context.

Parameters
[in]contextContext that can be used during computation.
Returns
Maximum serialized size of the type in bytes.

◆ get_name()

FASTDDS_EXPORTED_API const std::string & get_name ( ) const
inline

Get topic data type name.

Returns
Topic data type name

◆ is_bounded()

virtual FASTDDS_EXPORTED_API bool is_bounded ( ) const
inlinevirtual

Checks if the type is bounded.

◆ is_bounded_ctx()

virtual FASTDDS_EXPORTED_API bool is_bounded_ctx ( const std::shared_ptr< Context > & context) const
inlinevirtual

Checks if the type is bounded with context.

It can be reimplemented by the user to perform custom checks depending on the context received. The default implementation falls back to using the callback without context.

Parameters
[in]contextContext that can be used during check.

◆ is_plain()

virtual FASTDDS_EXPORTED_API bool is_plain ( DataRepresentationId_t ) const
inlinevirtual

Checks if the type is plain when using a specific encoding.

◆ is_plain_ctx()

virtual FASTDDS_EXPORTED_API bool is_plain_ctx ( const std::shared_ptr< Context > & context,
DataRepresentationId_t representation ) const
inlinevirtual

Checks if the type is plain when using a specific encoding and a context It can be reimplemented by the user to perform custom checks depending on the context received.

The default implementation falls back to using the callback without context.

Parameters
[in]contextContext that can be used during check.
[in]representationRepresentation of the data.

◆ register_type_object_representation()

virtual FASTDDS_EXPORTED_API void register_type_object_representation ( )
inlinevirtual

Register TypeObject type representation.

Reimplemented in DynamicPubSubType.

◆ register_type_object_representation_ctx()

virtual FASTDDS_EXPORTED_API void register_type_object_representation_ctx ( const std::shared_ptr< Context > & context)
inlinevirtual

Register TypeObject type representation It can be reimplemented by the user to perform custom registration depending on the context received.

The default implementation falls back to using the callback without context.

Parameters
[in]contextContext that can be used during registration.

◆ serialize()

virtual FASTDDS_EXPORTED_API bool serialize ( const void *const data,
rtps::SerializedPayload_t & payload,
eprosima::fastdds::dds::DataRepresentationId_t data_representation )
pure virtual

Serialize method, it should be implemented by the user, since it is abstract.

If not implemented, this method will call the serialize method in which the topic data representation is not considered. It is VERY IMPORTANT that the user sets the SerializedPayload length correctly.

Parameters
[in]dataPointer to the data
[out]payloadPointer to the payload
[in]data_representationRepresentation that should be used to encode the data into the payload.
Returns
True if correct.

Implemented in DynamicPubSubType.

◆ serialize_ctx()

virtual FASTDDS_EXPORTED_API bool serialize_ctx ( const std::shared_ptr< Context > & context,
const void *const data,
rtps::SerializedPayload_t & payload,
eprosima::fastdds::dds::DataRepresentationId_t data_representation )
inlinevirtual

Serialize method with context, it can be reimplemented by the user to perform custom serialization depending on the context received.

The default implementation falls back to using the callback without context. It is VERY IMPORTANT that the user sets the SerializedPayload length correctly.

Parameters
[in]contextContext that can be used during serialization.
[in]dataPointer to the data
[out]payloadPointer to the payload
[in]data_representationRepresentation that should be used to encode the data into the payload.
Returns
True if correct.

◆ set_name() [1/2]

FASTDDS_EXPORTED_API void set_name ( const std::string & nam)
inline

Set topic data type name.

Parameters
namTopic data type name

◆ set_name() [2/2]

FASTDDS_EXPORTED_API void set_name ( std::string && nam)
inline

Set topic data type name.

Parameters
namTopic data type name

◆ type_identifiers()

FASTDDS_EXPORTED_API const xtypes::TypeIdentifierPair & type_identifiers ( ) const
inline

Get the type identifiers.

Returns
TypeIdentifierPair

Member Data Documentation

◆ is_compute_key_provided

bool is_compute_key_provided {false}

Indicates whether the method to obtain the key has been implemented.

◆ max_serialized_type_size

uint32_t max_serialized_type_size {0}

Maximum serialized size of the type in bytes.

If the type has unbounded fields, and therefore cannot have a maximum size, use 0.

◆ type_identifiers_

xtypes::TypeIdentifierPair type_identifiers_
protected

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