11 #ifndef RTI_ROUTING_PROCESSOR_OUTPUT_HPP_
12 #define RTI_ROUTING_PROCESSOR_OUTPUT_HPP_
14 #include <dds/core/Value.hpp>
15 #include <dds/core/SafeEnumeration.hpp>
16 #include <rti/core/NativeValueType.hpp>
18 #include "routingservice/routingservice_processor.h"
19 #include "routingservice/routingservice_adapter_new.h"
20 #include <rti/routing/adapter/StreamWriter.hpp>
22 namespace rti {
namespace routing {
namespace processor {
26 template <
typename Data,
typename Info>
class TypedOutput;
30 RTI_RoutingServiceStreamWriterExt *native,
31 RTI_RoutingServiceRoute *native_route)
34 *RTI_RoutingServiceRoute_get_output_stream_info(native_route, native));
38 std::string name_from_native_output(
39 RTI_RoutingServiceStreamWriterExt *native,
40 RTI_RoutingServiceRoute *native_route)
42 return RTI_RoutingServiceRoute_get_output_name(
47 template <
typename Data,
typename Info = dds::sub::SampleInfo>
70 RTI_RoutingServiceStreamWriterExt *native,
72 RTI_RoutingServiceRoute *native_route,
73 RTI_RoutingServiceEnvironment *native_env)
76 native_env_(native_env),
77 stream_info_(stream_info_from_native_output(native, native_route)),
78 name_(name_from_native_output(native, native_route))
92 const std::string& name()
const
114 template <
typename Data,
typename Info>
129 template <
typename Data>
145 const std::vector<SamplePtr>& sample_seq,
146 const std::vector<InfoPtr>& info_seq) RTI_FINAL
148 int count = native_->write(
149 native_->stream_writer_data,
154 RTI_ROUTING_THROW_ON_ENV_ERROR(native_env_);
158 virtual void update(
const std::map<std::string, std::string>&) RTI_FINAL
160 throw dds::core::PreconditionNotMetError(
161 "update not applicable within a Processor notification context");
165 RTI_RoutingServiceStreamWriterExt* native()
171 template <
typename Data,
typename Info>
friend class TypedOutput;
173 RTI_RoutingServiceStreamWriterExt *native_;
175 RTI_RoutingServiceEnvironment *native_env_;
188 template <
typename Data,
typename Info>
208 const std::string&
name()
const;
221 void write(
const Data& sample,
const Info& info);
231 void write(
const Data& sample);
259 template <
typename Data,
typename Info>
260 struct create_data_from_output {
269 template <
typename Info>
270 struct create_data_from_output<dds::core::xtypes::DynamicData, Info> {
272 static dds::core::xtypes::DynamicData
get(TypedOutput<dds::core::xtypes::DynamicData, Info>& output)
274 if (output->stream_info().type_info().type_representation_kind()
275 != TypeRepresentationKind::DYNAMIC_TYPE) {
276 throw dds::core::PreconditionNotMetError(
277 "inconsistent data representation kind");
279 dds::core::xtypes::DynamicType *type_code =
280 static_cast<dds::core::xtypes::DynamicType *
> (
281 output->stream_info().type_info().type_representation());
282 return dds::core::xtypes::DynamicData(*type_code);
287 template <
typename Data,
typename Info>
288 TypedOutput<Data,Info>::TypedOutput(Output* output) : output_(output)
292 template <
typename Data,
typename Info>
295 return output_->stream_info_;
298 template <
typename Data,
typename Info>
301 return output_->name_;
304 template <
typename Data,
typename Info>
310 template <
typename Data,
typename Info>
313 const RTI_RoutingServiceSample out_samples[1] = {
314 const_cast<void *
> (
reinterpret_cast<const void *
> (&sample))
316 const RTI_RoutingServiceSampleInfo out_infos[1] = {
317 const_cast<void *
> (
reinterpret_cast<const void *
> (&info))
319 output_->native_->write(
320 output_->native_->stream_writer_data,
321 reinterpret_cast<const RTI_RoutingServiceSample *> (&out_samples),
322 reinterpret_cast<const RTI_RoutingServiceSample *> (&out_infos),
324 output_->native_env_);
325 RTI_ROUTING_THROW_ON_ENV_ERROR(output_->native_env_);
328 template <
typename Data,
typename Info>
331 const RTI_RoutingServiceSample out_samples[1] = {
332 const_cast<void *
> (
reinterpret_cast<const void *
> (&sample))
334 output_->native_->write(
335 output_->native_->stream_writer_data,
336 reinterpret_cast<const RTI_RoutingServiceSample *> (&out_samples),
339 output_->native_env_);
340 RTI_ROUTING_THROW_ON_ENV_ERROR(output_->native_env_);
343 template <
typename Data,
typename Info>
346 return create_data_from_output<Data, Info>::get(*
this);
362 #endif // RTI_ROUTING_PROCESSOR_OUTPUT_HPP_