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>
29namespace rti {
namespace routing {
namespace processor {
33class ProcessorForwarder;
39template <
typename PORT>
struct port_list;
41template <>
struct port_list<Input>
43 static std::vector<Input>& get(Route& route);
46template <>
struct port_list<Output>
48 static std::vector<Output>& get(Route& route);
88 template <
typename DataRep,
typename InfoRep = dds::sub::SampleInfo>
90 typedef PortIterator<Input, DataRep, InfoRep> iterator;
92 Inputs(RTI_RoutingServiceRoute *native_route)
93 : native_route_(native_route)
99 return iterator(native_route_);
108 RTI_RoutingServiceRoute *native_route_;
111 template <
typename DataRep,
typename InfoRep = dds::sub::SampleInfo>
113 typedef PortIterator<Output, DataRep, InfoRep> iterator;
115 Outputs(RTI_RoutingServiceRoute *native_route)
116 : native_route_(native_route)
122 return iterator(native_route_);
131 RTI_RoutingServiceRoute *native_route_;
141 return RTI_RoutingServiceRoute_get_input_count(native_route_);
150 return RTI_RoutingServiceRoute_get_output_count(native_route_);
159 return RTI_RoutingServiceRoute_is_input_enabled(native_route_, index)
170 return RTI_RoutingServiceRoute_is_output_enabled(native_route_, index)
195 return *(get_input_at_index(index));
213 return *(lookup_input(name));
237 template <
typename DataRep,
typename InfoRep>
240 return &
input(index);
248 template <
typename DataRep>
251 return input<DataRep, dds::sub::SampleInfo>(index);
259 template <
typename DataRep,
typename InfoRep>
269 template <
typename DataRep>
272 return input<DataRep, dds::sub::SampleInfo>(name);
295 return *(get_output_at_index(index));
313 return *(lookup_output(name));
336 template <
typename DataRep,
typename InfoRep>
347 template <
typename DataRep>
350 return output<DataRep, dds::sub::SampleInfo>(index);
358 template <
typename DataRep,
typename InfoRep>
368 template <
typename DataRep>
371 return output<DataRep, dds::sub::SampleInfo>(name);
383 template <
typename DataRep,
typename InfoRep>
386 return Inputs<DataRep, InfoRep>(native_route_);
393 template <
typename DataRep>
396 return inputs<DataRep, dds::sub::SampleInfo>();
408 template <
typename DataRep,
typename InfoRep>
411 return Outputs<DataRep, InfoRep>(native_route_);
418 template <
typename DataRep>
421 return outputs<DataRep, dds::sub::SampleInfo>();
437 void period(
const dds::core::Duration& period)
439 struct DDS_Duration_t native_period;
440 rti::core::native_conversions::to_native(native_period, period);
441 RTI_RoutingServiceRoute_set_period(
446 dds::core::Duration period()
const
448 struct DDS_Duration_t native_period;
449 RTI_RoutingServiceRoute_get_period(
453 return rti::core::native_conversions::from_native(native_period);
468 friend class detail::ProcessorForwarder;
470 friend struct port_list<
Input>;
471 friend struct port_list<
Output>;
473 typedef std::vector<Input>::iterator private_input_it;
474 typedef std::vector<Output>::iterator private_output_it;
478 Route(RTI_RoutingServiceRoute *native_route,
479 RTI_RoutingServiceEnvironment *native_env)
480 : native_route_(native_route),
481 native_env_(native_env)
483 const char *native_full_name =
484 RTI_RoutingServiceRoute_get_full_name(native_route);
485 if (native_full_name ==
nullptr) {
486 throw dds::core::InvalidArgumentError(
487 "Native Route has invalid full name");
489 full_name_ = native_full_name;
492 Input* get_input_at_index(int32_t index)
494 RTI_RoutingServiceInput *native_input =
495 RTI_RoutingServiceRoute_get_input_at(native_route_, index);
496 if (native_input == NULL) {
497 throw dds::core::InvalidArgumentError(
498 RTI_RoutingServiceEnvironment_get_error_message(native_env_));
501 return static_cast<Input*
>(RTI_RoutingServiceInput_get_user_data(native_input));
504 Output* get_output_at_index(int32_t index)
506 RTI_RoutingServiceOutput *native_output =
507 RTI_RoutingServiceRoute_get_output_at(native_route_, index);
508 if (native_output == NULL) {
509 throw dds::core::InvalidArgumentError(
510 RTI_RoutingServiceEnvironment_get_error_message(native_env_));
513 return static_cast<Output*
>(RTI_RoutingServiceOutput_get_user_data(native_output));
517 Input* lookup_input(
const std::string& name)
519 RTI_RoutingServiceInput *native_input =
520 RTI_RoutingServiceRoute_lookup_input_by_name(
523 if (native_input == NULL) {
524 throw dds::core::InvalidArgumentError(
525 RTI_RoutingServiceEnvironment_get_error_message(native_env_));
527 return static_cast<Input*
>(RTI_RoutingServiceInput_get_user_data(native_input));
531 Output* lookup_output(
const std::string& name)
533 RTI_RoutingServiceOutput *native_output =
534 RTI_RoutingServiceRoute_lookup_output_by_name(
537 if (native_output == NULL) {
538 throw dds::core::InvalidArgumentError(
539 RTI_RoutingServiceEnvironment_get_error_message(native_env_));
541 return static_cast<Output*
>(RTI_RoutingServiceOutput_get_user_data(native_output));
546 RTI_RoutingServiceRoute *native_route_;
547 RTI_RoutingServiceEnvironment *native_env_;
548 std::string full_name_;
RTI Routing Service C++ Adapter API.
Generic Representation of a Route's output.
Definition: Output.hpp:44
Representation of the Route object that owns a Processor.
Definition: Route.hpp:84
Outputs< DataRep > outputs()
Same as Inputs<DataRep, InfoRep> outputs() with InfoRep = dds::sub::SampleInfo.
Definition: Route.hpp:419
Input & input(const std::string &name)
Returns the Input object with the specified name or throws an exception if the input with the given n...
Definition: Route.hpp:211
Output & output(int32_t index)
Returns the Output object at the specified index.
Definition: Route.hpp:293
TypedOutput< DataRep > output(const std::string &name)
Same as output<DataRep, InfoRep>(std::string&) with InfoRep = dds::sub::SampleInfo.
Definition: Route.hpp:369
int32_t input_count() const
Returns the total number of inputs in this Route.
Definition: Route.hpp:139
Inputs< DataRep > inputs()
Same as Inputs<DataRep, InfoRep> inputs() with InfoRep = dds::sub::SampleInfo.
Definition: Route.hpp:394
TypedInput< DataRep, InfoRep > input(const std::string &name)
Same as input<DataRep, InfoRep>(int32_t) but using the configuration name of the input.
Definition: Route.hpp:260
void period(const dds::core::Duration &period)
Changes the event period of this Route.
Definition: Route.hpp:437
TypedOutput< DataRep > output(int32_t index)
Same as output<DataRep, InfoRep>(int32_t) with InfoRep = dds::sub::SampleInfo.
Definition: Route.hpp:348
Input & input(int32_t index)
Returns the Input object at the specified index.
Definition: Route.hpp:193
Outputs< DataRep, InfoRep > outputs()
Returns an accessor for the contained outputs.
Definition: Route.hpp:409
TypedOutput< DataRep, InfoRep > output(int32_t index)
Returns the TypedOutput object at the specified index.
Definition: Route.hpp:337
const std::string & full_name() const
Returns the fully qualified of this Route, derived from the configuration.
Definition: Route.hpp:461
TypedOutput< DataRep, InfoRep > output(const std::string &name)
Same as output<DataRep, InfoRep>(int32_t) but using the configuration name of the output.
Definition: Route.hpp:359
TypedInput< DataRep > input(const std::string &name)
Same as input<DataRep, InfoRep>(std::string&) with InfoRep = dds::sub::SampleInfo.
Definition: Route.hpp:270
int32_t output_count() const
Returns the total number of outputs in this Route.
Definition: Route.hpp:148
TypedInput< DataRep > input(int32_t index)
Same as input<DataRep, InfoRep>(int32_t) with InfoRep = dds::sub::SampleInfo.
Definition: Route.hpp:249
Inputs< DataRep, InfoRep > inputs()
Returns an accessor for the contained inputs.
Definition: Route.hpp:384
TypedInput< DataRep, InfoRep > input(int32_t index)
Returns the TypedInput object at the specified index.
Definition: Route.hpp:238
bool output_enabled(int32_t index) const
Checks whether the Input at the specified index is enabled.
Definition: Route.hpp:168
Output & output(const std::string &name)
Returns the Output object with the specified name or throws an exception if the output with the given...
Definition: Route.hpp:311
bool input_enabled(int32_t index) const
Checks whether the Input at the specified index is enabled.
Definition: Route.hpp:157
Representation of an Output whose data representation is DataRep, whose info representation is InfoRe...
Definition: Output.hpp:133