RTI Connext Modern C++ API  Version 6.1.2
dds::core::xtypes::StructType Class Reference

<<value-type>> Represents and IDL struct type More...

#include <dds/core/xtypes/StructType.hpp>

Inheritance diagram for dds::core::xtypes::StructType:
dds::core::xtypes::AbstractConstructedType< Member > dds::core::xtypes::DynamicType

Public Member Functions

 StructType (const std::string &name)
 Creates an empty struct type. More...
 
 StructType (const std::string &name, const StructType &parent)
 Creates an empty struct type with a base type. More...
 
template<typename Container >
 StructType (const std::string &the_name, const Container &the_members)
 Creates a struct with the members in a container. More...
 
template<typename Container >
 StructType (const std::string &the_name, const StructType &the_parent, const Container &the_members)
 Creates a struct with a base type and the members in a container. More...
 
template<typename MemberIter >
 StructType (const std::string &the_name, MemberIter begin, MemberIter end)
 Creates a struct with the members in an iterator range. More...
 
template<typename MemberIter >
 StructType (const std::string &the_name, const StructType &the_parent, MemberIter begin, MemberIter end)
 Creates a struct with a base type and the members in an iterator range. More...
 
 StructType (const std::string &the_name, StructType &&the_parent)
 <<C++11>> Creates an empty struct type with a base type. More...
 
template<typename MemberIter >
 StructType (const std::string &the_name, StructType &&the_parent, MemberIter begin, MemberIter end)
 <<C++11>> Creates an empty struct type with a base type and the members in an iterator range. More...
 
template<typename Container >
 StructType (const std::string &the_name, StructType &&the_parent, const Container &the_members)
 <<C++11>> Creates an empty struct type with a base type and the members in a container. More...
 
 StructType (const std::string &the_name, std::initializer_list< MemberImpl > the_members)
 <<C++11>> Creates a struct with the members in an initializer_list More...
 
 StructType (const std::string &the_name, const StructType &the_parent, std::initializer_list< MemberImpl > the_members)
 <<C++11>> Creates a struct with the members in an initializer_list and a base type More...
 
 StructType (const std::string &the_name, StructType &&the_parent, std::initializer_list< MemberImpl > the_members)
 <<C++11>> Creates a struct with the members in an initializer_list and a base type More...
 
StructTypeextensibility_kind (dds::core::xtypes::ExtensibilityKind kind)
 Sets the type extensibility kind. More...
 
bool has_parent () const
 Indicates if this type has a base type. More...
 
const StructTypeparent () const
 Retrieves the base type. More...
 
MemberIndex find_member_by_id (uint32_t id) const
 Gets the index of the member with a specific member ID. More...
 
StructTypeadd_member (const MemberImpl &member)
 Adds a member at the end. More...
 
template<typename Container >
StructTypeadd_members (const Container &the_members)
 Adds all the members of a container at the end. More...
 
StructTypeadd_members (std::initializer_list< MemberImpl > the_members)
 <<C++11>> Adds all the members of an initializer_list at the end More...
 
template<typename MemberIter >
StructTypeadd_members (MemberIter begin, MemberIter end)
 Adds all the members in an iterator range at the end. More...
 
StructTypeadd_member (MemberImpl &&the_member)
 <<C++11>> Adds a member, moving it, at the end More...
 
- Public Member Functions inherited from dds::core::xtypes::AbstractConstructedType< Member >
dds::core::xtypes::ExtensibilityKind extensibility_kind () const
 Gets the extensibility kind. More...
 
size_t member_count () const
 Gets the number of members. More...
 
const Membermember (MemberIndex index) const
 Gets a member by its index. More...
 
const Membermember (const std::string &name) const
 Gets a member by its name. More...
 
MemberIndex find_member_by_name (const std::string &name) const
 Obtains the member index from its name. More...
 
std::vector< Membermembers () const
 Gets a copy of all the members. More...
 
uint32_t cdr_serialized_sample_max_size (dds::core::policy::DataRepresentationId representation_id=DDS_AUTO_DATA_REPRESENTATION) const
 Gets the maximum serialized size of samples of this type. More...
 
uint32_t cdr_serialized_sample_min_size (dds::core::policy::DataRepresentationId representation_id=DDS_AUTO_DATA_REPRESENTATION) const
 Gets the minimum serialized size of samples of this type. More...
 
uint32_t cdr_serialized_sample_key_max_size (dds::core::policy::DataRepresentationId representation_id=DDS_AUTO_DATA_REPRESENTATION) const
 Gets the maximum serialized size of sample keys of this type. More...
 
- Public Member Functions inherited from dds::core::xtypes::DynamicType
dds::core::xtypes::TypeKind kind () const
 Gets the type kind. More...
 
std::string name () const
 Gets the name. More...
 

Related Functions

(Note that these are not member functions.)

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...
 

Additional Inherited Members

- Public Types inherited from dds::core::xtypes::AbstractConstructedType< Member >
typedef Member Member
 The member type (specified by the subclasses of this class) More...
 
typedef uint32_t MemberIndex
 The member index type. More...
 
- Static Public Attributes inherited from dds::core::xtypes::AbstractConstructedType< Member >
static OMG_DDS_API_CLASS_VARIABLE const MemberIndex INVALID_INDEX
 Indicates that a member doesn't exist. More...
 

Detailed Description

<<value-type>> Represents and IDL struct type

Constructor & Destructor Documentation

◆ StructType() [1/12]

dds::core::xtypes::StructType::StructType ( const std::string &  name)

Creates an empty struct type.

The struct doesn't have a base type. Members can be added after creation.

Parameters
nameThe name of the type

◆ StructType() [2/12]

dds::core::xtypes::StructType::StructType ( const std::string &  name,
const StructType parent 
)

Creates an empty struct type with a base type.

Members can be added after creation.

Parameters
nameThe name of the type
parentThe base type

◆ StructType() [3/12]

template<typename Container >
dds::core::xtypes::StructType::StructType ( const std::string &  the_name,
const Container &  the_members 
)
inline

Creates a struct with the members in a container.

The struct doesn't have a base type.

Template Parameters
ContainerA container that provides the member functions begin() and end() to iterate over Member elements.
Parameters
the_nameThe name of the type
the_membersA container with the members for this struct type

◆ StructType() [4/12]

template<typename Container >
dds::core::xtypes::StructType::StructType ( const std::string &  the_name,
const StructType the_parent,
const Container &  the_members 
)
inline

Creates a struct with a base type and the members in a container.

Template Parameters
ContainerA container that provides the member functions begin() and end() to iterate over Member elements.
Parameters
the_nameThe name of the type
the_parentThe base type
the_membersA container with the members for this struct type

◆ StructType() [5/12]

template<typename MemberIter >
dds::core::xtypes::StructType::StructType ( const std::string &  the_name,
MemberIter  begin,
MemberIter  end 
)
inline

Creates a struct with the members in an iterator range.

The struct doesn't have a base type.

Template Parameters
MemberIterA forward iterator of Member elements
Parameters
the_nameThe name of the type
beginThe beginning of the range of Members
endThe end of the range of Members

◆ StructType() [6/12]

template<typename MemberIter >
dds::core::xtypes::StructType::StructType ( const std::string &  the_name,
const StructType the_parent,
MemberIter  begin,
MemberIter  end 
)
inline

Creates a struct with a base type and the members in an iterator range.

Template Parameters
MemberIterA forward iterator of Member elements
Parameters
the_parentThe base type
the_nameThe name of the type
beginThe beginning of the range of Members
endThe end of the range of Members

◆ StructType() [7/12]

dds::core::xtypes::StructType::StructType ( const std::string &  the_name,
StructType &&  the_parent 
)
inline

<<C++11>> Creates an empty struct type with a base type.

The base type is moved. This is useful to save a copy in situations like the following example:

StructType my_type("my_type", StructType("parent_type", parent_members));

◆ StructType() [8/12]

template<typename MemberIter >
dds::core::xtypes::StructType::StructType ( const std::string &  the_name,
StructType &&  the_parent,
MemberIter  begin,
MemberIter  end 
)
inline

<<C++11>> Creates an empty struct type with a base type and the members in an iterator range.

The base type is moved.

◆ StructType() [9/12]

template<typename Container >
dds::core::xtypes::StructType::StructType ( const std::string &  the_name,
StructType &&  the_parent,
const Container &  the_members 
)
inline

<<C++11>> Creates an empty struct type with a base type and the members in a container.

The base type is moved.

◆ StructType() [10/12]

dds::core::xtypes::StructType::StructType ( const std::string &  the_name,
std::initializer_list< MemberImpl >  the_members 
)
inline

<<C++11>> Creates a struct with the members in an initializer_list

Parameters
the_nameThe name of the type
the_membersAn ininitalizer_list of Members

◆ StructType() [11/12]

dds::core::xtypes::StructType::StructType ( const std::string &  the_name,
const StructType the_parent,
std::initializer_list< MemberImpl >  the_members 
)
inline

<<C++11>> Creates a struct with the members in an initializer_list and a base type

Parameters
the_nameThe name of the type
the_parentThe base type
the_membersAn ininitalizer_list of Members

◆ StructType() [12/12]

dds::core::xtypes::StructType::StructType ( const std::string &  the_name,
StructType &&  the_parent,
std::initializer_list< MemberImpl >  the_members 
)
inline

<<C++11>> Creates a struct with the members in an initializer_list and a base type

Parameters
the_nameThe name of the type
the_parentThe base type (moved)
the_membersAn ininitalizer_list of Members

Member Function Documentation

◆ extensibility_kind()

StructType& dds::core::xtypes::StructType::extensibility_kind ( dds::core::xtypes::ExtensibilityKind  kind)

Sets the type extensibility kind.

◆ has_parent()

bool dds::core::xtypes::StructType::has_parent ( ) const

Indicates if this type has a base type.

◆ parent()

const StructType& dds::core::xtypes::StructType::parent ( ) const

Retrieves the base type.

If this type doesn't have a base type it throws PreconditionNotMetError.

See also
has_parent()

◆ find_member_by_id()

MemberIndex dds::core::xtypes::StructType::find_member_by_id ( uint32_t  id) const

Gets the index of the member with a specific member ID.

Returns
The index (which can be passed to member(uint32_t) of the member selected by label or INVALID_INDEX if the ID doesn't exist in this type

◆ add_member() [1/2]

StructType& dds::core::xtypes::StructType::add_member ( const MemberImpl &  member)

Adds a member at the end.

Referenced by rti::core::xtypes::set_tuple().

◆ add_members() [1/3]

template<typename Container >
StructType& dds::core::xtypes::StructType::add_members ( const Container &  the_members)
inline

Adds all the members of a container at the end.

◆ add_members() [2/3]

StructType& dds::core::xtypes::StructType::add_members ( std::initializer_list< MemberImpl >  the_members)
inline

<<C++11>> Adds all the members of an initializer_list at the end

◆ add_members() [3/3]

template<typename MemberIter >
StructType& dds::core::xtypes::StructType::add_members ( MemberIter  begin,
MemberIter  end 
)
inline

Adds all the members in an iterator range at the end.

◆ add_member() [2/2]

StructType& dds::core::xtypes::StructType::add_member ( MemberImpl &&  the_member)
inline

<<C++11>> Adds a member, moving it, at the end

Friends And Related Function Documentation

◆ create_type_from_tuple()

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

<<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