CoreDX DDS Modern C++ API
Public Member Functions | List of all members
dds::core::xtypes::UnionType Class Reference

The UnionType has a discriminator and a set of cases (UnionMember[s]). More...

Inherits dds::core::xtypes::TDynamicType< DELEGATE >.

Public Member Functions

 UnionType (const std::string &name, const DynamicType &discriminator_type)
 Construct a union type with the provided name and discriminator type.
 
 UnionType (const std::string &name, const DynamicType &discriminator_type, const std::vector< UnionMember > &cases)
 Construct a union type with the provided name and discriminator type. More...
 
const dds::core::xtypes::DynamicTypediscriminator_type () const
 Access the type of the union discriminator. More...
 
std::vector< UnionMembermembers () const
 Access the members (cases) of the union. More...
 
const UnionMember member_by_label (int32_t label) const
 Access a member of the union by case label. More...
 
const UnionMember member_by_id (uint32_t id) const
 Access a member of the union by id. More...
 
const UnionMember member (const std::string &name) const
 Access a member of the union by name. More...
 
UnionTypeadd_member (const UnionMember &member)
 Add a member to the union. More...
 
UnionType extensibility_kind (dds::core::xtypes::ExtensibilityKind kind)
 Set the extensibility kind of the structure. More...
 
dds::core::xtypes::ExtensibilityKind extensibility_kind () const
 Access the extensibility kind of the structure.
 
virtual void accept (DynamicTypeVisitor &v) const
 Accept a DynamicTypeVisitor. More...
 

Detailed Description

The UnionType has a discriminator and a set of cases (UnionMember[s]).

Constructor & Destructor Documentation

◆ UnionType()

dds::core::xtypes::UnionType::UnionType ( const std::string &  name,
const DynamicType discriminator_type,
const std::vector< UnionMember > &  cases 
)

Construct a union type with the provided name and discriminator type.

Adds the provided 'cases' to the union.

Member Function Documentation

◆ accept()

virtual void dds::core::xtypes::UnionType::accept ( DynamicTypeVisitor v) const
virtual

Accept a DynamicTypeVisitor.

Useful for traversing the type hierarchy.

◆ add_member()

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

Add a member to the union.

May throw dds::core::PreconditionNotMetError() if there is a collision between this new member and an existing member. The collision can be due to a matching ID, name, or case label. Additionally, dds::core::PreconditionNotMetError() is thrown if the member is marked as key and optional.

◆ discriminator_type()

const dds::core::xtypes::DynamicType& dds::core::xtypes::UnionType::discriminator_type ( ) const

Access the type of the union discriminator.

◆ extensibility_kind()

UnionType dds::core::xtypes::UnionType::extensibility_kind ( dds::core::xtypes::ExtensibilityKind  kind)

Set the extensibility kind of the structure.

Use instead of applying an ExtensibilityAnnotation.

◆ member()

const UnionMember dds::core::xtypes::UnionType::member ( const std::string &  name) const

Access a member of the union by name.

May throw dds::core::PreconditionNotMetError() if no member is found with the specified name.

◆ member_by_id()

const UnionMember dds::core::xtypes::UnionType::member_by_id ( uint32_t  id) const

Access a member of the union by id.

May throw dds::core::PreconditionNotMetError() if no member is found with the specified id.

◆ member_by_label()

const UnionMember dds::core::xtypes::UnionType::member_by_label ( int32_t  label) const

Access a member of the union by case label.

May throw dds::core::PreconditionNotMetError() if no member is found with the specified label.

◆ members()

std::vector<UnionMember> dds::core::xtypes::UnionType::members ( ) const

Access the members (cases) of the union.


© 2009-2020 Twin Oaks Computing, Inc
Castle Rock, CO 80104
All rights reserved.