C++11 API and IDL generation

8 posts / 0 new
Last post
Offline
Last seen: 8 years 11 months ago
Joined: 04/22/2015
Posts: 3
C++11 API and IDL generation

Hi!

Does RTI Connext support the DDS-PSM-Cxx (www.omg.org/spec/DDS-PSM-Cxx/, isocpp) API and generating the OMG IDL to C++11 mapping? (www.omg.org/spec/CPP11)

I checked the rtiddsgen tool but it seems that there's no option to generate C++11 files from IDL.
Is PrismTech's OpenSplice the only DDS implementation which fully supports this feature?

Is it planned from RTI to support that too?

What I'm currently trying to do is to compile the modern C++ examples from here:  https://github.com/PrismTech/dds-tutorial-cpp-ex/tree/master/ch1
These work out of the box with OpenSplice.

Thanks for your help!
Stefan

Offline
Last seen: 2 months 2 weeks ago
Joined: 04/02/2013
Posts: 194

Hi Stefan,

You can use the option -language C++11 in rtiddsgen. That will enable the use of certain C++11 features in the API and the generated types and will generate a publisher and subscriber example using C++11 code. This is not the OMG IDL-to-C++11 mapping; it's the mapping mandated by the OMG DDS-PSM (you may find this blog post interesting: The Attack of the DDS C++ APIs)

Note that only a few platforms support C++11, what compiler are you using?

You can also see the C++11 example publisher and subscriber code in the API reference documentation (see [RTI Connext installation directory]/doc/html/api_cpp2/Foo_subscriber_8cxx-example.html).

Regards,

Alex

Offline
Last seen: 8 years 11 months ago
Joined: 04/22/2015
Posts: 3

alejandro, thanks for your answer.

I managed now to compile the same code for Connext (using the Early Access DDS-PSM-Cxx Version available through the support) and OpenSplice (current community edition).

Interoperability between those two implementations also works (at least for this simple test).

You can find the source code here: https://github.com/Pro/dds-temperature

Happy coding!

Stefan

Offline
Last seen: 2 months 2 weeks ago
Joined: 04/02/2013
Posts: 194

That's good to hear! Thank you for sharing the results of your test.

sumant's picture
Offline
Last seen: 6 years 9 months ago
Joined: 02/02/2011
Posts: 7

@Stefan: Good to know that portaility is working out for you. I noted that the names of the generated header files are not the same. I.e, TempControl.h vs TempControl_DCPS.h. We'll discuss this issue at the OMG. 

I'm curious about the type of "samples" in tssub.cpp. I expect dds::sub::LoanedSamples<tutorial::TempSensorType> to work as well as auto. LoanedSamples is meant to move samples out automatically and thereby avoid making copies. I hope, both vendors behave similarly.

Offline
Last seen: 2 months 2 weeks ago
Joined: 04/02/2013
Posts: 194

In fact, using dds::sub::Sample will make a copy. We provide also rti::sub::LoanedSample which won't make a copy of the data. (Note, in the Early Access Release that class was named rti::sub::SampleRef)

I would suggest replacing the call to std::for_each with this loop, which (at least in the RTI implementation) won't make any copies:

 for (auto s : samples) {
     std::cout << s.data() << std::endl;
 } 

 

    

 

Offline
Last seen: 2 months 2 weeks ago
Joined: 04/02/2013
Posts: 194

I would also point out that you could make the code fully standard by replacing the part that disables shared memory (an RTI extension) with a dds::core::QosProvider that loads that QoS setting from an XML file ( QosProvideris a standard class). In any case in the next RTI release disabling shared memory shouldn't be necessary.

Offline
Last seen: 8 years 11 months ago
Joined: 04/22/2015
Posts: 3

@sumant: Yes, unfortunately there are different file names generated by the implementations.
For connext those are:

  • TempControl.cxx
  • TempControl.hpp
  • TempControlImpl.cxx
  • TempControlImpl.h
  • TempControlImplPlugin.cxx
  • TempControlImplPlugin.h
  • TempControlImplSupport.cxx
  • TempControlImplSupport.h

(Note the inconsistent file extension for header files .h vs. .hpp)

For OpenSplice:

  • TempControl.cpp
  • TempControlDcps.cpp
  • TempControlDcps.h
  • TempControl_DCPS.hpp
  • TempControlDcps_impl.cpp
  • TempControlDcps_impl.h
  • TempControl.h
  • TempControlSplDcps.cpp
  • TempControlSplDcps.h

It would also be helpful if the auxiliary files (like Impl... for Connext or Dcps... for OpenSplice) are named the same. This would simplify the makefile. Currently I have to distinguish between both implementations and compile the correct files accordingly:

github.com/Pro/dds-temperature/blob/master/connext/CMakeLists.txt#L31 and github.com/Pro/dds-temperature/blob/master/connext/cmake/MacroConnext.cmake#L18

 

@alejandro:

 I changed the code to use your suggested for loop and added a comment for describing the .xml file.