11 #ifndef RTI_ROUTING_ROUTING_SERVICE_PROPERTY_HPP_
12 #define RTI_ROUTING_ROUTING_SERVICE_PROPERTY_HPP_
16 #include <dds/core/macros.hpp>
17 #include <rti/core/NativeValueType.hpp>
19 #include "routingservice/routingservice_service.h"
20 #include <rti/routing/detail/ForwarderUtils.hpp>
22 namespace rti {
namespace routing {
24 class PropertyAdapter {
26 typedef RTI_RoutingServiceProperty native_type;
28 static void initialize(native_type& native_value)
30 static const native_type DEFAULT
31 = RTI_RoutingServiceProperty_INITIALIZER;
32 native_value = DEFAULT;
33 native_value.service_verbosity = -1;
34 native_value.dds_verbosity = -1;
37 static void finalize(native_type& native_value)
39 if (native_value.cfg_strings != NULL) {
40 RTIOsapiHeap_freeArray(native_value.cfg_strings);
41 native_value.cfg_strings = NULL;
44 RTI_RoutingServiceProperty_finalize(&native_value);
47 static void copy(native_type& destination,
const native_type& source)
49 RTIOsapiUtility_unusedParameter(destination);
50 RTIOsapiUtility_unusedParameter(source);
52 throw dds::core::UnsupportedError(
"Unsupported operation: copy");
55 static bool equals(
const native_type& first,
const native_type& second)
57 RTIOsapiUtility_unusedParameter(first);
58 RTIOsapiUtility_unusedParameter(second);
60 throw dds::core::UnsupportedError(
"Unsupported operation: equals");
63 static void add_properties_from_native(
64 std::map<std::string, std::string>& properties,
65 const RTI_RoutingServiceProperties *native_properties)
67 for (
int i = 0; i < native_properties->count; i++) {
68 properties[native_properties->properties[i].name] =
69 (
const char *) native_properties->properties[i].value;
73 static void add_properties_to_native(
74 RTI_RoutingServiceProperties *native_properties,
75 const std::map<std::string, std::string>& properties)
77 RTI_RoutingServiceProperties_finalize(native_properties);
78 RTI_RoutingServiceProperties_initialize(native_properties);
80 std::map<std::string, std::string>::const_iterator it = properties.begin();
81 for (; it != properties.end(); ++it) {
82 if (!RTI_RoutingServiceProperties_add(
85 it->second.c_str())) {
86 throw dds::core::Error(
"failed to add native property");
93 class ServiceProperty;
100 struct native_type_traits<rti::routing::ServiceProperty> {
101 typedef rti::routing::PropertyAdapter adapter_type;
102 typedef RTI_RoutingServiceProperty native_type;
118 typedef rti::core::NativeValueType<ServiceProperty> Base;
127 ServiceProperty(
const struct RTI_RoutingServiceProperty &native_property)
128 : Base(native_property)
138 return native().cfg_file == NULL ?
"" : native().cfg_file;
177 const std::vector<std::string>& the_cfg_strings)
179 cfg_strings_ = the_cfg_strings;
180 if (cfg_strings_.size() > 0) {
181 if (!RTIOsapiHeap_reallocateArray(
185 throw dds::core::OutOfResourcesError(
"cfg_strings native array");
187 for (uint32_t i = 0; i < cfg_strings_.size(); i++) {
188 native().cfg_strings[i] = cfg_strings_[i].c_str();
191 native().cfg_strings_count =
static_cast<int>(cfg_strings_.size());
201 return native().service_name == NULL ?
"" : native().service_name;
227 return native().application_name;
279 return native().domain_id_base;
292 native().domain_id_base = domain_id;
301 return native().plugin_search_path == NULL
303 : native().plugin_search_path;
343 native().dont_start_service = not_start
367 native().enable_administration = enable
378 return native().administration_domain_id;
393 native().administration_domain_id = domain_id;
402 return native().enable_monitoring == DDS_BOOLEAN_TRUE
415 native().enable_monitoring = enable
426 return native().monitoring_domain_id;
441 native().monitoring_domain_id = domain_id;
466 native().skip_default_files = skip
493 native().identify_execution = identify
504 return native().license_file_name == NULL?
""
505 : native().license_file_name;
530 std::map<std::string, std::string> properties;
532 PropertyAdapter::add_properties_from_native(
550 rti::routing::PropertyAdapter::add_properties_to_native(
551 &native().user_environment,
558 std::vector<std::string> cfg_strings_;
563 #endif // RTI_ROUTING_ROUTING_SERVICE_PROPERTY_HPP_