11 #ifndef RTI_ROUTING_DETAIL_FORWARDER_UTILS_UTILS_HPP_
12 #define RTI_ROUTING_DETAIL_FORWARDER_UTILS_UTILS_HPP_
16 #include <dds/topic/Topic.hpp>
17 #include <rti/core/Exception.hpp>
18 #include <routingservice/routingservice_infrastructure.h>
20 namespace rti {
namespace routing {
namespace detail {
22 #define RTI_ROUTING_THROW_ON_NULL(pointer) \
23 if ((pointer) == NULL) { \
24 throw dds::core::Error("invalid return of NULL"); \
27 #define RTI_ROUTING_THROW_ON_ENV_ERROR(NATIVE_ENV) \
28 if (RTI_RoutingServiceEnvironment_error_occurred((NATIVE_ENV))) { \
29 dds::core::Error rex( \
30 RTI_RoutingServiceEnvironment_get_error_message((NATIVE_ENV))); \
31 RTI_RoutingServiceEnvironment_clear_error((NATIVE_ENV)); \
35 #define RTI_ROUTING_SAMPLE_VECTOR_COPY_FROM_NATIVE( \
39 (VECTOR).resize((ARRAY_LENGTH)); \
40 memcpy(&((VECTOR)[0]), \
42 sizeof (void*) * (ARRAY_LENGTH));
44 #define RTI_ROUTING_SAMPLE_VECTOR_COPY_FROM_NATIVE_W_OFFSET( \
49 (VECTOR).resize((ARRAY_LENGTH) + (OFFSET)); \
50 memcpy(&((VECTOR)[OFFSET]), \
52 sizeof (void*) * (ARRAY_LENGTH));
55 #define RTI_ROUTING_SAMPLE_VECTOR_COPY_PTRS( \
58 (TO_VECTOR).resize((FROM_VECTOR).size()); \
59 memcpy(&(TO_VECTOR[0]), &(FROM_VECTOR)[0], sizeof(void*) * (FROM_VECTOR).size());
62 template <
typename OwnerType,
typename ForwarderType>
63 struct ScopedForwarder {
67 ForwarderType *forwarder,
68 RTI_RoutingServiceEnvironment *environment)
69 :owner_(owner), forwarder_(forwarder), environment_(environment)
80 if (forwarder_ != NULL) {
81 ForwarderType::delete_native(owner_, forwarder_->native(), environment_);
87 ForwarderType *forwarder_;
88 RTI_RoutingServiceEnvironment *environment_;
96 #endif // RTI_ROUTING_DETAIL_FORWARDER_UTILS_UTILS_HPP_