11 #ifndef RTI_ROUTING_PROCESSOR_ROUTE_HPP_
12 #define RTI_ROUTING_PROCESSOR_ROUTE_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_processor_impl.h"
21 #include <dds/core/xtypes/DynamicData.hpp>
22 #include <dds/sub/SampleInfo.hpp>
24 #include <rti/routing/processor/Input.hpp>
25 #include <rti/routing/processor/Output.hpp>
26 #include <rti/routing/processor/LoanedSamples.hpp>
27 #include <rti/routing/processor/PortIterator.hpp>
29 namespace rti {
namespace routing {
namespace processor {
33 class ProcessorForwarder;
40 template <
typename PORT>
struct port_list;
42 template <>
struct port_list<Input>
44 static std::vector<Input>&
get(Route& route);
47 template <>
struct port_list<Output>
49 static std::vector<Output>&
get(Route& route);
89 template <
typename DataRep,
typename InfoRep = dds::sub::SampleInfo>
91 typedef PortIterator<Input, DataRep, InfoRep> iterator;
93 Inputs(RTI_RoutingServiceRoute *native_route)
94 : native_route_(native_route)
100 return iterator(native_route_);
109 RTI_RoutingServiceRoute *native_route_;
112 template <
typename DataRep,
typename InfoRep = dds::sub::SampleInfo>
114 typedef PortIterator<Output, DataRep, InfoRep> iterator;
116 Outputs(RTI_RoutingServiceRoute *native_route)
117 : native_route_(native_route)
123 return iterator(native_route_);
132 RTI_RoutingServiceRoute *native_route_;
144 return RTI_RoutingServiceRoute_get_input_count(native_route_);
153 return RTI_RoutingServiceRoute_get_output_count(native_route_);
176 return *(get_input_at_index(index));
191 return *(lookup_input(name));
215 template <
typename DataRep,
typename InfoRep>
218 return &
input(index);
226 template <
typename DataRep>
229 return input<DataRep, dds::sub::SampleInfo>(index);
237 template <
typename DataRep,
typename InfoRep>
247 template <
typename DataRep>
250 return input<DataRep, dds::sub::SampleInfo>(name);
273 return *(get_output_at_index(index));
288 return *(lookup_output(name));
311 template <
typename DataRep,
typename InfoRep>
322 template <
typename DataRep>
325 return output<DataRep, dds::sub::SampleInfo>(index);
333 template <
typename DataRep,
typename InfoRep>
343 template <
typename DataRep>
346 return output<DataRep, dds::sub::SampleInfo>(name);
358 template <
typename DataRep,
typename InfoRep>
361 return Inputs<DataRep, InfoRep>(native_route_);
368 template <
typename DataRep>
371 return inputs<DataRep, dds::sub::SampleInfo>();
383 template <
typename DataRep,
typename InfoRep>
386 return Outputs<DataRep, InfoRep>(native_route_);
393 template <
typename DataRep>
396 return outputs<DataRep, dds::sub::SampleInfo>();
415 RTI_RoutingServiceRoute_set_session_period(
417 period.to_millisecs());
422 friend class detail::ProcessorForwarder;
424 friend struct port_list<
Input>;
425 friend struct port_list<
Output>;
427 typedef std::vector<Input>::iterator private_input_it;
428 typedef std::vector<Output>::iterator private_output_it;
432 Route(RTI_RoutingServiceRoute *native_route,
433 RTI_RoutingServiceEnvironment *native_env)
434 : native_route_(native_route),
435 native_env_(native_env)
439 template<
typename PORT>
440 PORT * get_port_from_native(
void *native)
442 return static_cast<PORT*
>(
443 RTI_RoutingServiceRoute_get_stream_port_user_data(
448 Input* get_input_at_index(int32_t index)
450 RTI_RoutingServiceStreamReaderExt *native_input =
451 RTI_RoutingServiceRoute_get_input_at(
454 if (native_input == NULL) {
455 throw dds::core::InvalidArgumentError(
456 RTI_RoutingServiceEnvironment_get_error_message(native_env_));
459 return get_port_from_native<Input>(native_input->stream_reader_data);
462 Output* get_output_at_index(int32_t index)
464 RTI_RoutingServiceStreamWriterExt *native_output =
465 RTI_RoutingServiceRoute_get_output_at(
468 if (native_output == NULL) {
469 throw dds::core::InvalidArgumentError(
470 RTI_RoutingServiceEnvironment_get_error_message(native_env_));
473 return get_port_from_native<Output>(
474 native_output->stream_writer_data);
478 Input* lookup_input(
const std::string& name)
480 RTI_RoutingServiceStreamReaderExt *native_input =
481 RTI_RoutingServiceRoute_lookup_input_by_name(
484 if (native_input == NULL) {
485 throw dds::core::InvalidArgumentError(
486 RTI_RoutingServiceEnvironment_get_error_message(native_env_));
488 return get_port_from_native<Input>(native_input->stream_reader_data);
492 Output* lookup_output(
const std::string& name)
494 RTI_RoutingServiceStreamWriterExt *native_output =
495 RTI_RoutingServiceRoute_lookup_output_by_name(
498 if (native_output == NULL) {
499 throw dds::core::InvalidArgumentError(
500 RTI_RoutingServiceEnvironment_get_error_message(native_env_));
502 return get_port_from_native<Output>(
503 native_output->stream_writer_data);
507 RTI_RoutingServiceRoute *native_route_;
508 RTI_RoutingServiceEnvironment *native_env_;
515 #endif // RTI_ROUTING_PROCESSOR_ROUTE_HPP_