union types with boolean discriminator

3 posts / 0 new
Last post
Offline
Last seen: 1 year 9 months ago
Joined: 06/15/2022
Posts: 5
union types with boolean discriminator

We're using union types with a Boolean discriminator. When the discriminator is true, the 'value' field contains valid data. When false, there is no valid data.

The problem is that the rtiddsprototyper defaults the discriminator to 'true', which means the value field should have valid data. We have the same problem with code generated from the rtiddsgen tool: the default discriminator value is 'true'. The documentation I've seen explains that the discriminator changes when setting the appropriate member of the union. But with these Boolean discriminators, there is no union member that corresponds to 'false'. Is there any way to use the rtiddsprototyper (with or without lua) to set the discriminator of these union types to 'false'?

<union name="request_ack_rejection_type">
  <discriminator type="boolean"/>
  <case>
    <caseDiscriminator value="true"/>
    <member name="value" type="nonBasic" nonBasicTypeName= "org::omg::c4i::Domain_Model::Common_Types::Requests::denial_type"/>
  </case>
</union>
Organization:
Howard's picture
Offline
Last seen: 20 hours 39 min ago
Joined: 11/29/2012
Posts: 565
Hmm, you may be running into the issue in which currently all discriminator values need ot have an associated member.

But I think that a better solution for your use case is to use the "@optional" annotation...which basically turns the member into a pointer.  And if you set the value of the member value on sending, the DataReader receives the value (via a pointer member).

If you don't set the member (or set the pointer to NULL), then the DataReader will receive a NULL pointer for the member, which you can check for...the type definition would look something like this:

     <module name="com">
      <module name="rtx">
        <module name="Example_Types">
          <struct name="example_type">
            <member name="request_ack_rejection" type="nonBasic" nonBasicTypeName="org::omg::c4i::Domain_Model::Common_Types::Requests::denial_type" optional="true"/>
          </struct>
        </module>
      </module>
    </module>

 

 

Offline
Last seen: 1 year 9 months ago
Joined: 06/15/2022
Posts: 5

Thank you again, Howard. I can try to update the XML.

All of these issues are from the OMG's OARIS specification. I can submit these issues to the OMG about the specification, but I am hesitant to edit the IDL from a standard.