11 #ifndef RTI_ROUTING_ADAPTER_TYPE_INFOHPP_
12 #define RTI_ROUTING_ADAPTER_TYPE_INFOHPP_
16 #include <dds/core/macros.hpp>
18 #include <routingservice/routingservice_infrastructure.h>
19 #include <dds/core/Value.hpp>
20 #include <dds/core/SafeEnumeration.hpp>
21 #include <rti/core/NativeValueType.hpp>
23 namespace rti {
namespace routing {
53 DYNAMIC_TYPE = RTI_ROUTING_SERVICE_TYPE_REPRESENTATION_DYNAMIC_TYPE,
63 XML = RTI_ROUTING_SERVICE_TYPE_REPRESENTATION_XML,
69 JAVA_OBJECT = RTI_ROUTING_SERVICE_TYPE_REPRESENTATION_JAVA_OBJECT,
76 CUSTOM = RTI_ROUTING_SERVICE_TYPE_REPRESENTATION_FIRST_CUSTOM_REPRESENTATION
91 class TypeInfoAdapter {
93 typedef RTI_RoutingServiceTypeInfo native_type;
95 static void initialize(native_type& native_value)
97 static const native_type default_value = {
99 RTI_ROUTING_SERVICE_TYPE_REPRESENTATION_DYNAMIC_TYPE,
101 native_value = default_value;
104 static void finalize(native_type& native_value)
106 if (native_value.type_name != NULL) {
107 RTIOsapiHeap_freeString(native_value.type_name);
108 native_value.type_name = NULL;
112 static void copy(native_type& destination,
const native_type& source)
114 char *result = DDS_String_replace(
115 &destination.type_name,
117 if (source.type_name != NULL && result == NULL) {
118 throw std::bad_alloc();
120 destination.type_representation_kind =
121 source.type_representation_kind;
122 destination.type_representation =
123 source.type_representation;
126 static bool equals(
const native_type& first,
const native_type& second)
128 if (strcmp(first.type_name, second.type_name) != 0) {
131 if (first.type_representation_kind
132 != second.type_representation_kind) {
136 return first.type_representation == second.type_representation;
149 struct native_type_traits<rti::routing::TypeInfo> {
150 typedef rti::routing::TypeInfoAdapter adapter_type;
151 typedef RTI_RoutingServiceTypeInfo native_type;
168 class TypeInfo :
public rti::core::NativeValueType<TypeInfo> {
170 RTI_NATIVE_VALUE_TYPE_DEFINE_DEFAULT_MOVE_OPERATIONS(
TypeInfo)
172 typedef rti::core::NativeValueType<TypeInfo> Base;
192 std::string& the_type_name,
193 TypeRepresentationKind the_type_representation_kind =
194 TypeRepresentationKind::DYNAMIC_TYPE)
200 TypeInfo(
const struct RTI_RoutingServiceTypeInfo &native_stream_info)
201 : Base(native_stream_info)
210 return native().type_name;
225 if (DDS_String_replace(
227 the_type_name.c_str()) == NULL) {
228 throw std::bad_alloc();
239 return static_cast<TypeRepresentationKind::type
>(
240 native().type_representation_kind);
251 TypeRepresentationKind the_type_representation_kind)
253 native().type_representation_kind =
static_cast<int>(
254 the_type_representation_kind.underlying());
263 return native().type_representation;
276 native().type_representation = the_type_representation;
283 #endif // RTI_ROUTING_ADAPTER_TYPE_INFOHPP_