RTI Connext Modern C++ API  Version 7.0.0
dds::core::xtypes::UnionType Class Reference

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

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

Inheritance diagram for dds::core::xtypes::UnionType:
dds::core::xtypes::AbstractConstructedType< UnionMember > dds::core::xtypes::DynamicType

Public Types

typedef UnionMember::DiscriminatorType DiscriminatorType
 The type used to set and get discriminator (label) values. More...
 
- Public Types inherited from dds::core::xtypes::AbstractConstructedType< UnionMember >
typedef UnionMember Member
 The member type (specified by the subclasses of this class) More...
 
typedef uint32_t MemberIndex
 The member index type. More...
 

Public Member Functions

 UnionType (const std::string &the_name, const DynamicTypeImpl &discriminator_type)
 Creates an empty union. More...
 
template<typename Container >
 UnionType (const std::string &the_name, const DynamicTypeImpl &discriminator_type, const Container &the_members)
 Creates a union with the members in a container. More...
 
template<typename MemberIter >
 UnionType (const std::string &the_name, const DynamicTypeImpl &discriminator_type, MemberIter begin, MemberIter end)
 Creates a union with the members in an iterator range. More...
 
 UnionType (const std::string &the_name, const DynamicTypeImpl &discriminator_type, std::initializer_list< UnionMember > the_members)
 Creates a union with the members in an initializer_list. More...
 
const DynamicTypeImpl & discriminator () const
 Gets the type of the discriminator. More...
 
MemberIndex find_member_by_label (DiscriminatorType label) const
 Gets the index of the member selected by a label. More...
 
MemberIndex find_member_by_id (uint32_t id) const
 Gets the index of the member with a specific member ID. More...
 
UnionTypeadd_member (const UnionMember &member)
 Add a member to the end of this union. More...
 
template<typename Container >
UnionTypeadd_members (const Container &the_members)
 Adds all the members of a container at the end. More...
 
UnionTypeadd_members (std::initializer_list< UnionMember > the_members)
 Adds all the members of an initializer_list at the end. More...
 
template<typename MemberIter >
UnionTypeadd_members (MemberIter begin, MemberIter end)
 Adds all the members in an iterator range at the end. More...
 
UnionTypeadd_member (UnionMember &&the_member)
 Adds a member, moving it, at the end. More...
 
- Public Member Functions inherited from dds::core::xtypes::AbstractConstructedType< UnionMember >
dds::core::xtypes::ExtensibilityKind extensibility_kind () const
 Gets the extensibility kind. More...
 
size_t member_count () const
 Gets the number of members. More...
 
const UnionMembermember (MemberIndex index) const
 Gets a member by its index. More...
 
const UnionMembermember (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< UnionMembermembers () 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...
 

Additional Inherited Members

- Static Public Attributes inherited from dds::core::xtypes::AbstractConstructedType< UnionMember >
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 union type

Member Typedef Documentation

◆ DiscriminatorType

typedef UnionMember::DiscriminatorType dds::core::xtypes::UnionType::DiscriminatorType

The type used to set and get discriminator (label) values.

Note that this is different from discriminator(), which represents the discriminator type as defined in IDL.

Constructor & Destructor Documentation

◆ UnionType() [1/4]

dds::core::xtypes::UnionType::UnionType ( const std::string &  the_name,
const DynamicTypeImpl &  discriminator_type 
)
inline

Creates an empty union.

Members can be added after creation.

Parameters
the_nameThe name of the type
discriminator_typeThe type of the discriminator

◆ UnionType() [2/4]

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

Creates a union with the members in a container.

Template Parameters
ContainerA container that provides the member functions begin() and end() to iterate over UnionMember elements.
Parameters
the_nameThe name of the type
discriminator_typeThe type of the discriminator, which can be a primitive type, an EnumType or an AliasType to any of these.
the_membersA container with the members for this union type

◆ UnionType() [3/4]

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

Creates a union with the members in an iterator range.

Template Parameters
MemberIterA forward iterator of UnionMember elements
Parameters
the_nameThe name of the type
discriminator_typeThe type of the discriminator
beginThe beginning of the range of UnionMembers
endThe end of the range of UnionMembers

◆ UnionType() [4/4]

dds::core::xtypes::UnionType::UnionType ( const std::string &  the_name,
const DynamicTypeImpl &  discriminator_type,
std::initializer_list< UnionMember the_members 
)
inline

Creates a union with the members in an initializer_list.

Parameters
the_nameThe name of the type
discriminator_typeThe type of the discriminator
the_membersAn ininitalizer_list of UnionMembers

Member Function Documentation

◆ discriminator()

const DynamicTypeImpl& dds::core::xtypes::UnionType::discriminator ( ) const

Gets the type of the discriminator.

◆ find_member_by_label()

MemberIndex dds::core::xtypes::UnionType::find_member_by_label ( DiscriminatorType  label) const

Gets the index of the member selected by a label.

The result of this function can be passed to member(uint32_t).

Returns
The index of the member selected by label or INVALID_INDEX if that label doesn't select any member

◆ find_member_by_id()

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

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

The result of this function can be passed to member(uint32_t).

Returns
The index of the member that has this id or INVALID_INDEX if no member uses that id.

◆ add_member() [1/2]

UnionType& dds::core::xtypes::UnionType::add_member ( const UnionMember member)

Add a member to the end of this union.

◆ add_members() [1/3]

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

Adds all the members of a container at the end.

◆ add_members() [2/3]

UnionType& dds::core::xtypes::UnionType::add_members ( std::initializer_list< UnionMember the_members)
inline

Adds all the members of an initializer_list at the end.

◆ add_members() [3/3]

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

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

◆ add_member() [2/2]

UnionType& dds::core::xtypes::UnionType::add_member ( UnionMember &&  the_member)
inline

Adds a member, moving it, at the end.