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 = {
100 RTI_ROUTING_SERVICE_TYPE_REPRESENTATION_DYNAMIC_TYPE,
102 native_value = default_value;
105 static void finalize(native_type& native_value)
107 if (native_value.type_name != NULL) {
108 RTIOsapiHeap_freeString(native_value.type_name);
109 native_value.type_name = NULL;
113 static void copy(native_type& destination,
const native_type& source)
115 char *result = DDS_String_replace(
116 &destination.type_name,
118 if (source.type_name != NULL && result == NULL) {
119 throw std::bad_alloc();
121 destination.type_representation_kind =
122 source.type_representation_kind;
123 destination.type_representation =
124 source.type_representation;
127 static bool equals(
const native_type& first,
const native_type& second)
129 if (strcmp(first.type_name, second.type_name) != 0) {
132 if (first.type_representation_kind
133 != second.type_representation_kind) {
137 return first.type_representation == second.type_representation;
150struct native_type_traits<rti::routing::TypeInfo> {
151 typedef rti::routing::TypeInfoAdapter adapter_type;
152 typedef RTI_RoutingServiceTypeInfo native_type;
169class TypeInfo :
public rti::core::NativeValueType<TypeInfo> {
171 RTI_NATIVE_VALUE_TYPE_DEFINE_DEFAULT_MOVE_OPERATIONS(
TypeInfo)
173 typedef rti::core::NativeValueType<TypeInfo> Base;
193 const std::string& the_type_name,
195 TypeRepresentationKind::DYNAMIC_TYPE)
201 TypeInfo(
const struct RTI_RoutingServiceTypeInfo &native_stream_info)
202 : Base(native_stream_info)
211 return native().type_name;
226 if (DDS_String_replace(
228 the_type_name.c_str()) == NULL) {
229 throw std::bad_alloc();
240 return static_cast<TypeRepresentationKind::type
>(
241 native().type_representation_kind);
255 the_type_representation_kind.underlying());
264 return native().type_representation;
290 throw dds::core::IllegalOperationError(
291 "type representation is not dynamic type");
294 const DDS_TypeCode *native_typecode =
reinterpret_cast<DDS_TypeCode*
>(
296 return rti::core::native_conversions::cast_from_native<
297 dds::core::xtypes::DynamicType>(*native_typecode);
310 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:169
const dds::core::xtypes::DynamicType & dynamic_type() const
Returns the type_representation as DynamicType object.
Definition: TypeInfo.hpp:287
TypeInfo & type_name(const std::string &the_type_name)
Sets the registered name of the type associated with the data.
Definition: TypeInfo.hpp:223
void dynamic_type(const dds::core::xtypes::DynamicType *dynamic_type)
Sets the type representation value as DynamicType object.
Definition: TypeInfo.hpp:308
TypeRepresentationKind type_representation_kind() const
Getter (see setter with the same name)
Definition: TypeInfo.hpp:238
std::string type_name() const
Getter (see setter with the same name)
Definition: TypeInfo.hpp:209
TypeInfo & type_representation(TypeRepresentationType the_type_representation)
Sets the type representation value.
Definition: TypeInfo.hpp:275
TypeInfo & type_representation_kind(TypeRepresentationKind the_type_representation_kind)
Sets the type representation kind.
Definition: TypeInfo.hpp:251
RTI_RoutingServiceTypeRepresentation TypeRepresentationType
Type representation defined as an opaque pointer.
Definition: TypeInfo.hpp:180
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:192
TypeRepresentationType type_representation() const
Getter (see setter with the same name)
Definition: TypeInfo.hpp:262
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