I use cyclonedds-cxx and their IDL compiler to translate IDL files for the use with cyclonedds-cxx. I have this IDL file:
#ifndef TRANSPORTDATA_IDL
#define TRANSPORTDATA_IDL
#include "Transform_.idl"
module TransportData
{
struct Data
{
long userID; //@key
geometry_msgs::msg::dds_::Transform_ transform_;
};
#pragma keylist Data userID
};
#endif // TRANSPORTDATA_IDL
This IDL file is, among others, converted to Transportdata_DCPS.hpp, which looks like this:
#ifndef ISOCPP2_TRANSPORTDATA_H
#define ISOCPP2_TRANSPORTDATA_H
#include "dds/dds.hpp"
#include "TransportData.h"
#include "TransportDataSplDcps.h"
#include "org/eclipse/cyclonedds/topic/TopicTraits.hpp"
#include "org/eclipse/cyclonedds/topic/DataRepresentation.hpp"
namespace org { namespace eclipse { namespace cyclonedds { namespace topic {
template <>
class TopicTraits<TransportData::Data>
{
public:
static ::org::eclipse::cyclonedds::topic::DataRepresentationId_t getDataRepresentationId()
{
return ::org::eclipse::cyclonedds::topic::OSPL_REPRESENTATION;
}
static ::std::vector<uint8_t> getMetaData()
{
return ::std::vector<uint8_t>();
}
static ::std::vector<uint8_t> getTypeHash()
{
return ::std::vector<uint8_t>();
}
static ::std::vector<uint8_t> getExtentions()
{
return ::std::vector<uint8_t>();
}
static const char *getKeyList()
{
return "userID";
}
static const char *getTypeName()
{
return "TransportData::Data";
}
static const dds_topic_descriptor_t *getDescriptor()
{
return &TransportData_Data_desc;
}
static copyInFunction getCopyIn()
{
return (copyInFunction) __TransportData_Data__copyIn;
}
static copyOutFunction getCopyOut()
{
return (copyOutFunction) __TransportData_Data__copyOut;
}
static size_t getSampleSize()
{
return sizeof(TransportData_Data);
}
};
}}}}
namespace dds { namespace topic {
template <>
struct topic_type_name<TransportData::Data>
{
static std::string value()
{
return org::eclipse::cyclonedds::topic::TopicTraits<TransportData::Data>::getTypeName();
}
};
}}
REGISTER_TOPIC_TYPE(TransportData::Data)
#endif /* ISOCPP_TRANSPORTDATA_H */
I have three questions about this:
copyInFunction
and the copyOutFunction
for?This is all implementation-specific and with the new IDL compiler for Cyclone, the output will change completely, even eliminating most of the generated files.
The copyInFunction
and copyOutFunction
here refer to functions that copy samples from the C++ representation to an internal representation and back. For the initial commit of the C++ API, this internal representation is actually the sample in C representation, after which it gets converted to/from CDR. The new version does away with these functions and avoids this copy.