RTI Routing Service Version 7.3.0
StreamInfo.hpp
1/*
2 * (c) Copyright, Real-Time Innovations, 2017.
3 * All rights reserved.
4 *
5 * No duplications, whole or partial, manual or electronic, may be made
6 * without express written permission. Any such copies, or
7 * revisions thereof, must display this notice unaltered.
8 * This code contains trade secrets of Real-Time Innovations, Inc.
9 */
10
11#ifndef RTI_ROUTING_ADAPTER_STREAM_INFO_HPP_
12#define RTI_ROUTING_ADAPTER_STREAM_INFO_HPP_
13
14// IMPORTANT: macros.hpp must be the first RTI header included in every header
15// file so that symbols are exported correctly on Windows
16#include <dds/core/macros.hpp>
17
18
19#include <routingservice/routingservice_infrastructure.h>
20#include <dds/core/Value.hpp>
21#include <dds/core/Exception.hpp>
22#include <rti/core/NativeValueType.hpp>
23#include <rti/routing/TypeInfo.hpp>
24
25namespace rti { namespace routing {
26
31class StreamInfoAdapter {
32public:
33 typedef RTI_RoutingServiceStreamInfo native_type;
34
35 static void initialize(native_type& native_value)
36 {
37 RTIOsapiMemory_zero(
38 &native_value,
39 sizeof (RTI_RoutingServiceStreamInfo));
40 }
41
42 static void finalize(native_type& native_value)
43 {
44 TypeInfoAdapter::finalize(native_value.type_info);
45 if (native_value.stream_name != NULL) {
46 DDS_String_free(native_value.stream_name);
47 native_value.stream_name = NULL;
48 }
49 }
50
51 static void copy(native_type& destination, const native_type& source)
52 {
53 char *result = DDS_String_replace(
54 &destination.stream_name,
55 source.stream_name);
56 if (source.stream_name != NULL && result == NULL) {
57 throw std::bad_alloc();
58 }
59 destination.disposed = source.disposed;
60 TypeInfoAdapter::copy(
61 destination.type_info,
62 source.type_info);
63 }
64
65 static bool equals(const native_type& first, const native_type& second)
66 {
67 if (strcmp(first.stream_name, second.stream_name) != 0) {
68 return false;
69 }
70 if (first.disposed != second.disposed) {
71 return false;
72 }
73 return TypeInfoAdapter::equals(first.type_info, second.type_info);
74 }
75
76};
77
78class StreamInfo;
79
80}
81
82// native_type_traits needs to be defined in rti::core
83namespace core {
84
85template <>
86struct native_type_traits<rti::routing::StreamInfo> {
87 typedef rti::routing::StreamInfoAdapter adapter_type;
88 typedef RTI_RoutingServiceStreamInfo native_type;
89};
90
91}
92
93namespace routing {
94
106class StreamInfo : public rti::core::NativeValueType<StreamInfo> {
107public:
108 RTI_NATIVE_VALUE_TYPE_DEFINE_DEFAULT_MOVE_OPERATIONS(StreamInfo)
109
110 typedef rti::core::NativeValueType<StreamInfo> Base;
111public:
112
123 const std::string& the_stream_name,
124 const std::string& the_type_name)
125 {
126 stream_name(the_stream_name);
127 type_info().type_name(the_type_name);
128 }
129
130 StreamInfo(const RTI_RoutingServiceStreamInfo &native_stream_info)
131 : Base(native_stream_info)
132 {
133 }
134
138 bool disposed() const
139 {
140 return native().disposed ? true : false;
141 }
142
153 StreamInfo& disposed(bool the_disposed)
154 {
155 native().disposed = the_disposed ? 1 : 0;
156 return *this;
157 }
158
162 std::string stream_name() const
163 {
164 return native().stream_name;
165 }
166
173 StreamInfo& stream_name(const std::string& the_stream_name)
174 {
175 if (DDS_String_replace(
176 &native().stream_name,
177 the_stream_name.c_str()) == NULL) {
178 throw std::bad_alloc();
179 }
180
181 return *this;
182 }
183
188 {
189 using namespace rti::core::native_conversions;
190
191 return cast_from_native<TypeInfo>(native().type_info);
192 }
193
199 const TypeInfo& type_info() const
200 {
201 using namespace rti::core::native_conversions;
202
203 return cast_from_native<TypeInfo>(native().type_info);
204 }
205
206};
207
208}}
209
210#endif // RTI_ROUTING_ADAPTER_STREAM_INFO_HPP_
Definition of the stream information that RTI Routing Service needs to manage user data streams.
Definition: StreamInfo.hpp:106
const TypeInfo & type_info() const
Sets the type information associated with the stream.
Definition: StreamInfo.hpp:199
StreamInfo & stream_name(const std::string &the_stream_name)
Sets the name of the stream.
Definition: StreamInfo.hpp:173
StreamInfo & disposed(bool the_disposed)
Sets the dispose flag in this object.
Definition: StreamInfo.hpp:153
TypeInfo & type_info()
Getter (see setter with the same name)
Definition: StreamInfo.hpp:187
StreamInfo(const std::string &the_stream_name, const std::string &the_type_name)
Constructs a StreamInfo with the minimum required information.
Definition: StreamInfo.hpp:122
std::string stream_name() const
Getter (see setter with the same name)
Definition: StreamInfo.hpp:162
bool disposed() const
Getter (see setter with the same name)
Definition: StreamInfo.hpp:138
Definition of the type information associated with a RTI Routing Service stream.
Definition: TypeInfo.hpp:169
std::string type_name() const
Getter (see setter with the same name)
Definition: TypeInfo.hpp:209