CoreDX DDS Modern C++ API
|
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::DynamicType & | discriminator_type () const |
Access the type of the union discriminator. More... | |
std::vector< UnionMember > | members () 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... | |
UnionType & | add_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... | |
The UnionType has a discriminator and a set of cases (UnionMember[s]).
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.
|
virtual |
Accept a DynamicTypeVisitor.
Useful for traversing the type hierarchy.
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.
const dds::core::xtypes::DynamicType& dds::core::xtypes::UnionType::discriminator_type | ( | ) | const |
Access the type of the union discriminator.
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.
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.
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.
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.
std::vector<UnionMember> dds::core::xtypes::UnionType::members | ( | ) | const |
Access the members (cases) of the union.