RTI Connext Modern C++ API Version 7.3.0
dds::core::xtypes::UnionMember Class Reference

<<value-type>> Represents a UnionType member More...

#include "dds/core/xtypes/MemberType.hpp"

Public Types

typedef DDS_Long DiscriminatorType
 The type to represent a union discriminator. More...
 
typedef std::vector< DiscriminatorTypeLabelSeq
 A sequence of values for the discriminator that select a member. More...
 

Public Member Functions

 UnionMember (const std::string &name, const DynamicTypeImpl &type, const LabelSeq &labels)
 Creates a union member with a name, type and selected by one or more labels. More...
 
 UnionMember (const std::string &name, const DynamicTypeImpl &type, DiscriminatorType label)
 Creates a union member with a name, type and selected by a single label. More...
 
 UnionMember (const std::string &the_name, DynamicTypeImpl &&the_type, const LabelSeq &the_labels)
 <<C++11>> Creates a union member with a name, type and selected by one or more labels. More...
 
 UnionMember (const std::string &the_name, DynamicTypeImpl &&the_type, DiscriminatorType the_label)
 <<C++11>> Creates a union member with a name, type and selected by a single label. More...
 
const dds::core::stringname () const
 Gets the member name. More...
 
dds::core::stringname ()
 Gets the member name. More...
 
const DynamicTypetype ()
 Gets the member type. More...
 
bool has_id () const
 Indicates it the member has an ID annotation. More...
 
int32_t get_id () const
 Returns the ID annotation of this member. More...
 
bool is_pointer () const
 <<extension>> Indicates if this member is a pointer More...
 
uint32_t label_count () const
 Gets the number of labels that select this member. More...
 
LabelSeq labels () const
 Gets a copy of all the labels that select this member. More...
 
UnionMemberlabels (const LabelSeq &values)
 Sets the labels that select this member. More...
 
UnionMemberlabel (DiscriminatorType value)
 Sets a single label that selects this member. More...
 
UnionMembername (const dds::core::string &value)
 Sets the name. More...
 
UnionMemberid (int32_t value)
 Sets the ID annotation of a member. More...
 
UnionMemberpointer (bool value)
 <<extension>> Makes a member a pointer More...
 

Static Public Attributes

static OMG_DDS_API_CLASS_VARIABLE DiscriminatorType DEFAULT_LABEL
 Special value for the default: union label. More...
 
static const int32_t INVALID_ID
 The special ID of a member without the ID annotation. More...
 

Detailed Description

<<value-type>> Represents a UnionType member

Encapsulates the name, type and labels of a UnionType member along with several IDL annotations such as id.

Member Typedef Documentation

◆ DiscriminatorType

typedef DDS_Long dds::core::xtypes::UnionMember::DiscriminatorType

The type to represent a union discriminator.

◆ LabelSeq

typedef std::vector<DiscriminatorType> dds::core::xtypes::UnionMember::LabelSeq

A sequence of values for the discriminator that select a member.

Constructor & Destructor Documentation

◆ UnionMember() [1/4]

dds::core::xtypes::UnionMember::UnionMember ( const std::string &  name,
const DynamicTypeImpl &  type,
const LabelSeq labels 
)

Creates a union member with a name, type and selected by one or more labels.

◆ UnionMember() [2/4]

dds::core::xtypes::UnionMember::UnionMember ( const std::string &  name,
const DynamicTypeImpl &  type,
DiscriminatorType  label 
)

Creates a union member with a name, type and selected by a single label.

◆ UnionMember() [3/4]

dds::core::xtypes::UnionMember::UnionMember ( const std::string &  the_name,
DynamicTypeImpl &&  the_type,
const LabelSeq the_labels 
)
inline

<<C++11>> Creates a union member with a name, type and selected by one or more labels.

It moves the type.

◆ UnionMember() [4/4]

dds::core::xtypes::UnionMember::UnionMember ( const std::string &  the_name,
DynamicTypeImpl &&  the_type,
DiscriminatorType  the_label 
)
inline

<<C++11>> Creates a union member with a name, type and selected by a single label.

It moves the type.

Member Function Documentation

◆ name() [1/3]

const dds::core::string & dds::core::xtypes::UnionMember::name ( ) const

Gets the member name.

◆ name() [2/3]

dds::core::string & dds::core::xtypes::UnionMember::name ( )

Gets the member name.

◆ type()

const DynamicType & dds::core::xtypes::UnionMember::type ( )

Gets the member type.

◆ has_id()

bool dds::core::xtypes::UnionMember::has_id ( ) const

Indicates it the member has an ID annotation.

Returns
True if this member has been annotated explicitly with an ID; false if the has a default-assigned ID.

◆ get_id()

int32_t dds::core::xtypes::UnionMember::get_id ( ) const

Returns the ID annotation of this member.

Returns
If has_id() is true, this returns the value of the ID annotation. Otherwise it returns INVALID_ID.

◆ is_pointer()

bool dds::core::xtypes::UnionMember::is_pointer ( ) const

<<extension>> Indicates if this member is a pointer

◆ label_count()

uint32_t dds::core::xtypes::UnionMember::label_count ( ) const

Gets the number of labels that select this member.

◆ labels() [1/2]

LabelSeq dds::core::xtypes::UnionMember::labels ( ) const

Gets a copy of all the labels that select this member.

◆ labels() [2/2]

UnionMember & dds::core::xtypes::UnionMember::labels ( const LabelSeq values)

Sets the labels that select this member.

◆ label()

UnionMember & dds::core::xtypes::UnionMember::label ( DiscriminatorType  value)

Sets a single label that selects this member.

If more than one label selects this case, use labels(const LabelSeq&)

◆ name() [3/3]

UnionMember & dds::core::xtypes::UnionMember::name ( const dds::core::string value)

Sets the name.

◆ id()

UnionMember & dds::core::xtypes::UnionMember::id ( int32_t  value)

Sets the ID annotation of a member.

[default] Automatically assigned as the ID of the previous member plus one previous member

◆ pointer()

UnionMember & dds::core::xtypes::UnionMember::pointer ( bool  value)

<<extension>> Makes a member a pointer

[default] false

Member Data Documentation

◆ DEFAULT_LABEL

OMG_DDS_API_CLASS_VARIABLE DiscriminatorType dds::core::xtypes::UnionMember::DEFAULT_LABEL
static

Special value for the default: union label.

◆ INVALID_ID

const int32_t dds::core::xtypes::UnionMember::INVALID_ID
static

The special ID of a member without the ID annotation.