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> 24 namespace rti {
namespace routing {
namespace processor {
30 template <
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_;
132 template <
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>(
233 template <
typename Data,
typename Info>
234 struct create_data_from_output {
243 template <
typename Info>
244 struct create_data_from_output<dds::core::xtypes::DynamicData, Info> {
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);
261 template <
typename Data,
typename Info>
266 template <
typename Data,
typename Info>
269 return output_->stream_info_;
272 template <
typename Data,
typename Info>
275 return output_->name_;
278 template <
typename Data,
typename Info>
284 template <
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");
295 template <
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");
306 template <
typename Data,
typename Info>
309 return create_data_from_output<Data, Info>::get(*
this);
321 typedef dds::pub::DataWriter<dds::core::xtypes::DynamicData> DynamicDataWriter;
326 #endif // RTI_ROUTING_PROCESSOR_OUTPUT_HPP_ Definition of the stream information that RTI Routing Service needs to manage user data streams...
Definition: StreamInfo.hpp:106
Data create_data()
Creates a new data sample that can be used to write in this output.
Definition: Output.hpp:307
void write(const Data &sample, const Info &info)
Writes the specified data and info sample in this output.
Definition: Output.hpp:285
dds::pub::DataWriter< Data > dds_data_writer()
Returns the underlying DDS DataWriter that is part of this StreamWriter implementation, assuming this input holds a DDS StreamWriter.
Definition: Output.hpp:213
Representation of an Output whose data representation is DataRep, whose info representation is InfoRe...
Definition: Output.hpp:28
Representation of the Route object that owns a Processor.
Definition: Route.hpp:84
const rti::routing::StreamInfo & stream_info() const
Returns the StreamInfo associated with this object.
Definition: Output.hpp:267
Definition: AdapterPlugin.hpp:25
const std::string & name() const
Returns the name of this output.
Definition: Output.hpp:273
Generic Representation of a Route's output.
Definition: Output.hpp:44