Working with IDL types - Union

2 posts / 0 new
Last post
Offline
Last seen: 6 months 3 weeks ago
Joined: 09/12/2014
Posts: 6
Working with IDL types - Union

Possible to give an example of how to use Union in Modern C++. I don't see any nice example of how to initialize a union, its discriminator and its member.

 

 

Gerardo Pardo's picture
Offline
Last seen: 3 weeks 3 days ago
Joined: 06/02/2010
Posts: 588

See the attached ZIP file. 

The UnionType_publisher.cxx shows  how to set the union in modern C++. You basically use the setter of the union branch you want. The discriminator is set automatically.

The UnionType_subscriber.cxx shows  how to access the union discriminator modern C++. There is an operation called "_d()" that returns it. Then you use the proper getter for the branch that corresponds to that value of the discriminator.

 

 

 

File Attachments: