Skip to content

Commit

Permalink
Remove old cdr enviornment variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
Douglas Ayers committed Nov 8, 2024
1 parent 5678598 commit 9b9768a
Showing 1 changed file with 7 additions and 47 deletions.
54 changes: 7 additions & 47 deletions src/qos_dictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ namespace
* @details defaults to by source timestamp, but can be overridden with $DDS_DISTRUST_TIMESTAMPSS
* @return QosPolicy for destination order.
*/


DDS::DestinationOrderQosPolicyKind QosDictionary::getTimestampPolicy()
{
//lets use some static bools so we don't getenv() and transform strings every time we register a new topic.
Expand Down Expand Up @@ -194,60 +196,18 @@ DDS::DestinationOrderQosPolicyKind QosDictionary::getTimestampPolicy()
return retval;
}

DDS::DataRepresentationId_t QosDictionary::getDataRepresentationType()
{
return DDS::XCDR2_DATA_REPRESENTATION;
}

/**
* @brief Get the encoding for DataWriters
* @details Snippet from the OpenDDS 3.16 developers guide:
* For the rtps_udp transport, the default encoding of DataWriters changed from classic CDR to XCDR2. To maintain interoperability with pre-3.16 OpenDDS and other DDS implementations, the first element of representation.value of DataWriterQos must be set to DDS::XCDR_DATA_REPRESENTATION or the non-OpenDDS 3.16 DataReader must be set up with DDS::XCDR2_DATA_REPRESENTATION if supported. DataReaders will continue to be interoperable by default
* We default to XCDR2, but if $DDS_USE_OLD_CDR is set, CDR is used for compatilility with versions before 3.16.0
* @return QosPolicy for destination order.
*/
DDS::DataRepresentationId_t QosDictionary::getDataRepresentationType()
{
//lets use some static bools so we don't getenv() and transform strings every time we register a new topic.
//TODO: Determine if this needs thread safety. I think it doesn't?
static bool first_time = true;
static DDS::DataRepresentationId_t retval = DDS::XCDR2_DATA_REPRESENTATION;
if (!first_time)
{
//if (retval == DDS::XCDR2_DATA_REPRESENTATION)
//{
// std::cout << "[DDSMAN DEBUG] Using XCDR2" << std::endl;
//}
//else
//{
// std::cout << "[DDSMAN DEBUG] Using Classic CDR" << std::endl;
//}
return retval;
}
char* DDS_USE_OLD_CDR = getenv("DDS_USE_OLD_CDR");
bool old_cdr = false;
if (DDS_USE_OLD_CDR != NULL)
{
std::string old_cdr_val(DDS_USE_OLD_CDR);
std::transform(old_cdr_val.begin(), old_cdr_val.end(), old_cdr_val.begin(), [](char ch) {return static_cast<char>(::tolower(ch)); });
if ((old_cdr_val != "") && (old_cdr_val != "0") && (old_cdr_val != "false"))
{
old_cdr = true;
}
}
if (!old_cdr)
{
std::cout << "The 'DDS_USE_OLD_CDR' environment variable was not set. "
<< "Using XCDR2 encoding for data writers. This will enable xtypes functionality with OpenDDS 3.16.0 and later"
<< std::endl;
retval = DDS::XCDR2_DATA_REPRESENTATION;
}
else
{
std::cout << "The 'DDS_USE_OLD_CDR' environment variable was set. "
<< "Using 'classic' CDR encoding for data writers. This will enable interoperability with OpenDDS versions before 3.16.0"
<< std::endl;
retval = DDS::XCDR_DATA_REPRESENTATION;
}
first_time = false;
return retval;
}

OpenDDS::DCPS::Encoding::Kind QosDictionary::getEncodingKind()
{
if (QosDictionary::getDataRepresentationType() == DDS::XCDR_DATA_REPRESENTATION)
Expand Down

0 comments on commit 9b9768a

Please sign in to comment.