Skip to content

Commit

Permalink
Merge pull request OpenDDS#4519 from mitza-oci/submessage-idl
Browse files Browse the repository at this point in the history
Support the IDL4 `@value` annotation in IDL-to-C++11 and use it for RTPS SubmessageKind
  • Loading branch information
iguessthislldo authored Mar 22, 2024
2 parents 14fc41b + 648ca82 commit 08a2763
Show file tree
Hide file tree
Showing 41 changed files with 603 additions and 265 deletions.
6 changes: 5 additions & 1 deletion MPC/config/dds_versioning_idl_defaults.mpb
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
// This base project is only meant to be used by the core OpenDDS
// libraries

project : taoidldefaults {
project: taoidldefaults, dcps_ts_defaults {
idlflags += -Wb,versioning_begin=OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL \
-Wb,versioning_end=OPENDDS_END_VERSIONED_NAMESPACE_DECL \
-Wb,versioning_include=dds/Versioned_Namespace.h

dcps_ts_flags += -Wb,versioning_begin=OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL \
-Wb,versioning_end=OPENDDS_END_VERSIONED_NAMESPACE_DECL \
-Wb,versioning_name=OPENDDS_VERSIONED_NAMESPACE_NAME
}
11 changes: 7 additions & 4 deletions dds/DCPS/RTPS/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
/RtpsCoreC.h
/RtpsCoreC.inl
/RtpsCoreS.h
/RtpsSecurityC.cpp
/RtpsSecurityC.h
/RtpsSecurityC.inl
/RtpsSecurityS.h
/RtpsCoreTypeSupport.idl
/RtpsCoreTypeSupportC.cpp
/RtpsCoreTypeSupportC.h
Expand Down Expand Up @@ -49,6 +45,13 @@
/RtpsRpcS.h
/RtpsRpcTypeSupportImpl.cpp
/RtpsRpcTypeSupportImpl.h
/RtpsSecurityC.cpp
/RtpsSecurityC.h
/RtpsSecurityC.inl
/RtpsSecurityS.h
/RtpsSubmessageKindC.h
/RtpsSubmessageKindTypeSupportImpl.cpp
/RtpsSubmessageKindTypeSupportImpl.h
/TypeLookupC.cpp
/TypeLookupC.h
/TypeLookupC.inl
Expand Down
25 changes: 16 additions & 9 deletions dds/DCPS/RTPS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,33 @@ target_sources(OpenDDS_Rtps
_opendds_library(OpenDDS_Rtps)
target_link_libraries(OpenDDS_Rtps PUBLIC OpenDDS::Dcps)

set(ots_args
set(common_idl_options
INCLUDE_BASE "${OPENDDS_SOURCE_DIR}"
USE_EXPORT "dds/DCPS/RTPS/rtps_export.h" OpenDDS_Rtps_Export
)
set(tao_idl_options -St -Scdr)
set(opendds_idl_options -St -SI -Sv -Sx)
opendds_target_sources(OpenDDS_Rtps
PUBLIC
RtpsCore.idl
RtpsSecurity.idl
RtpsRpc.idl
TypeLookup.idl
${ots_args}
SKIP_OPENDDS_IDL
TAO_IDL_OPTIONS -St -Scdr
TAO_IDL_OPTIONS ${tao_idl_options}
OPENDDS_IDL_OPTIONS ${opendds_idl_options}
${common_idl_options}
)
opendds_target_sources(OpenDDS_Rtps
PUBLIC
RtpsCore.idl
RtpsRpc.idl
TypeLookup.idl
${ots_args}
RtpsSubmessageKind.idl
OPENDDS_IDL_OPTIONS ${opendds_idl_options} -Lspcpp
SKIP_TAO_IDL
${common_idl_options}
)
opendds_target_sources(OpenDDS_Rtps
PUBLIC
RtpsSecurity.idl
TAO_IDL_OPTIONS ${tao_idl_options}
SKIP_OPENDDS_IDL
${common_idl_options}
)
opendds_install_interface_files(OpenDDS_Rtps INCLUDE_BASE "${OPENDDS_SOURCE_DIR}")
63 changes: 4 additions & 59 deletions dds/DCPS/RTPS/RtpsCore.idl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "dds/DdsSecurityParams.idl"
#endif

#include "RtpsSubmessageKind.idl"

module OpenDDS {
module RTPS {

Expand Down Expand Up @@ -538,9 +540,9 @@ module OpenDDS {
unsigned short submessageLength; /* octetsToNextHeader */
};
// Valid constants for the submessageId field are the enumerators
// of the SubmessageKind enum in MessageTypes.h.
// of the SubmessageKind enum in RtpsSubmessageKind.idl.
// The least-significant bit of "flags" is E, the endianness flag:
// pseudoenum E { BIG_ENDIAN = 0, LITTLE_ENDIAN = 1};
// pseudoenum E { BIG_ENDIAN = 0, LITTLE_ENDIAN = 1 };

/* Type used to hold fragment numbers. */
struct FragmentNumber_t {
Expand Down Expand Up @@ -773,63 +775,6 @@ module OpenDDS {
DDS::OctetSeq content;
};

enum SubmessageKind {
SUBMESSAGE_NONE,
PAD, /* = 0x01, Pad */
RESERVED_2,
RESERVED_3,
RESERVED_4,
RESERVED_5,
ACKNACK, /* = 0x06, AckNack */
HEARTBEAT, /* = 0x07, Heartbeat */
GAP, /* = 0x08, Gap */
INFO_TS, /* = 0x09, InfoTimestamp */
RESERVED_10,
RESERVED_11,
INFO_SRC, /* = 0x0c, InfoSource */
INFO_REPLY_IP4, /* = 0x0d, InfoReplyIp4 */
INFO_DST, /* = 0x0e, InfoDestination */
INFO_REPLY, /* = 0x0f, InfoReply */
RESERVED_16,
RESERVED_17,
NACK_FRAG, /* = 0x12, NackFrag */
HEARTBEAT_FRAG, /* = 0x13, HeartbeatFrag */
RESERVED_20,
DATA, /* = 0x15, Data */
DATA_FRAG, /* = 0x16, DataFrag */
RESERVED_23,
RESERVED_24,
RESERVED_25,
RESERVED_26,
RESERVED_27,
RESERVED_28,
RESERVED_29,
RESERVED_30,
RESERVED_31,
RESERVED_32,
RESERVED_33,
RESERVED_34,
RESERVED_35,
RESERVED_36,
RESERVED_37,
RESERVED_38,
RESERVED_39,
RESERVED_40,
RESERVED_41,
RESERVED_42,
RESERVED_43,
RESERVED_44,
RESERVED_45,
RESERVED_46,
RESERVED_47,
SEC_BODY, // SubmessageKinds 0x30-3f reserved for security
SEC_PREFIX,
SEC_POSTFIX,
SRTPS_PREFIX,
SRTPS_POSTFIX,
RESERVED_53_SECURITY
};

@OpenDDS::internal::special_serialization
union Submessage switch (SubmessageKind) {
case PAD:
Expand Down
40 changes: 40 additions & 0 deletions dds/DCPS/RTPS/RtpsSubmessageKind.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Distributed under the OpenDDS License.
* See: http://www.opendds.org/license.html
*/

#ifndef OPENDDS_DCPS_RTPS_RTPSSUBMESSAGEKIND_IDL
#define OPENDDS_DCPS_RTPS_RTPSSUBMESSAGEKIND_IDL

module OpenDDS {
module RTPS {

enum SubmessageKind {
@value(0x00) RTPS_HE, /* HeaderExtension */
@value(0x01) PAD, /* Pad */
@value(0x06) ACKNACK, /* AckNack */
@value(0x07) HEARTBEAT, /* Heartbeat */
@value(0x08) GAP, /* Gap */
@value(0x09) INFO_TS, /* InfoTimestamp */
@value(0x0c) INFO_SRC, /* InfoSource */
@value(0x0d) INFO_REPLY_IP4, /* InfoReplyIp4 */
@value(0x0e) INFO_DST, /* InfoDestination */
@value(0x0f) INFO_REPLY, /* InfoReply */
@value(0x12) NACK_FRAG, /* NackFrag */
@value(0x13) HEARTBEAT_FRAG, /* HeartbeatFrag */
@value(0x15) DATA, /* Data */
@value(0x16) DATA_FRAG, /* DataFrag */

// SubmessageKinds 0x30-3f are reserved for DDS Security
@value(0x30) SEC_BODY,
@value(0x31) SEC_PREFIX,
@value(0x32) SEC_POSTFIX,
@value(0x33) SRTPS_PREFIX,
@value(0x34) SRTPS_POSTFIX

// SubmessageKinds 0x80 and above are vendor-specific
};

};
};
#endif
7 changes: 6 additions & 1 deletion dds/DCPS/RTPS/rtps.mpc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project(OpenDDS_Rtps): dcpslib, install, rtps_optional_safety, opendds_testing_features {
project(OpenDDS_Rtps): dcpslib, install, rtps_optional_safety, opendds_testing_features, dds_versioning_idl_defaults {
sharedname = OpenDDS_Rtps
dynamicflags = OPENDDS_RTPS_BUILD_DLL

Expand All @@ -12,6 +12,11 @@ project(OpenDDS_Rtps): dcpslib, install, rtps_optional_safety, opendds_testing_f
ICE
}

TypeSupport_Files {
dcps_ts_flags += -Lspcpp
RtpsSubmessageKind.idl
}

specific {
install_dir = dds/DCPS/RTPS
}
Expand Down
8 changes: 4 additions & 4 deletions dds/DCPS/RTPS/rtps_optional_safety.mpb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
feature(no_opendds_safety_profile) : dcps_ts_defaults, dds_versioning_idl_defaults {
feature(no_opendds_safety_profile): dds_versioning_idl_defaults {
idlflags += -Wb,export_macro=OpenDDS_Rtps_Export -Wb,export_include=rtps_export.h -SS
dcps_ts_flags += -Wb,export_macro=OpenDDS_Rtps_Export -Wb,export_include=rtps_export.h -SI
dcps_ts_flags += -Wb,export_macro=OpenDDS_Rtps_Export -Wb,export_include=rtps_export.h -SI -Sx -Sv -St

IDL_Files {
commandflags += -St -Scdr
Expand All @@ -17,8 +17,8 @@ feature(no_opendds_safety_profile) : dcps_ts_defaults, dds_versioning_idl_defaul
}
}

feature(!no_opendds_safety_profile) : dcps_ts_defaults, dds_versioning_idl_defaults {
dcps_ts_flags += -Wb,export_macro=OpenDDS_Rtps_Export -Wb,export_include=rtps_export.h -SI -Sx -Lspcpp
feature(!no_opendds_safety_profile): dds_versioning_idl_defaults {
dcps_ts_flags += -Wb,export_macro=OpenDDS_Rtps_Export -Wb,export_include=rtps_export.h -SI -Sx -Sv -Lspcpp

IDL_Files {
}
Expand Down
34 changes: 34 additions & 0 deletions dds/DCPS/ValueCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,45 @@
#include "ValueCommon.h"
#include "debug.h"

#include <cstring>

OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL

namespace OpenDDS {
namespace DCPS {

ACE_CDR::Long EnumHelper::get_value(const char* name) const
{
ACE_CDR::Long value;
return get_value(value, name) ? value : 0;
}

const char* EnumHelper::get_name(ACE_CDR::Long value) const
{
const char* name;
return get_name(name, value) ? name : 0;
}

bool ListEnumHelper::valid(const char* name) const
{
for (OPENDDS_VECTOR(Pair)::const_iterator it = pairs_.begin(); it != pairs_.end(); ++it) {
if (std::strcmp(it->name, name) == 0) {
return true;
}
}
return false;
}

bool ListEnumHelper::valid(ACE_CDR::Long value) const
{
for (OPENDDS_VECTOR(Pair)::const_iterator it = pairs_.begin(); it != pairs_.end(); ++it) {
if (it->value == value) {
return true;
}
}
return false;
}

bool ListEnumHelper::get_value(ACE_CDR::Long& value, const char* name) const
{
for (OPENDDS_VECTOR(Pair)::const_iterator it = pairs_.begin(); it != pairs_.end(); ++it) {
Expand Down
9 changes: 8 additions & 1 deletion dds/DCPS/ValueCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
namespace OpenDDS {
namespace DCPS {

class EnumHelper {
class OpenDDS_Dcps_Export EnumHelper {
public:
virtual ~EnumHelper() {}
virtual bool valid(const char* name) const = 0;
virtual bool valid(ACE_CDR::Long value) const = 0;
virtual bool get_value(ACE_CDR::Long& value, const char* name) const = 0;
virtual bool get_name(const char*& name, ACE_CDR::Long value) const = 0;
virtual XTypes::TypeKind get_equivalent_int() const = 0;

ACE_CDR::Long get_value(const char* name) const;
const char* get_name(ACE_CDR::Long value) const;
};

class OpenDDS_Dcps_Export ListEnumHelper : public EnumHelper {
Expand All @@ -47,6 +52,8 @@ class OpenDDS_Dcps_Export ListEnumHelper : public EnumHelper {
pairs_ = pairs;
}

bool valid(const char* name) const;
bool valid(ACE_CDR::Long value) const;
bool get_value(ACE_CDR::Long& value, const char* name) const;
bool get_name(const char*& name, ACE_CDR::Long value) const;

Expand Down
4 changes: 3 additions & 1 deletion dds/DCPS/XTypes/TypeObjectTypeSupportImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
#define OPENDDS_DCPS_XTYPES_TYPEOBJECTTYPESUPPORTIMPL_H

#include "TypeObject.h"
#include "dds/DCPS/ValueReader.h"

OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL

namespace OpenDDS {
namespace DCPS {

class ValueReader;
class ValueWriter;

inline bool vread(ValueReader&, XTypes::TypeIdentifier&)
{
return false;
Expand Down
5 changes: 1 addition & 4 deletions dds/dcps_optional_safety.mpb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ project : dds_suppress_any_support, dcps_ts_defaults, dds_versioning_idl_default

dcps_ts_flags += -Wb,pch_include=DCPS/DdsDcps_pch.h \
-Wb,export_macro=OpenDDS_Dcps_Export \
-Wb,export_include=dds/DCPS/dcps_export.h \
-Wb,versioning_begin=OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL \
-Wb,versioning_end=OPENDDS_END_VERSIONED_NAMESPACE_DECL \
-Wb,versioning_name=OPENDDS_VERSIONED_NAMESPACE_NAME
-Wb,export_include=dds/DCPS/dcps_export.h
}

feature(no_opendds_safety_profile, built_in_topics) : dds_suppress_any_support, dcps_ts_defaults, dds_versioning_idl_defaults {
Expand Down
Loading

0 comments on commit 08a2763

Please sign in to comment.