Porting C++ code between vendors

3 posts / 0 new
Last post
Offline
Last seen: 9 years 3 months ago
Joined: 12/31/2014
Posts: 1
Porting C++ code between vendors

I am trying to port some piece of code from OpenSplice to RTI and I have noticed that there are some modifications that I need to do to make it work. For example OpenSplice uses DomainParticipant_var type variable where RTI uses DomainParticipant* type variable. Is there any best practices or some other documentation that would show how to write as protable code as possible?

Keywords:
Jaime Martin - eProsima's picture
Offline
Last seen: 9 years 2 months ago
Joined: 07/02/2013
Posts: 2

We have created some portable code between RTI and OpenDDS, and we solve the differences using a header file with some defines (I paste the code below). Perhaps you could follow a similar approach. I could create a GitHub Repo to maintain those header files if you provide yours.

 

#if defined(RTI_WIN32) || defined(RTI_LINUX)

#include "ndds_namespace_cpp.h"

#define PARTICIPANT_QOS_DEFAULT DDS_PARTICIPANT_QOS_DEFAULT

#define PUBLISHER_QOS_DEFAULT DDS_PUBLISHER_QOS_DEFAULT

#define TOPIC_QOS_DEFAULT DDS_TOPIC_QOS_DEFAULT

#define SUBSCRIBER_QOS_DEFAULT DDS_SUBSCRIBER_QOS_DEFAULT

#define STATUS_MASK_NONE DDS_STATUS_MASK_NONE

#define BOOLEAN_FALSE DDS_BOOLEAN_FALSE #define BOOLEAN_TRUE DDS_BOOLEAN_TRUE

#define strdup DDS_String_dup #define EPROSIMA_UINT32 RTI_UINT32


#elif defined(OPENDDS)

#include "dds/DdsDcpsC.h"
#include "dds/DdsDcpsInfrastructureC.h"
#include "dds/DCPS/Service_Participant.h"
#include "dds/DCPS/Marked_Default_Qos.h"
#include "dds/DCPS/GuardCondition.h"
#include "dds/DCPS/DataWriterImpl.h"

#define STATUS_MASK_NONE OpenDDS::DCPS::NO_STATUS_MASK

#define BOOLEAN_FALSE false

#define BOOLEAN_TRUE true

#define DDS_InstanceHandle_is_nil(ih) (ih == 0)

#define EPROSIMA_UINT32 ::CORBA::ULong

#endif

 

jwillemsen's picture
Offline
Last seen: 2 years 11 months ago
Joined: 09/24/2013
Posts: 55

For the implementation of the CIAO DDS4CCM implementation we did use the RTI CCK together with the CCK to get the IDL to C++ language mapping defined types. This together with some wrappers and defines made it possible to at least write portable user code. For CIAO see http://download.dre.vanderbilt.edu.

For AXCIOMA we have taken the approach to use IDL to C++11 and hide all vendor details about a set of traits and typedefs, see https://www.axcioma.org for more about AXCIOMA.