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>
17#include <dds/pub/DataWriter.hpp>
18#include <dds/core/xtypes/DynamicData.hpp>
20#include "routingservice/routingservice_processor.h"
21#include "routingservice/routingservice_adapter_new.h"
22#include <rti/routing/adapter/StreamWriter.hpp>
24namespace rti {
namespace routing {
namespace processor {
28template <
typename Data,
typename Info>
class TypedOutput;
30template <
typename Data,
typename Info = dds::sub::SampleInfo>
50 RTI_RoutingServiceOutput *native,
52 RTI_RoutingServiceRoute *native_route) :
55 native_route_(native_route),
56 stream_info_(*RTI_RoutingServiceOutput_get_stream_info(native)),
57 name_(RTI_RoutingServiceOutput_get_name(native))
71 const std::string& name()
const
93 template <
typename Data,
typename Info>
108 template <
typename Data>
115 template <
typename Data,
typename Info>
friend class TypedOutput;
117 RTI_RoutingServiceOutput *native_;
119 RTI_RoutingServiceRoute *native_route_;
132template <
typename Data,
typename Info>
152 const std::string&
name()
const;
165 void write(
const Data& sample,
const Info& info);
175 void write(
const Data& sample);
215 DDS_DataWriter *native_writer =
216 RTI_RoutingServiceOutput_get_dds_writer(output_->native_);
217 if (native_writer == NULL) {
218 throw dds::core::InvalidArgumentError(
219 "invalid argument: input does not hold a DDS StreamWriter");
222 typedef dds::pub::DataWriter<Data> data_writer_type;
223 return rti::core::detail::create_from_native_entity<data_writer_type>(
233template <
typename Data,
typename Info>
234struct create_data_from_output {
236 static Data get(TypedOutput<Data, Info>& )
243template <
typename Info>
244struct create_data_from_output<dds::core::xtypes::DynamicData, Info> {
246 static dds::core::xtypes::DynamicData get(TypedOutput<dds::core::xtypes::DynamicData, Info>& output)
248 if (output->stream_info().type_info().type_representation_kind()
249 != TypeRepresentationKind::DYNAMIC_TYPE) {
250 throw dds::core::PreconditionNotMetError(
251 "inconsistent data representation kind");
253 dds::core::xtypes::DynamicType *type_code =
254 static_cast<dds::core::xtypes::DynamicType *
> (
255 output->stream_info().type_info().type_representation());
256 return dds::core::xtypes::DynamicData(*type_code);
261template <
typename Data,
typename Info>
262TypedOutput<Data,Info>::TypedOutput(Output* output) : output_(output)
266template <
typename Data,
typename Info>
269 return output_->stream_info_;
272template <
typename Data,
typename Info>
275 return output_->name_;
278template <
typename Data,
typename Info>
284template <
typename Data,
typename Info>
287 if (!RTI_RoutingServiceOutput_write_sample(
289 const_cast<void *
> (
reinterpret_cast<const void*
> (&sample)),
290 const_cast<void *
> (
reinterpret_cast<const void*
> (&info)))) {
291 throw dds::core::Error(
"error writing sample to native output");
295template <
typename Data,
typename Info>
298 if (!RTI_RoutingServiceOutput_write_sample(
300 const_cast<void *
> (
reinterpret_cast<const void*
> (&sample)),
302 throw dds::core::Error(
"error writing sample to native output");
306template <
typename Data,
typename Info>
309 return create_data_from_output<Data, Info>::get(*
this);
321typedef dds::pub::DataWriter<dds::core::xtypes::DynamicData> DynamicDataWriter;
Definition of the stream information that RTI Routing Service needs to manage user data streams.
Definition: StreamInfo.hpp:106
Generic Representation of a Route's output.
Definition: Output.hpp:44
TypedOutput< Data, Info > get()
Returns a typed version of this Output.
Definition: Output.hpp:94
TypedOutput< Data, dds::sub::SampleInfo > get()
Returns a typed version of this Output.
Definition: Output.hpp:109
Representation of the Route object that owns a Processor.
Definition: Route.hpp:84
Representation of an Output whose data representation is DataRep, whose info representation is InfoRe...
Definition: Output.hpp:133
const std::string & name() const
Returns the name of this output.
Definition: Output.hpp:273
const rti::routing::StreamInfo & stream_info() const
Returns the StreamInfo associated with this object.
Definition: Output.hpp:267
Data create_data()
Creates a new data sample that can be used to write in this output.
Definition: Output.hpp:307
dds::pub::DataWriter< Data > dds_data_writer()
Returns the underlying DDS DataWriter that is part of this StreamWriter implementation,...
Definition: Output.hpp:213
void write(const Data &sample, const Info &info)
Writes the specified data and info sample in this output.
Definition: Output.hpp:285