RTI Connext .NET API (legacy)  Version 6.1.2
HelloWorldPlugin.cpp

RTI Connext Implementation Support

Files generated by rtiddsgen that provided methods for type specific serialization and deserialization, to support the RTI Connext implementation.

The following files are always generated in the C++/CLI language, even when code is generated with the -language C# option, because they depend on unmanaged code that ships with RTI Connext. Once compiled, the code can be used from either C++/CLI or C# code; see the C# publisher and subscriber example code.

HelloWorldPlugin.h

/*
WARNING: THIS FILE IS AUTO-GENERATED. DO NOT MODIFY.
This file was generated from HelloWorld.idl
using RTI Code Generator (rtiddsgen) version 3.1.2.
The rtiddsgen tool is part of the RTI Connext DDS distribution.
For more information, type 'rtiddsgen -help' at a command shell
or consult the Code Generator User's Manual.
*/
#pragma once
#include "HelloWorld.h"
/* ------------------------------------------------------------------------
* Type: HelloWorld
* ------------------------------------------------------------------------ */
public ref class HelloWorldPlugin :
DefaultTypePlugin<HelloWorld^> {
// --- Support methods: ------------------------------------------------------
public:
void print_data(
HelloWorld^ sample,
System::String^ desc,
System::UInt32 indent);
// --- (De)Serialize methods: ------------------------------------------------
public:
virtual System::Boolean serialize(
TypePluginDefaultEndpointData^ endpoint_data,
HelloWorld^ sample,
CdrStream% stream,
System::Boolean serialize_encapsulation,
System::UInt16 encapsulation_id,
System::Boolean serialize_sample,
System::Object^ endpoint_plugin_qos) override;
virtual System::Boolean deserialize_sample(
TypePluginDefaultEndpointData^ endpoint_data,
HelloWorld^ sample,
CdrStream% stream,
System::Boolean deserialize_encapsulation,
System::Boolean deserialize_sample,
System::Object^ endpoint_plugin_qos) override;
System::Boolean skip(
TypePluginDefaultEndpointData^ endpoint_data,
CdrStream% stream,
System::Boolean skip_encapsulation,
System::Boolean skip_sample,
System::Object^ endpoint_plugin_qos);
virtual System::UInt32 get_serialized_sample_max_size(
TypePluginDefaultEndpointData^ endpoint_data,
System::Boolean include_encapsulation,
System::UInt16 encapsulation_id,
System::UInt32 size) override;
virtual System::UInt32 get_serialized_sample_min_size(
TypePluginDefaultEndpointData^ endpoint_data,
System::Boolean include_encapsulation,
System::UInt16 encapsulation_id,
System::UInt32 size) override;
virtual System::UInt32 get_serialized_sample_size(
TypePluginDefaultEndpointData^ endpoint_data,
Boolean include_encapsulation,
UInt16 encapsulation_id,
UInt32 current_alignment,
HelloWorld^ sample) override;
// --- Key Management functions: --------------------------------------------
public:
virtual System::UInt32 get_serialized_key_max_size(
TypePluginDefaultEndpointData^ endpoint_data,
System::Boolean include_encapsulation,
System::UInt16 encapsulation_id,
System::UInt32 current_alignment) override;
virtual System::UInt32 get_serialized_key_for_keyhash_max_size(
TypePluginDefaultEndpointData^ endpoint_data,
System::Boolean include_encapsulation,
System::UInt16 encapsulation_id,
System::UInt32 current_alignment) override;
virtual System::Boolean serialize_key(
TypePluginDefaultEndpointData^ endpoint_data,
HelloWorld^ key,
CdrStream% stream,
System::Boolean serialize_encapsulation,
System::UInt16 encapsulation_id,
System::Boolean serialize_sample,
System::Object^ endpoint_plugin_qos) override;
virtual System::Boolean serialize_key_for_keyhash(
TypePluginDefaultEndpointData^ endpoint_data,
HelloWorld^ key,
CdrStream% stream,
System::Boolean serialize_encapsulation,
System::UInt16 encapsulation_id,
System::Boolean serialize_sample,
System::Object^ endpoint_plugin_qos) override;
virtual System::Boolean deserialize_key_sample(
TypePluginDefaultEndpointData^ endpoint_data,
HelloWorld^ key,
CdrStream% stream,
System::Boolean deserialize_encapsulation,
System::Boolean deserialize_sample,
System::Object^ endpoint_plugin_qos) override;
System::Boolean serialized_sample_to_key(
TypePluginDefaultEndpointData^ endpoint_data,
HelloWorld^ sample,
CdrStream% stream,
System::Boolean deserialize_encapsulation,
System::Boolean deserialize_key,
System::Object^ endpoint_plugin_qos);
// --- Plug-in lifecycle management methods: --------------------------------
public:
static HelloWorldPlugin^ get_instance();
static void dispose();
private:
HelloWorldPlugin()
: DefaultTypePlugin(
"HelloWorld",
false, // not keyed
false, // use RTPS-compliant alignment
#ifndef NDDS_STANDALONE_TYPE
HelloWorld::get_typecode()) {
#else
nullptr) {
#endif
// empty
}
static HelloWorldPlugin^ _singleton;
};

HelloWorldPlugin.cpp

/*
WARNING: THIS FILE IS AUTO-GENERATED. DO NOT MODIFY.
This file was generated from HelloWorld.idl
using RTI Code Generator (rtiddsgen) version 3.1.2.
The rtiddsgen tool is part of the RTI Connext DDS distribution.
For more information, type 'rtiddsgen -help' at a command shell
or consult the Code Generator User's Manual.
*/
#include "HelloWorldPlugin.h"
#pragma unmanaged
#include "ndds/ndds_cpp.h"
#include "osapi/osapi_utility.h"
#pragma managed
/* ------------------------------------------------------------------------
* Type HelloWorld
* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------
Support functions:
* ------------------------------------------------------------------------ */
void
HelloWorldPlugin::print_data(
HelloWorld^ sample,
String^ desc,
UInt32 indent_level) {
for (UInt32 i = 0; i < indent_level; ++i) { Console::Write(" "); }
if (desc != nullptr) {
Console::WriteLine("{0}:", desc);
} else {
Console::WriteLine();
}
if (sample == nullptr) {
Console::WriteLine("null");
return;
}
DataPrintUtility::print_object(
sample->msg, "msg", indent_level);
}
/* ------------------------------------------------------------------------
(De)Serialize functions:
* ------------------------------------------------------------------------ */
Boolean
HelloWorldPlugin::serialize(
TypePluginDefaultEndpointData^ endpoint_data,
HelloWorld^ sample,
CdrStream% stream,
Boolean serialize_encapsulation,
UInt16 final_encapsulation_id,
Boolean serialize_sample,
Object^ endpoint_plugin_qos)
{
CdrStreamPosition rti_position;
char* dheaderPosition = NULL;
Boolean inBaseClass_tmp = stream.inBaseClass;
stream.inBaseClass = false;
if (serialize_encapsulation) {
/* Encapsulate sample */
if (!stream.serialize_and_set_cdr_encapsulation(final_encapsulation_id, ExtensibilityKind::EXTENSIBLE_EXTENSIBILITY)) {
return false;
}
rti_position = stream.reset_alignment();
}
if (serialize_sample) {
Boolean xcdr1 = (final_encapsulation_id <= CdrEncapsulation::CDR_ENCAPSULATION_ID_PL_CDR_LE)? true: false;
if (!inBaseClass_tmp && !xcdr1) {
dheaderPosition=stream.writeDHeader();
}
if (!stream.serialize_string(sample->msg , (128))) {
return false;
}
if(!xcdr1){
if (dheaderPosition!=NULL) {
stream.setDHeader(dheaderPosition);
}
}
}
if(serialize_encapsulation) {
stream.restore_alignment(rti_position);
}
return true;
}
Boolean
HelloWorldPlugin::deserialize_sample(
TypePluginDefaultEndpointData^ endpoint_data,
HelloWorld^ sample,
CdrStream% stream,
Boolean deserialize_encapsulation,
Boolean deserialize_data,
Object^ endpoint_plugin_qos)
{
CdrStreamPosition rti_position;
char * tmpPosition = 0;
UInt32 tmpSize = 0;
UInt32 tmpLength = 0;
char * buffer = nullptr;
Boolean inBaseClass_tmp = stream.inBaseClass;
stream.inBaseClass = false;
if(deserialize_encapsulation) {
/* Deserialize encapsulation */
if (!stream.deserialize_and_set_cdr_encapsulation()) {
return false;
}
rti_position = stream.reset_alignment();
}
if (deserialize_data) {
UInt16 encapsulation_id = stream.get_encapsulation_kind();
Boolean xcdr1 = (encapsulation_id <= CdrEncapsulation::CDR_ENCAPSULATION_ID_PL_CDR_LE)? true: false;
sample->clear();
char * DHtmpPosition = 0;
UInt32 DHtmpSize = 0;
UInt32 DHtmpLength = 0;
if (!inBaseClass_tmp && !xcdr1) {
DHtmpLength = stream.deserialize_unsigned_long();
DHtmpPosition = stream.get_current_position().toChar();
DHtmpSize = stream.get_buffer_length();
stream.set_buffer_length((UInt32)((UInt64)DHtmpPosition - (UInt64)stream.get_buffer_begin()) + DHtmpLength);
}
try{
sample->msg = stream.deserialize_string( (128));
if (sample->msg == nullptr) {
return false;
}
} catch (System::ApplicationException^ e) {
if (stream.get_remainder() >= RTI_CDR_PARAMETER_HEADER_ALIGNMENT) {
throw gcnew System::ApplicationException("Error deserializing sample! Remainder: " + stream.get_remainder() + "\n" +
"Exception caused by: " + e->Message);
}
}
if (!inBaseClass_tmp && !xcdr1) {
stream.restore_buffer((char *)(DHtmpPosition + DHtmpLength), DHtmpSize);
}
}
if(deserialize_encapsulation) {
stream.restore_alignment(rti_position);
}
return true;
}
Boolean
HelloWorldPlugin::skip(
TypePluginDefaultEndpointData^ endpoint_data,
CdrStream% stream,
Boolean skip_encapsulation,
Boolean skip_sample,
Object^ endpoint_plugin_qos)
{
CdrStreamPosition rti_position;
char * tmpPosition = 0;
UInt32 tmpSize = 0;
UInt32 tmpLength = 0;
char * buffer = nullptr;
Boolean inBaseClass_tmp = stream.inBaseClass;
stream.inBaseClass = false;
if (skip_encapsulation) {
if (!stream.skip_encapsulation()) {
return false;
}
rti_position = stream.reset_alignment();
}
if (skip_sample) {
UInt16 encapsulation_id = stream.get_encapsulation_kind();
Boolean xcdr1 = (encapsulation_id <= CdrEncapsulation::CDR_ENCAPSULATION_ID_PL_CDR_LE)? true: false;
char * DHtmpPosition = 0;
UInt32 DHtmpLength = 0;
if (!xcdr1 && !inBaseClass_tmp) {
DHtmpLength = stream.deserialize_unsigned_long();
DHtmpPosition = stream.get_current_position().toChar();
stream.set_current_position((char *)(DHtmpPosition + DHtmpLength));
if(skip_encapsulation) {
stream.restore_alignment(rti_position);
}
return true;
}
try {
stream.skip_string((128));
} catch (System::ApplicationException^ e) {
if (stream.get_remainder() >= RTI_CDR_PARAMETER_HEADER_ALIGNMENT) {
throw gcnew System::ApplicationException(
"Error skipping sample! Remainder: "
+ stream.get_remainder() + "\n"
+ "Exception caused by: " + e->Message);
}
}
}
if(skip_encapsulation) {
stream.restore_alignment(rti_position);
}
return true;
}
/*
size is the offset from the point where we have do a logical reset
Return difference in size, not the final offset.
*/
UInt32
HelloWorldPlugin::get_serialized_sample_max_size(
TypePluginDefaultEndpointData^ endpoint_data,
Boolean include_encapsulation,
UInt16 final_encapsulation_id,
UInt32 current_alignment)
{
UInt32 initial_alignment = current_alignment;
UInt32 encapsulation_size = current_alignment;
CdrPrimitiveType ^ _cdrPrimitiveType = CdrPrimitiveType::get_cdr_primitive_type_instance(final_encapsulation_id);
UInt16 encapsulation_id = CdrEncapsulation::get_encapsulation_from_final(
final_encapsulation_id,
ExtensibilityKind::EXTENSIBLE_EXTENSIBILITY);
Boolean xcdr1 = (encapsulation_id <= CdrEncapsulation::CDR_ENCAPSULATION_ID_PL_CDR_LE);
if (include_encapsulation) {
if (!CdrStream::valid_encapsulation_id(encapsulation_id)) {
return 1;
}
encapsulation_size = CdrPrimitiveType::get_encapsulation_serialized_size(
current_alignment);
encapsulation_size -= current_alignment;
current_alignment = 0;
initial_alignment = 0;
}
if (!xcdr1) {
//DHeader
current_alignment += _cdrPrimitiveType->get_long_max_size_serialized(current_alignment);
}
current_alignment +=_cdrPrimitiveType->get_string_max_size_serialized(
current_alignment , (128)+1);
if (include_encapsulation) {
current_alignment += encapsulation_size;
}
return current_alignment - initial_alignment;
}
UInt32
HelloWorldPlugin::get_serialized_sample_min_size(
TypePluginDefaultEndpointData^ endpoint_data,
Boolean include_encapsulation,
UInt16 final_encapsulation_id,
UInt32 current_alignment)
{
UInt32 initial_alignment = current_alignment;
UInt32 encapsulation_size = current_alignment;
CdrPrimitiveType ^ _cdrPrimitiveType = CdrPrimitiveType::get_cdr_primitive_type_instance(final_encapsulation_id);
UInt16 encapsulation_id = CdrEncapsulation::get_encapsulation_from_final(
final_encapsulation_id,
ExtensibilityKind::EXTENSIBLE_EXTENSIBILITY);
Boolean xcdr1 = (encapsulation_id <= CdrEncapsulation::CDR_ENCAPSULATION_ID_PL_CDR_LE);
if (include_encapsulation) {
if (!CdrStream::valid_encapsulation_id(encapsulation_id)) {
return 1;
}
encapsulation_size = CdrPrimitiveType::get_encapsulation_serialized_size(
encapsulation_size);
current_alignment = 0;
initial_alignment = 0;
}
if (!xcdr1) {
//DHeader
current_alignment += _cdrPrimitiveType->get_long_max_size_serialized(current_alignment);
}
current_alignment +=_cdrPrimitiveType->get_string_max_size_serialized(
current_alignment, 1);
if (include_encapsulation) {
current_alignment += encapsulation_size;
}
return current_alignment - initial_alignment;
}
UInt32
HelloWorldPlugin::get_serialized_sample_size(
TypePluginDefaultEndpointData^ endpoint_data,
Boolean include_encapsulation,
UInt16 final_encapsulation_id,
UInt32 current_alignment,
HelloWorld^ sample)
{
UInt32 initial_alignment = current_alignment;
UInt32 encapsulation_size = current_alignment;
CdrPrimitiveType ^ _cdrPrimitiveType = CdrPrimitiveType::get_cdr_primitive_type_instance(final_encapsulation_id);
UInt16 encapsulation_id = CdrEncapsulation::get_encapsulation_from_final(
final_encapsulation_id,
ExtensibilityKind::EXTENSIBLE_EXTENSIBILITY);
Boolean xcdr1 = (encapsulation_id <= CdrEncapsulation::CDR_ENCAPSULATION_ID_PL_CDR_LE);
if (include_encapsulation) {
if (!CdrStream::valid_encapsulation_id(encapsulation_id)) {
return 1;
}
encapsulation_size = CdrPrimitiveType::get_encapsulation_serialized_size(
current_alignment);
encapsulation_size -= current_alignment;
current_alignment = 0;
initial_alignment = 0;
endpoint_data->set_base_alignment(current_alignment);
}
if (!xcdr1) {
//DHeader
current_alignment += _cdrPrimitiveType->get_long_max_size_serialized(current_alignment);
}
current_alignment += _cdrPrimitiveType->get_string_max_size_serialized(
endpoint_data->get_alignment(current_alignment), sample->msg);
if (include_encapsulation) {
current_alignment += encapsulation_size;
}
return current_alignment - initial_alignment;
}
UInt32
HelloWorldPlugin::get_serialized_key_max_size(
TypePluginDefaultEndpointData^ endpoint_data,
Boolean include_encapsulation,
UInt16 final_encapsulation_id,
UInt32 current_alignment)
{
UInt32 encapsulation_size = current_alignment;
UInt32 initial_alignment = current_alignment;
CdrPrimitiveType ^ _cdrPrimitiveType = CdrPrimitiveType::get_cdr_primitive_type_instance(final_encapsulation_id);
UInt16 encapsulation_id = CdrEncapsulation::get_encapsulation_from_final(
final_encapsulation_id,
ExtensibilityKind::EXTENSIBLE_EXTENSIBILITY);
Boolean xcdr1 = (encapsulation_id <= CdrEncapsulation::CDR_ENCAPSULATION_ID_PL_CDR_LE);
if (include_encapsulation) {
if (!CdrStream::valid_encapsulation_id(encapsulation_id)) {
return 1;
}
encapsulation_size = CdrPrimitiveType::get_encapsulation_serialized_size(
current_alignment);
current_alignment = 0;
initial_alignment = 0;
}
if (!xcdr1) {
//DHeader
current_alignment += _cdrPrimitiveType->get_long_max_size_serialized(current_alignment);
}
current_alignment +=get_serialized_sample_max_size(
endpoint_data,false, encapsulation_id, current_alignment);
if (include_encapsulation) {
current_alignment += encapsulation_size;
}
return current_alignment - initial_alignment;
}
UInt32
HelloWorldPlugin::get_serialized_key_for_keyhash_max_size(
TypePluginDefaultEndpointData^ endpoint_data,
Boolean include_encapsulation,
UInt16 final_encapsulation_id,
UInt32 current_alignment)
{
UInt32 encapsulation_size = current_alignment;
UInt32 initial_alignment = current_alignment;
CdrPrimitiveType ^ _cdrPrimitiveType = CdrPrimitiveType::get_cdr_primitive_type_instance(final_encapsulation_id);
UInt16 encapsulation_id = CdrEncapsulation::get_encapsulation_from_final(
final_encapsulation_id,
ExtensibilityKind::EXTENSIBLE_EXTENSIBILITY);
Boolean xcdr1 = (encapsulation_id <= CdrEncapsulation::CDR_ENCAPSULATION_ID_PL_CDR_LE);
if(xcdr1){
return get_serialized_key_max_size(
endpoint_data,
include_encapsulation,
final_encapsulation_id,
current_alignment);
}
if (include_encapsulation) {
if (!CdrStream::valid_encapsulation_id(encapsulation_id)) {
return 1;
}
encapsulation_size = CdrPrimitiveType::get_encapsulation_serialized_size(
current_alignment);
current_alignment = 0;
initial_alignment = 0;
}
current_alignment +=_cdrPrimitiveType->get_string_max_size_serialized(
current_alignment , (128)+1);
if (include_encapsulation) {
current_alignment += encapsulation_size;
}
return current_alignment - initial_alignment;
}
/* ------------------------------------------------------------------------
Key Management functions:
* ------------------------------------------------------------------------ */
Boolean
HelloWorldPlugin::serialize_key(
TypePluginDefaultEndpointData^ endpoint_data,
HelloWorld^ sample,
CdrStream% stream,
Boolean serialize_encapsulation,
UInt16 final_encapsulation_id,
Boolean serialize_key,
Object^ endpoint_plugin_qos)
{
CdrStreamPosition rti_position;
char* dheaderPosition = NULL;
Boolean inBaseClass_tmp = stream.inBaseClass;
stream.inBaseClass = false;
if (serialize_encapsulation) {
/* Encapsulate sample */
if (!stream.serialize_and_set_cdr_encapsulation(final_encapsulation_id, ExtensibilityKind::EXTENSIBLE_EXTENSIBILITY)) {
return false;
}
rti_position = stream.reset_alignment();
}
if (serialize_key) {
Boolean xcdr1 = (final_encapsulation_id <= CdrEncapsulation::CDR_ENCAPSULATION_ID_PL_CDR_LE)? true: false;
if (!serialize(
endpoint_data,
sample,
stream,
false,
final_encapsulation_id,
serialize_key,
endpoint_plugin_qos)) {
return false;
}
}
if(serialize_encapsulation) {
stream.restore_alignment(rti_position);
}
return true;
}
Boolean
HelloWorldPlugin::serialize_key_for_keyhash(
TypePluginDefaultEndpointData^ endpoint_data,
HelloWorld^ sample,
CdrStream% stream,
Boolean serialize_encapsulation,
UInt16 final_encapsulation_id,
Boolean serialize_key,
Object^ endpoint_plugin_qos)
{
CdrStreamPosition rti_position;
Boolean inBaseClass_tmp = stream.inBaseClass;
stream.inBaseClass = false;
Boolean xcdr1 = (final_encapsulation_id <= CdrEncapsulation::CDR_ENCAPSULATION_ID_PL_CDR_LE)? true: false;
if (xcdr1){
return this->serialize_key(
endpoint_data,
sample,
stream,
serialize_encapsulation,
final_encapsulation_id,
serialize_key,
endpoint_plugin_qos);
}
if (serialize_encapsulation) {
if (!stream.serialize_and_set_cdr_encapsulation(final_encapsulation_id, ExtensibilityKind::EXTENSIBLE_EXTENSIBILITY)) {
return false;
}
rti_position = stream.reset_alignment();
} else {
stream.set_cdr_encapsulation(final_encapsulation_id);
}
if (serialize_key) {
if (!stream.serialize_string(sample->msg , (128))) {
return false;
}
}
if(serialize_encapsulation) {
stream.restore_alignment(rti_position);
}
return true;
}
Boolean HelloWorldPlugin::deserialize_key_sample(
TypePluginDefaultEndpointData^ endpoint_data,
HelloWorld^ sample,
CdrStream% stream,
Boolean deserialize_encapsulation,
Boolean deserialize_key,
Object^ endpoint_plugin_qos)
{
CdrStreamPosition rti_position;
char * tmpPosition = 0;
UInt32 tmpSize = 0;
UInt32 tmpLength = 0;
char * buffer = nullptr;
Boolean inBaseClass_tmp = stream.inBaseClass;
stream.inBaseClass = false;
if (deserialize_encapsulation) {
/* Deserialize encapsulation */
if (!stream.deserialize_and_set_cdr_encapsulation()) {
return false;
}
rti_position = stream.reset_alignment();
}
if (deserialize_key) {
UInt16 encapsulation_id = stream.get_encapsulation_kind();
Boolean xcdr1 = (encapsulation_id <= CdrEncapsulation::CDR_ENCAPSULATION_ID_PL_CDR_LE)? true: false;
if (!deserialize_sample(
endpoint_data, sample, stream,
false,
deserialize_key,
endpoint_plugin_qos)) {
return false;
}
}
if(deserialize_encapsulation) {
stream.restore_alignment(rti_position);
}
return true;
}
Boolean
HelloWorldPlugin::serialized_sample_to_key(
TypePluginDefaultEndpointData^ endpoint_data,
HelloWorld^ sample,
CdrStream% stream,
Boolean deserialize_encapsulation,
Boolean deserialize_key,
Object^ endpoint_plugin_qos)
{
CdrStreamPosition rti_position;
char * tmpPosition = 0;
UInt32 tmpSize = 0;
UInt32 tmpLength = 0;
char * buffer = nullptr;
Boolean inBaseClass_tmp = stream.inBaseClass;
stream.inBaseClass = false;
if(deserialize_encapsulation) {
if (!stream.deserialize_and_set_cdr_encapsulation()) {
return false;
}
rti_position = stream.reset_alignment();
}
if (deserialize_key) {
UInt16 encapsulation_id = stream.get_encapsulation_kind();
Boolean xcdr1 = (encapsulation_id <= CdrEncapsulation::CDR_ENCAPSULATION_ID_PL_CDR_LE)? true: false;
if (!deserialize_sample(
endpoint_data,
sample,
stream,
false,
deserialize_key,
endpoint_plugin_qos)) {
return false;
}
}
if(deserialize_encapsulation) {
stream.restore_alignment(rti_position);
}
return true;
}
/* ------------------------------------------------------------------------
* Plug-in Lifecycle Methods
* ------------------------------------------------------------------------ */
HelloWorldPlugin^
HelloWorldPlugin::get_instance() {
if (_singleton == nullptr) {
_singleton = gcnew HelloWorldPlugin();
}
return _singleton;
}
void
HelloWorldPlugin::dispose() {
delete _singleton;
_singleton = nullptr;
}