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 <dds/core/xtypes/DynamicType.hpp>
22#include <rti/core/NativeValueType.hpp>
24namespace rti {
namespace routing {
54 DYNAMIC_TYPE = RTI_ROUTING_SERVICE_TYPE_REPRESENTATION_DYNAMIC_TYPE,
64 XML = RTI_ROUTING_SERVICE_TYPE_REPRESENTATION_XML,
70 JAVA_OBJECT = RTI_ROUTING_SERVICE_TYPE_REPRESENTATION_JAVA_OBJECT,
77 CUSTOM = RTI_ROUTING_SERVICE_TYPE_REPRESENTATION_FIRST_CUSTOM_REPRESENTATION
92class TypeInfoAdapter {
94 typedef RTI_RoutingServiceTypeInfo native_type;
96 static void initialize(native_type& native_value)
98 static const native_type default_value = {
101 RTI_ROUTING_SERVICE_TYPE_REPRESENTATION_DYNAMIC_TYPE,
103 native_value = default_value;
106 static void finalize(native_type& native_value)
108 if (native_value.type_name != NULL) {
109 RTIOsapiHeap_freeString(native_value.type_name);
110 native_value.type_name = NULL;
114 static void copy(native_type& destination,
const native_type& source)
116 char *result = DDS_String_replace(
117 &destination.type_name,
119 if (source.type_name != NULL && result == NULL) {
120 throw std::bad_alloc();
122 destination.can_be_optimized = source.can_be_optimized;
123 destination.type_representation_kind =
124 source.type_representation_kind;
125 destination.type_representation =
126 source.type_representation;
129 static bool equals(
const native_type& first,
const native_type& second)
131 if (strcmp(first.type_name, second.type_name) != 0) {
134 if (first.type_representation_kind
135 != second.type_representation_kind) {
139 return first.type_representation == second.type_representation;
152struct native_type_traits<rti::routing::TypeInfo> {
153 typedef rti::routing::TypeInfoAdapter adapter_type;
154 typedef RTI_RoutingServiceTypeInfo native_type;
171class TypeInfo :
public rti::core::NativeValueType<TypeInfo> {
173 RTI_NATIVE_VALUE_TYPE_DEFINE_DEFAULT_MOVE_OPERATIONS(
TypeInfo)
175 typedef rti::core::NativeValueType<TypeInfo> Base;
195 const std::string& the_type_name,
197 TypeRepresentationKind::DYNAMIC_TYPE)
201 native().can_be_optimized = DDS_BOOLEAN_TRUE;
204 TypeInfo(
const struct RTI_RoutingServiceTypeInfo &native_stream_info)
205 : Base(native_stream_info)
214 return native().type_name;
229 if (DDS_String_replace(
231 the_type_name.c_str()) == NULL) {
232 throw std::bad_alloc();
243 return static_cast<TypeRepresentationKind::type
>(
244 native().type_representation_kind);
258 the_type_representation_kind.underlying());
267 return native().type_representation;
293 throw dds::core::IllegalOperationError(
294 "type representation is not dynamic type");
297 const DDS_TypeCode *native_typecode =
reinterpret_cast<DDS_TypeCode*
>(
299 return rti::core::native_conversions::cast_from_native<
300 dds::core::xtypes::DynamicType>(*native_typecode);
313 DDS_TypeCode *native_typecode =
const_cast<DDS_TypeCode*
>(
valid type representations that RTI Routing Service accepts.
Definition of the type information associated with a RTI Routing Service stream.
Definition: TypeInfo.hpp:171
const dds::core::xtypes::DynamicType & dynamic_type() const
Returns the type_representation as DynamicType object.
Definition: TypeInfo.hpp:290
TypeInfo & type_name(const std::string &the_type_name)
Sets the registered name of the type associated with the data.
Definition: TypeInfo.hpp:226
void dynamic_type(const dds::core::xtypes::DynamicType *dynamic_type)
Sets the type representation value as DynamicType object.
Definition: TypeInfo.hpp:311
TypeRepresentationKind type_representation_kind() const
Getter (see setter with the same name)
Definition: TypeInfo.hpp:241
std::string type_name() const
Getter (see setter with the same name)
Definition: TypeInfo.hpp:212
TypeInfo & type_representation(TypeRepresentationType the_type_representation)
Sets the type representation value.
Definition: TypeInfo.hpp:278
TypeInfo & type_representation_kind(TypeRepresentationKind the_type_representation_kind)
Sets the type representation kind.
Definition: TypeInfo.hpp:254
RTI_RoutingServiceTypeRepresentation TypeRepresentationType
Type representation defined as an opaque pointer.
Definition: TypeInfo.hpp:182
TypeInfo(const std::string &the_type_name, TypeRepresentationKind the_type_representation_kind=TypeRepresentationKind::DYNAMIC_TYPE)
Constructs a TypeInfo with the minimum required information.
Definition: TypeInfo.hpp:194
TypeRepresentationType type_representation() const
Getter (see setter with the same name)
Definition: TypeInfo.hpp:265
The definition of the rti::routing::TypeRepresentationKind.
Definition: TypeInfo.hpp:41
type
Definition of all the possible type representation kinds.
Definition: TypeInfo.hpp:45
@ XML
[Not supported] XML type representation.
Definition: TypeInfo.hpp:64
@ CUSTOM
[Not supported] Custom type representation.
Definition: TypeInfo.hpp:77
@ DYNAMIC_TYPE
Dynamic type representation.
Definition: TypeInfo.hpp:54
@ JAVA_OBJECT
[Not supported] Java object type representation.
Definition: TypeInfo.hpp:70