RTI Connext Modern C++ API  Version 6.1.0
rti::core::xtypes Namespace Reference

<<extension>> Extensions to dds::core::xtypes More...

Classes

class  DynamicDataInfo
 Contains information about a DynamicData sample. More...
 
class  DynamicDataMemberInfo
 Contains information about a DynamicData member. More...
 
class  DynamicDataTypeSerializationProperty
 <<extension>> <<value-type>> Configures aspects of the memory management in the serialization of dds::core::xtypes::DynamicData samples. More...
 
class  DynamicTypePrintFormatProperty
 <<extension>> <<value-type>> A collection of attributes used to configure how DynamicTypes will be formatted when converted to strings. More...
 
class  LoanedDynamicData
 <<move-only-type>> Gives temporary access to a member of another DynamicData object. More...
 

Functions

template<typename TopicType >
DynamicDataImpl convert (const TopicType &sample)
 <<extension>> Creates a DynamicData sample from a typed sample More...
 
const dds::core::xtypes::DynamicTyperesolve_alias (const dds::core::xtypes::DynamicType &type)
 <<extension>> If the type is an alias returns its related type recursively until it is not an alias. More...
 
std::vector< char > & to_cdr_buffer (std::vector< char > &buffer, const DynamicData &sample, dds::core::policy::DataRepresentationId representation_id=dds::core::policy::DataRepresentation::auto_id())
 <<extension>> Serializes a DynamicData sample into CDR format More...
 
DynamicData & from_cdr_buffer (DynamicData &sample, const std::vector< char > &buffer)
 <<extension>> Creates a DynamicData sample by deserializing a CDR buffer' More...
 
template<typename TopicType >
TopicType convert (const DynamicData &sample)
 <<extension>> Creates a typed sample from a DynamicData sample. More...
 
template<typename TopicType >
DynamicData convert (const TopicType &sample)
 <<extension>> Creates a DynamicData sample from a typed sample More...
 
template<typename TopicType >
bool can_convert (const DynamicData &sample)
 <<extension>> Determines if the DynamicType of this sample is equal to the DynamicType of TopicType More...
 
template<typename... Types>
std::tuple< Types... > get_tuple (const dds::core::xtypes::DynamicData &data)
 <<C++11>> <<experimental>> <<extension>> Retrieves all the values of a DynamicData object into an std::tuple at once More...
 
template<typename... Types>
void set_tuple (dds::core::xtypes::DynamicData &data, const std::tuple< Types... > &value)
 <<C++11>> <<experimental>> <<extension>> Assigns the values of a std::tuple to a DynamicData object at once More...
 
template<typename... Types>
dds::core::xtypes::StructType create_type_from_tuple (const std::string &name)
 <<C++11>> <<experimental>> <<extension>> Creates a StructType from a list of types or a std::tuple More...
 
void print_idl (const DynamicType &type, unsigned int indent=0)
 <<extension>> Prints the IDL representation of this DynamicType to the standard output More...
 
std::ostream & to_string (std::ostream &out, const DynamicType &type, const rti::core::xtypes::DynamicTypePrintFormatProperty &format=DynamicTypePrintFormatProperty())
 <<extension>> Writes the string representation of this DynamicType to an output stream. More...
 
std::string to_string (const DynamicType &type, const rti::core::xtypes::DynamicTypePrintFormatProperty &format=DynamicTypePrintFormatProperty())
 <<extension>> Creates the string representation of this DynamicType to a string. More...
 

Detailed Description

Function Documentation

◆ convert() [1/3]

template<typename TopicType >
DynamicDataImpl rti::core::xtypes::convert ( const TopicType &  sample)

<<extension>> Creates a DynamicData sample from a typed sample

Template Parameters
TopicTypeAn IDL topic-type
Parameters
sampleThe typed sample to convert to DynamicData
Returns
A new DynamicData object whose type is rti::topic::dynamic_type<TopicType> and contains the data from sample

◆ resolve_alias()

const dds::core::xtypes::DynamicType & rti::core::xtypes::resolve_alias ( const dds::core::xtypes::DynamicType type)

<<extension>> If the type is an alias returns its related type recursively until it is not an alias.

◆ to_cdr_buffer()

std::vector< char > & rti::core::xtypes::to_cdr_buffer ( std::vector< char > &  buffer,
const DynamicData &  sample,
dds::core::policy::DataRepresentationId  representation_id = dds::core::policy::DataRepresentation::auto_id() 
)

<<extension>> Serializes a DynamicData sample into CDR format

Parameters
bufferThe output buffer, which will be resized to the correct size
sampleThe sample to serialize
representation_idThe data representation used to serialize the data
Returns
A reference to buffer

◆ from_cdr_buffer()

DynamicData & rti::core::xtypes::from_cdr_buffer ( DynamicData &  sample,
const std::vector< char > &  buffer 
)

<<extension>> Creates a DynamicData sample by deserializing a CDR buffer'

Parameters
sampleThe sample to deserialize.
bufferThe buffer containing the CDR data
Returns
A reference to sample

◆ convert() [2/3]

template<typename TopicType >
TopicType rti::core::xtypes::convert ( const DynamicData &  sample)

<<extension>> Creates a typed sample from a DynamicData sample.

This function is useful when an application uses DynamicData and regular typed Topics at the same time.

For example, given this IDL type:

struct Foo {
long x;
};

We can convert from Foo and DynamicData:

// Receive a DynamicData sample
assert (samples.size() > 0);
// Create a Foo sample
const DynamicData& dynamic_data = samples[0].data();
assert (can_convert<Foo>(dynamic_data));
Foo typed_data = convert<Foo>(dynamic_data);
assert (typed_data.x() == dynamic_data.value<int32_t>("x"));
Precondition
can_convert<TopicType>(sample), otherwise the behavior is undefined.
Template Parameters
TopicTypeAn IDL topic-type
Parameters
sampleThe DynamicData sample to convert to type TopicType
Returns
An instance of TopicType containing the data in sample.

◆ convert() [3/3]

template<typename TopicType >
DynamicData rti::core::xtypes::convert ( const TopicType &  sample)

<<extension>> Creates a DynamicData sample from a typed sample

Template Parameters
TopicTypeAn IDL topic-type
Parameters
sampleThe typed sample to convert to DynamicData
Returns
A new DynamicData object whose type is rti::topic::dynamic_type<TopicType> and contains the data from sample

◆ can_convert()

template<typename TopicType >
bool rti::core::xtypes::can_convert ( const DynamicData &  sample)

<<extension>> Determines if the DynamicType of this sample is equal to the DynamicType of TopicType

Template Parameters
TopicTypeAn IDL topic-type
Returns
True if the DynamicType of TopicType is the same as this sample's and therefore it is possible to create an instance of TopicType from this DynamicData object.
See also
convert()

◆ get_tuple()

template<typename... Types>
std::tuple< Types... > rti::core::xtypes::get_tuple ( const dds::core::xtypes::DynamicData data)

<<C++11>> <<experimental>> <<extension>> Retrieves all the values of a DynamicData object into an std::tuple at once

See also
Manipulating data reflectively using C++ tuples

◆ set_tuple()

template<typename... Types>
void rti::core::xtypes::set_tuple ( dds::core::xtypes::DynamicData data,
const std::tuple< Types... > &  value 
)

<<C++11>> <<experimental>> <<extension>> Assigns the values of a std::tuple to a DynamicData object at once

See also
Manipulating data reflectively using C++ tuples

References dds::core::xtypes::StructType::add_member().

◆ create_type_from_tuple()

template<typename... Types>
dds::core::xtypes::StructType rti::core::xtypes::create_type_from_tuple ( const std::string &  name)

<<C++11>> <<experimental>> <<extension>> Creates a StructType from a list of types or a std::tuple

Template Parameters
TypesA list of types or a std::tuple. The types must be primitive (see dds::core::xtypes::PrimitiveType) or std::string.

The StructType members are all default-created (i.e. non-key, non-optional, with default IDs...) and their names are m0, m1, m2, etc.

See also
Create a DynamicType using tuples

◆ print_idl()

void rti::core::xtypes::print_idl ( const DynamicType &  type,
unsigned int  indent = 0 
)

<<extension>> Prints the IDL representation of this DynamicType to the standard output

◆ to_string() [1/2]

std::ostream & rti::core::xtypes::to_string ( std::ostream &  out,
const DynamicType &  type,
const rti::core::xtypes::DynamicTypePrintFormatProperty format = DynamicTypePrintFormatProperty() 
)

<<extension>> Writes the string representation of this DynamicType to an output stream.

Parameters
outThe output stream to which the string representation of the DynamicType should be printed.
typeThe DynamicType to be printed.
formatThe DynamicTypePrintFormatProperty used to define the format of the string.
Returns
A reference to out.

◆ to_string() [2/2]

std::string rti::core::xtypes::to_string ( const DynamicType &  type,
const rti::core::xtypes::DynamicTypePrintFormatProperty format = DynamicTypePrintFormatProperty() 
)

<<extension>> Creates the string representation of this DynamicType to a string.

Parameters
typeThe DynamicType to be printed.
formatThe DynamicTypePrintFormatProperty used to define the format of the string.
Returns
The string representation of the DynamicType.