11#ifndef RTI_ROUTING_ROUTING_SERVICE_IMPL_HPP_
12#define RTI_ROUTING_ROUTING_SERVICE_IMPL_HPP_
14#include <dds/core/refmacros.hpp>
15#include <rti/core/detail/SelfReference.hpp>
16#include "routingservice/routingservice_adapter.h"
17#include "routingservice/routingservice_service.h"
18#include "routingservice/routingservice_log.h"
20#include <rti/routing/ServiceProperty.hpp>
21#include <rti/routing/adapter/detail/AdapterForwarder.hpp>
22#include <rti/routing/transf/detail/TransformationPluginForwarder.hpp>
23#include <rti/routing/processor/detail/ProcessorPluginForwarder.hpp>
24#include <rti/routing/detail/ShutdownHookForwarder.hpp>
26namespace rti {
namespace routing {
28class RoutingServiceImpl
29 :
public rti::core::detail::RetainableType<RoutingServiceImpl> {
32 template <
typename HookFunc>
33 explicit RoutingServiceImpl(
34 const ServiceProperty& property,
35 HookFunc& shutdown_hook)
36 : native_(RTI_RoutingService_new(&property.native())),
38 new rti::routing::detail::ShutdownHookForwarder<HookFunc>(
41 rti::core::check_create_entity(native_,
"RoutingService");
42 RTI_RoutingService_set_remote_shutdown_hook(
44 shutdown_hook_fwd_->native());
47 explicit RoutingServiceImpl(
const ServiceProperty& property)
48 : native_(RTI_RoutingService_new(&property.native())),
49 shutdown_hook_fwd_(nullptr)
51 rti::core::check_create_entity(native_,
"RoutingService");
54 RoutingServiceImpl(
const RTI_RoutingServiceProperty& property)
55 : native_(RTI_RoutingService_new(&property)),
56 shutdown_hook_fwd_(NULL)
58 rti::core::check_create_entity(native_,
"RoutingService");
61 RoutingServiceImpl(RTI_RoutingService *native)
62 : native_(native), shutdown_hook_fwd_(NULL)
64 rti::core::check_create_entity(native_,
"RoutingService");
69 RTI_RoutingService_delete(native_);
70 delete shutdown_hook_fwd_;
75 if (!RTI_RoutingService_start(native_)) {
76 throw dds::core::Error(
"failed to start RoutingService");
82 if (!RTI_RoutingService_stop(native_)) {
83 throw dds::core::Error(
"failed to stop RoutingService");
87 void attach_adapter_plugin(
89 const std::string& registered_name)
91 RTI_RoutingServiceAdapterPluginExt *native_plugin =
92 adapter::detail::AdapterForwarder::create_plugin(adapter_plugin);
93 if (!RTI_RoutingService_attach_adapter_plugin(
96 registered_name.c_str())) {
97 throw dds::core::Error(
"failed to attach native adapter");
101 void attach_transformation_plugin(
103 const std::string& registered_name)
105 RTI_RoutingServiceTransformationPlugin *native_plugin =
106 transf::detail::TransformationPluginForwarder::create_plugin(
107 transformation_plugin);
108 if (!RTI_RoutingService_attach_transformation_plugin(
111 registered_name.c_str())) {
112 throw dds::core::Error(
"failed to attach native transformation");
116 void attach_processor_plugin(
118 const std::string& registered_name)
120 RTI_RoutingServiceProcessorPlugin *native_plugin =
121 processor::detail::ProcessorPluginForwarder::create_plugin(
123 if (!RTI_RoutingService_attach_processor_plugin(
126 registered_name.c_str())) {
127 throw dds::core::Error(
"failed to attach native processor");
131 RTI_RoutingService* native()
const
137 RTI_RoutingService *native_;
138 rti::routing::detail::AbstractShutdownHookForwarder *shutdown_hook_fwd_;
The top-level plug-in class.
Definition: AdapterPlugin.hpp:34
The top-level plug-in class.
Definition: ProcessorPlugin.hpp:202