11#ifndef RTI_ROUTING_ADAPTER_DETAIL_SESSION_FORWARDER_HPP_
12#define RTI_ROUTING_ADAPTER_DETAIL_SESSION_FORWARDER_HPP_
14#include <rti/core/Exception.hpp>
16#include <rti/apputils/ServiceException.hpp>
18#include <rti/routing/adapter/Connection.hpp>
19#include <rti/routing/detail/UpdatableEntityForwarder.hpp>
20#include <rti/routing/detail/ForwarderUtils.hpp>
22namespace rti {
namespace routing {
namespace adapter {
namespace detail {
25class SessionForwarder {
27 static RTI_RoutingServiceSessionExt* create_native(
28 Connection *connection,
29 const RTI_RoutingServiceProperties *native_properties,
30 RTI_RoutingServiceEnvironment *environment)
34 using rti::routing::detail::ScopedForwarder;
37 std::map<std::string, std::string> properties;
38 rti::routing::PropertyAdapter::add_properties_from_native(
42 SessionForwarder *forwarder =
new SessionForwarder();
43 ScopedForwarder<Connection, SessionForwarder> scoped(
49 forwarder->session_ = connection->create_session(properties);
58 return forwarder->native();
59 }
catch(
const rti::apputils::FatalServiceException& ex) {
60 RTI_RoutingServiceEnvironment_fatal_error(
64 }
catch(
const std::exception& ex) {
65 RTI_RoutingServiceEnvironment_set_error(
70 RTI_RoutingServiceEnvironment_set_error(
72 "unexpected exception");
77 static void delete_native(
78 Connection *connection,
79 RTI_RoutingServiceSessionExt *native_session,
80 RTI_RoutingServiceEnvironment *environment)
82 SessionForwarder *forwarder =
static_cast<SessionForwarder*
>(
83 native_session->session_data);
86 if (forwarder->session_ != NULL) {
87 connection->delete_session(forwarder->session_);
88 forwarder->session_ = NULL;
91 }
catch(
const rti::apputils::FatalServiceException& ex) {
92 RTI_RoutingServiceEnvironment_fatal_error(
95 }
catch(
const std::exception& ex) {
96 RTI_RoutingServiceEnvironment_set_error(
110 RTI_RoutingServiceSessionExt* native()
112 return &this->native_;
116 void *native_session_data,
117 const struct RTI_RoutingServiceProperties * native_properties,
118 RTI_RoutingServiceEnvironment * environment)
120 SessionForwarder *forwarder =
121 static_cast<SessionForwarder*
> (native_session_data);
123 rti::routing::detail::UpdatableEntityForwarder::update(
130 SessionForwarder() : session_(NULL)
132 RTIOsapiMemory_zero(&native_,
sizeof(native_));
133 native_.session_data =
134 static_cast<void*
>(
this);
136 SessionForwarder::update;
144 RTI_RoutingServiceSessionExt native_;