import com.rti.dds.cdr.CdrEncapsulation;
import com.rti.dds.cdr.CdrInputStream;
import com.rti.dds.cdr.CdrOutputStream;
import com.rti.dds.cdr.CdrPrimitiveType;
import com.rti.dds.cdr.CdrBuffer;
import com.rti.dds.cdr.CdrHelper;
import com.rti.dds.cdr.CdrMemberInfo;
import com.rti.dds.domain.DomainParticipant;
import com.rti.dds.publication.DataWriter;
import com.rti.dds.publication.DataWriterListener;
import com.rti.dds.subscription.DataReader;
import com.rti.dds.subscription.DataReaderListener;
import com.rti.dds.topic.KeyHash_t;
import com.rti.dds.topic.TypeSupportImpl;
import com.rti.dds.topic.TypeSupportType;
import com.rti.dds.util.Sequence;
import com.rti.dds.topic.DefaultEndpointData;
import com.rti.dds.infrastructure.RETCODE_ERROR;
import com.rti.dds.infrastructure.*;
import com.rti.dds.topic.TypeSupportParticipantInfo;
import com.rti.dds.topic.TypeSupportEndpointInfo;
import com.rti.dds.typecode.TypeCode;
import com.rti.dds.cdr.IllegalCdrStateException;
import com.rti.dds.infrastructure.Copyable;
public class HelloWorldTypeSupport extends TypeSupportImpl {
private static final String TYPE_NAME = "HelloWorld";
private static final char[] PLUGIN_VERSION = {2, 0, 0, 0};
private static final HelloWorldTypeSupport _singleton
= new HelloWorldTypeSupport();
public static String get_type_name() {
return _singleton.get_type_nameI();
}
public static void register_type(DomainParticipant participant,
String type_name) {
_singleton.register_typeI(participant, type_name);
}
public static void unregister_type(DomainParticipant participant,
String type_name) {
_singleton.unregister_typeI(participant, type_name);
}
public static HelloWorldTypeSupport get_instance() {
return _singleton;
}
public static HelloWorldTypeSupport getInstance() {
return get_instance();
}
public Object create_data() {
return HelloWorld.create();
}
public void destroy_data(Object data) {
return;
}
public Object create_key() {
return new HelloWorld();
}
public void destroy_key(Object key) {
return;
}
public Class get_type() {
return HelloWorld.class;
}
public Object copy_data(Object destination, Object source) {
HelloWorld typedDst = (HelloWorld) destination;
HelloWorld typedSrc = (HelloWorld) source;
return typedDst.copy_from(typedSrc);
}
public long get_serialized_sample_max_size(Object endpoint_data,boolean include_encapsulation,short encapsulation_id,long currentAlignment) {
long origAlignment = currentAlignment;
long encapsulation_size = currentAlignment;
if(include_encapsulation) {
if (!CdrEncapsulation.isValidEncapsulationKind(encapsulation_id)) {
throw new RETCODE_ERROR("Unsupported encapsulation");
}
encapsulation_size += CdrPrimitiveType.SHORT.getMaxSizeSerialized(encapsulation_size);
encapsulation_size += CdrPrimitiveType.SHORT.getMaxSizeSerialized(encapsulation_size);
encapsulation_size -= currentAlignment;
currentAlignment = 0;
origAlignment = 0;
}
currentAlignment += CdrPrimitiveType.getStringMaxSizeSerialized(currentAlignment, ((128))+1);
if (include_encapsulation) {
currentAlignment += encapsulation_size;
}
return currentAlignment - origAlignment;
}
public long get_serialized_sample_min_size(Object endpoint_data,boolean include_encapsulation,short encapsulation_id,long currentAlignment) {
long origAlignment = currentAlignment;
long encapsulation_size = currentAlignment;
if(include_encapsulation) {
if (!CdrEncapsulation.isValidEncapsulationKind(encapsulation_id)) {
throw new RETCODE_ERROR("Unsupported encapsulation");
}
encapsulation_size += CdrPrimitiveType.SHORT.getMaxSizeSerialized(encapsulation_size);
encapsulation_size += CdrPrimitiveType.SHORT.getMaxSizeSerialized(encapsulation_size);
encapsulation_size -= currentAlignment;
currentAlignment = 0;
origAlignment = 0;
}
currentAlignment += CdrPrimitiveType.getStringMaxSizeSerialized(currentAlignment, 1);
if (include_encapsulation) {
currentAlignment += encapsulation_size;
}
return currentAlignment - origAlignment;
}
public long get_serialized_sample_size(
Object endpoint_data, boolean include_encapsulation,
short encapsulation_id, long currentAlignment,
Object sample)
{
HelloWorld typedSrc = (HelloWorld) sample;
long origAlignment = currentAlignment;
long encapsulation_size = currentAlignment;
if(include_encapsulation) {
if (!CdrEncapsulation.isValidEncapsulationKind(encapsulation_id)) {
throw new RETCODE_ERROR("Unsupported encapsulation");
}
encapsulation_size += CdrPrimitiveType.SHORT.getMaxSizeSerialized(encapsulation_size);
encapsulation_size += CdrPrimitiveType.SHORT.getMaxSizeSerialized(encapsulation_size);
encapsulation_size -= currentAlignment;
currentAlignment = 0;
origAlignment = 0;
}
currentAlignment += CdrPrimitiveType.getStringSerializedSize(currentAlignment , typedSrc.msg );
if (include_encapsulation) {
currentAlignment += encapsulation_size;
}
return currentAlignment - origAlignment;
}
public long get_serialized_key_max_size(
Object endpoint_data,
boolean include_encapsulation,
short encapsulation_id,
long currentAlignment)
{
long origAlignment = currentAlignment;
long encapsulation_size = currentAlignment;
if(include_encapsulation) {
if (!CdrEncapsulation.isValidEncapsulationKind(encapsulation_id)) {
throw new RETCODE_ERROR("Unsupported encapsulation");
}
encapsulation_size += CdrPrimitiveType.SHORT.getMaxSizeSerialized(encapsulation_size);
encapsulation_size += CdrPrimitiveType.SHORT.getMaxSizeSerialized(encapsulation_size);
encapsulation_size -= currentAlignment;
currentAlignment = 0;
origAlignment = 0;
}
currentAlignment += get_serialized_sample_max_size(
endpoint_data,false,encapsulation_id,currentAlignment);
if (include_encapsulation) {
currentAlignment += encapsulation_size;
}
return currentAlignment - origAlignment;
}
public void serialize(Object endpoint_data,Object src, CdrOutputStream dst,boolean serialize_encapsulation,
short encapsulation_id, boolean serialize_sample, Object endpoint_plugin_qos) {
int position = 0;
if(serialize_encapsulation) {
dst.serializeAndSetCdrEncapsulation(encapsulation_id);
position = dst.resetAlignment();
}
if(serialize_sample) {
HelloWorld typedSrc = (HelloWorld) src;
dst.writeString(typedSrc.msg,(128));
}
if (serialize_encapsulation) {
dst.restoreAlignment(position);
}
}
public void serialize_key(
Object endpoint_data,
Object src,
CdrOutputStream dst,
boolean serialize_encapsulation,
short encapsulation_id,
boolean serialize_key,
Object endpoint_plugin_qos)
{
int position = 0;
if (serialize_encapsulation) {
dst.serializeAndSetCdrEncapsulation(encapsulation_id);
position = dst.resetAlignment();
}
if (serialize_key) {
HelloWorld typedSrc = (HelloWorld) src;
serialize(endpoint_data, src, dst, false, CdrEncapsulation.CDR_ENCAPSULATION_ID_CDR_BE, true, endpoint_plugin_qos);
}
if (serialize_encapsulation) {
dst.restoreAlignment(position);
}
}
public Object deserialize_sample(
Object endpoint_data,
Object dst,
CdrInputStream src, boolean deserialize_encapsulation,
boolean deserialize_sample,
Object endpoint_plugin_qos)
{
int position = 0;
if(deserialize_encapsulation) {
src.deserializeAndSetCdrEncapsulation();
position = src.resetAlignment();
}
if(deserialize_sample) {
HelloWorld typedDst = (HelloWorld) dst;
typedDst.clear();
try{
typedDst.msg = src.readString((128));
} catch (IllegalCdrStateException stateEx) {
if (src.available() >= CdrEncapsulation.CDR_ENCAPSULATION_PARAMETER_ID_ALIGNMENT) {
throw new RETCODE_ERROR("Error deserializing sample! Remainder: " + src.available() + "\n" +
"Exception caused by: " + stateEx.getMessage());
}
} catch (Exception ex) {
throw new RETCODE_ERROR(ex.getMessage());
}
}
if (deserialize_encapsulation) {
src.restoreAlignment(position);
}
return dst;
}
public Object deserialize_key_sample(
Object endpoint_data,
Object dst,
CdrInputStream src,
boolean deserialize_encapsulation,
boolean deserialize_key,
Object endpoint_plugin_qos)
{
int position = 0;
if(deserialize_encapsulation) {
src.deserializeAndSetCdrEncapsulation();
position = src.resetAlignment();
}
if(deserialize_key) {
HelloWorld typedDst = (HelloWorld) dst;
deserialize_sample(endpoint_data, dst, src, false, true, endpoint_plugin_qos);
}
if (deserialize_encapsulation) {
src.restoreAlignment(position);
}
return dst;
}
public void skip(Object endpoint_data,
CdrInputStream src,
boolean skip_encapsulation,
boolean skip_sample,
Object endpoint_plugin_qos)
{
int position = 0;
if (skip_encapsulation) {
src.skipEncapsulation();
position = src.resetAlignment();
}
if (skip_sample) {
src.skipString();
}
if (skip_encapsulation) {
src.restoreAlignment(position);
}
}
public Object serialized_sample_to_key(
Object endpoint_data,
Object sample,
CdrInputStream src,
boolean deserialize_encapsulation,
boolean deserialize_key,
Object endpoint_plugin_qos)
{
int position = 0;
if(deserialize_encapsulation) {
src.deserializeAndSetCdrEncapsulation();
position = src.resetAlignment();
}
if (deserialize_key) {
HelloWorld typedDst = (HelloWorld) sample;
deserialize_sample(
endpoint_data, sample, src, false,
true, endpoint_plugin_qos);
}
if (deserialize_encapsulation) {
src.restoreAlignment(position);
}
return sample;
}
public Object on_participant_attached(Object registration_data,
TypeSupportParticipantInfo participant_info,
boolean top_level_registration,
Object container_plugin_context,
TypeCode type_code) {
return super.on_participant_attached(
registration_data, participant_info, top_level_registration,
container_plugin_context, type_code);
}
public void on_participant_detached(Object participant_data) {
super.on_participant_detached(participant_data);
}
public Object on_endpoint_attached(Object participantData,
TypeSupportEndpointInfo endpoint_info,
boolean top_level_registration,
Object container_plugin_context) {
return super.on_endpoint_attached(
participantData, endpoint_info,
top_level_registration, container_plugin_context);
}
public void on_endpoint_detached(Object endpoint_data) {
super.on_endpoint_detached(endpoint_data);
}
protected DataWriter create_datawriter(long native_writer,
DataWriterListener listener,
int mask) {
return new HelloWorldDataWriter (native_writer, listener, mask, this);
}
protected DataReader create_datareader(long native_reader,
DataReaderListener listener,
int mask) {
return new HelloWorldDataReader(native_reader, listener, mask, this);
}
protected HelloWorldTypeSupport() {
super(TYPE_NAME, false,HelloWorldTypeCode.VALUE,HelloWorld.class,TypeSupportType.TST_STRUCT, PLUGIN_VERSION);
}
protected HelloWorldTypeSupport (boolean enableKeySupport) {
super(TYPE_NAME, enableKeySupport,HelloWorldTypeCode.VALUE,HelloWorld.class,TypeSupportType.TST_STRUCT, PLUGIN_VERSION);
}
}
import com.rti.dds.infrastructure.Time_t;
import com.rti.dds.infrastructure.WriteParams_t;
import com.rti.dds.infrastructure.InstanceHandle_t;
import com.rti.dds.publication.DataWriterImpl;
import com.rti.dds.publication.DataWriterListener;
import com.rti.dds.topic.TypeSupportImpl;
public class HelloWorldDataWriter extends DataWriterImpl {
public InstanceHandle_t register_instance(HelloWorld instance_data) {
return register_instance_untyped(instance_data);
}
public InstanceHandle_t register_instance_w_timestamp(HelloWorld instance_data,
Time_t source_timestamp) {
return register_instance_w_timestamp_untyped(
instance_data, source_timestamp);
}
public InstanceHandle_t register_instance_w_params(HelloWorld instance_data,
WriteParams_t params) {
return register_instance_w_params_untyped(
instance_data, params);
}
public void unregister_instance(HelloWorld instance_data,
InstanceHandle_t handle) {
unregister_instance_untyped(instance_data, handle);
}
public void unregister_instance_w_timestamp(HelloWorld instance_data,
InstanceHandle_t handle, Time_t source_timestamp) {
unregister_instance_w_timestamp_untyped(
instance_data, handle, source_timestamp);
}
public void unregister_instance_w_params(HelloWorld instance_data,
WriteParams_t params) {
unregister_instance_w_params_untyped(
instance_data, params);
}
public void write(HelloWorld instance_data, InstanceHandle_t handle) {
write_untyped(instance_data, handle);
}
public void write_w_timestamp(HelloWorld instance_data,
InstanceHandle_t handle, Time_t source_timestamp) {
write_w_timestamp_untyped(instance_data, handle, source_timestamp);
}
public void write_w_params(HelloWorld instance_data,
WriteParams_t params) {
write_w_params_untyped(instance_data, params);
}
public void dispose(HelloWorld instance_data, InstanceHandle_t instance_handle){
dispose_untyped(instance_data, instance_handle);
}
public void dispose_w_timestamp(HelloWorld instance_data,
InstanceHandle_t instance_handle, Time_t source_timestamp) {
dispose_w_timestamp_untyped(
instance_data, instance_handle, source_timestamp);
}
public void dispose_w_params(HelloWorld instance_data,
WriteParams_t params) {
dispose_w_params_untyped(instance_data, params);
}
public void get_key_value(HelloWorld key_holder, InstanceHandle_t handle) {
get_key_value_untyped(key_holder, handle);
}
public InstanceHandle_t lookup_instance(HelloWorld key_holder) {
return lookup_instance_untyped(key_holder);
}
HelloWorldDataWriter(long native_writer, DataWriterListener listener,
int mask, TypeSupportImpl type) {
super(native_writer, listener, mask, type);
}
}
import com.rti.dds.infrastructure.InstanceHandle_t;
import com.rti.dds.subscription.DataReaderImpl;
import com.rti.dds.subscription.DataReaderListener;
import com.rti.dds.subscription.ReadCondition;
import com.rti.dds.subscription.SampleInfo;
import com.rti.dds.subscription.SampleInfoSeq;
import com.rti.dds.topic.TypeSupportImpl;
public class HelloWorldDataReader extends DataReaderImpl {
public void read(HelloWorldSeq received_data, SampleInfoSeq info_seq,
int max_samples,
int sample_states, int view_states, int instance_states) {
read_untyped(received_data, info_seq, max_samples, sample_states,
view_states, instance_states);
}
public void take(HelloWorldSeq received_data, SampleInfoSeq info_seq,
int max_samples,
int sample_states, int view_states, int instance_states) {
take_untyped(received_data, info_seq, max_samples, sample_states,
view_states, instance_states);
}
public void read_w_condition(HelloWorldSeq received_data,
SampleInfoSeq info_seq,
int max_samples,
ReadCondition condition) {
read_w_condition_untyped(received_data, info_seq, max_samples,
condition);
}
public void take_w_condition(HelloWorldSeq received_data,
SampleInfoSeq info_seq,
int max_samples,
ReadCondition condition) {
take_w_condition_untyped(received_data, info_seq, max_samples,
condition);
}
public void read_next_sample(HelloWorld received_data, SampleInfo sample_info) {
read_next_sample_untyped(received_data, sample_info);
}
public void take_next_sample(HelloWorld received_data, SampleInfo sample_info) {
take_next_sample_untyped(received_data, sample_info);
}
public void read_instance(HelloWorldSeq received_data, SampleInfoSeq info_seq,
int max_samples, InstanceHandle_t a_handle, int sample_states,
int view_states, int instance_states) {
read_instance_untyped(received_data, info_seq, max_samples, a_handle,
sample_states, view_states, instance_states);
}
public void take_instance(HelloWorldSeq received_data, SampleInfoSeq info_seq,
int max_samples, InstanceHandle_t a_handle, int sample_states,
int view_states, int instance_states) {
take_instance_untyped(received_data, info_seq, max_samples, a_handle,
sample_states, view_states, instance_states);
}
public void read_instance_w_condition(HelloWorldSeq received_data,
SampleInfoSeq info_seq, int max_samples,
InstanceHandle_t a_handle, ReadCondition condition) {
read_instance_w_condition_untyped(received_data, info_seq,
max_samples, a_handle, condition);
}
public void take_instance_w_condition(HelloWorldSeq received_data,
SampleInfoSeq info_seq, int max_samples,
InstanceHandle_t a_handle, ReadCondition condition) {
take_instance_w_condition_untyped(received_data, info_seq,
max_samples, a_handle, condition);
}
public void read_next_instance(HelloWorldSeq received_data,
SampleInfoSeq info_seq, int max_samples,
InstanceHandle_t a_handle, int sample_states, int view_states,
int instance_states) {
read_next_instance_untyped(received_data, info_seq, max_samples,
a_handle, sample_states, view_states, instance_states);
}
public void take_next_instance(HelloWorldSeq received_data,
SampleInfoSeq info_seq, int max_samples,
InstanceHandle_t a_handle, int sample_states, int view_states,
int instance_states) {
take_next_instance_untyped(received_data, info_seq, max_samples,
a_handle, sample_states, view_states, instance_states);
}
public void read_next_instance_w_condition(HelloWorldSeq received_data,
SampleInfoSeq info_seq, int max_samples,
InstanceHandle_t a_handle, ReadCondition condition) {
read_next_instance_w_condition_untyped(received_data, info_seq,
max_samples, a_handle, condition);
}
public void take_next_instance_w_condition(HelloWorldSeq received_data,
SampleInfoSeq info_seq, int max_samples,
InstanceHandle_t a_handle, ReadCondition condition) {
take_next_instance_w_condition_untyped(received_data, info_seq,
max_samples, a_handle, condition);
}
public void return_loan(HelloWorldSeq received_data, SampleInfoSeq info_seq) {
return_loan_untyped(received_data, info_seq);
}
public void get_key_value(HelloWorld key_holder, InstanceHandle_t handle){
get_key_value_untyped(key_holder, handle);
}
public InstanceHandle_t lookup_instance(HelloWorld key_holder) {
return lookup_instance_untyped(key_holder);
}
HelloWorldDataReader (long native_reader, DataReaderListener listener,
int mask, TypeSupportImpl data_type) {
super(native_reader, listener, mask, data_type);
}
}