RTI Connext Modern C++ API  Version 6.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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.
 
- Public Types inherited from dds::core::xtypes::AbstractConstructedType< UnionMember >
typedef UnionMember Member
 The member type (specified by the subclasses of this class)
 
typedef uint32_t MemberIndex
 The member index type.
 

Public Member Functions

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

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.
 

Detailed Description

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

Member Typedef Documentation

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

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

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

Gets the type of the discriminator.

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
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.
UnionType& dds::core::xtypes::UnionType::add_member ( const UnionMember member)

Add a member to the end of this union.

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.

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.

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.

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

Adds a member, moving it, at the end.


RTI Connext Modern C++ API Version 6.0.1 Copyright © Sat Nov 23 2019 Real-Time Innovations, Inc