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)
33 std::map<std::string, std::string> properties;
34 rti::routing::PropertyAdapter::add_properties_from_native(
38 SessionForwarder *forwarder =
new SessionForwarder();
39 ScopedForwarder<Connection, SessionForwarder> scoped(
45 forwarder->session_ = connection->create_session(properties);
48 return forwarder->native();
49 }
catch(
const std::exception& ex) {
50 RTI_RoutingServiceEnvironment_set_error(
56 RTI_RoutingServiceEnvironment_set_error(
58 "unexpected exception");
64 static void delete_native(
65 Connection *connection,
66 RTI_RoutingServiceSessionExt *native_session,
67 RTI_RoutingServiceEnvironment *environment)
69 SessionForwarder *forwarder =
static_cast<SessionForwarder*
>(
70 native_session->session_data);
73 if (forwarder->session_ != NULL) {
74 connection->delete_session(forwarder->session_);
75 forwarder->session_ = NULL;
78 }
catch(
const std::exception& ex) {
79 RTI_RoutingServiceEnvironment_set_error(
94 RTI_RoutingServiceSessionExt* native()
96 return &this->native_;
100 void *native_session_data,
101 const struct RTI_RoutingServiceProperties * native_properties,
102 RTI_RoutingServiceEnvironment * environment)
104 SessionForwarder *forwarder =
105 static_cast<SessionForwarder*
> (native_session_data);
107 rti::routing::detail::UpdatableEntityForwarder::update(
114 SessionForwarder() : session_(NULL)
116 RTIOsapiMemory_zero(&native_,
sizeof(native_));
117 native_.session_data =
118 static_cast<void*
>(
this);
120 SessionForwarder::update;
128 RTI_RoutingServiceSessionExt native_;
135 #endif // RTI_ROUTING_ADAPTER_DETAIL_SESSION_FORWARDER_HPP_