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>
20 namespace rti {
namespace routing {
namespace adapter {
namespace detail {
23 class 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);
50 return forwarder->native();
51 }
catch(
const std::exception& ex) {
52 RTI_RoutingServiceEnvironment_set_error(
58 RTI_RoutingServiceEnvironment_set_error(
60 "unexpected exception");
66 static void delete_native(
67 Connection *connection,
68 RTI_RoutingServiceSessionExt *native_session,
69 RTI_RoutingServiceEnvironment *environment)
71 SessionForwarder *forwarder =
static_cast<SessionForwarder*
>(
72 native_session->session_data);
75 if (forwarder->session_ != NULL) {
76 connection->delete_session(forwarder->session_);
77 forwarder->session_ = NULL;
80 }
catch(
const std::exception& ex) {
81 RTI_RoutingServiceEnvironment_set_error(
96 RTI_RoutingServiceSessionExt* native()
98 return &this->native_;
102 void *native_session_data,
103 const struct RTI_RoutingServiceProperties * native_properties,
104 RTI_RoutingServiceEnvironment * environment)
106 SessionForwarder *forwarder =
107 static_cast<SessionForwarder*
> (native_session_data);
109 rti::routing::detail::UpdatableEntityForwarder::update(
116 SessionForwarder() : session_(NULL)
118 RTIOsapiMemory_zero(&native_,
sizeof(native_));
119 native_.session_data =
120 static_cast<void*
>(
this);
122 SessionForwarder::update;
130 RTI_RoutingServiceSessionExt native_;
137 #endif // RTI_ROUTING_ADAPTER_DETAIL_SESSION_FORWARDER_HPP_