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/routing/adapter/Connection.hpp>
17#include <rti/routing/detail/UpdatableEntityForwarder.hpp>
18#include <rti/routing/detail/ForwarderUtils.hpp>
20namespace rti {
namespace routing {
namespace adapter {
namespace detail {
23class SessionForwarder {
25 static RTI_RoutingServiceSessionExt* create_native(
26 Connection *connection,
27 const RTI_RoutingServiceProperties *native_properties,
28 RTI_RoutingServiceEnvironment *environment)
32 using rti::routing::detail::ScopedForwarder;
35 std::map<std::string, std::string> properties;
36 rti::routing::PropertyAdapter::add_properties_from_native(
40 SessionForwarder *forwarder =
new SessionForwarder();
41 ScopedForwarder<Connection, SessionForwarder> scoped(
47 forwarder->session_ = connection->create_session(properties);
56 return forwarder->native();
57 }
catch(
const std::exception& ex) {
58 RTI_RoutingServiceEnvironment_set_error(
64 RTI_RoutingServiceEnvironment_set_error(
66 "unexpected exception");
71 static void delete_native(
72 Connection *connection,
73 RTI_RoutingServiceSessionExt *native_session,
74 RTI_RoutingServiceEnvironment *environment)
76 SessionForwarder *forwarder =
static_cast<SessionForwarder*
>(
77 native_session->session_data);
80 if (forwarder->session_ != NULL) {
81 connection->delete_session(forwarder->session_);
82 forwarder->session_ = NULL;
85 }
catch(
const std::exception& ex) {
86 RTI_RoutingServiceEnvironment_set_error(
101 RTI_RoutingServiceSessionExt* native()
103 return &this->native_;
107 void *native_session_data,
108 const struct RTI_RoutingServiceProperties * native_properties,
109 RTI_RoutingServiceEnvironment * environment)
111 SessionForwarder *forwarder =
112 static_cast<SessionForwarder*
> (native_session_data);
114 rti::routing::detail::UpdatableEntityForwarder::update(
121 SessionForwarder() : session_(NULL)
123 RTIOsapiMemory_zero(&native_,
sizeof(native_));
124 native_.session_data =
125 static_cast<void*
>(
this);
127 SessionForwarder::update;
135 RTI_RoutingServiceSessionExt native_;