10#ifndef RTI_CDS_CLOUD_DISCOVERY_SERVICE_PROPERTY_HPP_
11#define RTI_CDS_CLOUD_DISCOVERY_SERVICE_PROPERTY_HPP_
17#include <dds/core/macros.hpp>
18#include <rti/core/NativeValueType.hpp>
20#include "clouddiscoveryservice/clouddiscoveryservice_infrastructure.h"
21#include "clouddiscoveryservice/clouddiscoveryservice_service.h"
23namespace rti {
namespace cds {
58 return allow_domain_ids_;
77 return deny_domain_ids_;
81 std::string allow_domain_ids_;
82 std::string deny_domain_ids_;
131 return receive_port_;
139class PropertyAdapter {
141 typedef RTI_CDS_Property native_type;
143 static void initialize(native_type& native_value)
145 static const native_type DEFAULT
146 = RTI_CDS_Property_INITIALIZER;
147 native_value = DEFAULT;
149 native_value.service_verbosity = RTI_LOG_BIT_EXCEPTION;
150 native_value.dds_verbosity = RTI_LOG_BIT_EXCEPTION;
153 static void finalize(native_type& native_value)
155 if (native_value.cfg_strings != NULL) {
156 RTIOsapiHeap_freeArray(native_value.cfg_strings);
157 native_value.cfg_strings = NULL;
160 RTI_CDS_Property_finalize(&native_value);
163 static void copy(native_type& destination,
const native_type& source)
165 if (RTI_CDS_Property_copy(&destination, &source) == NULL) {
166 throw dds::core::Error(
"Native RTI_CDS_Property_copy");
170 static bool equals(
const native_type& first,
const native_type& second)
172 RTIOsapiUtility_unusedParameter(first);
173 RTIOsapiUtility_unusedParameter(second);
175 throw dds::core::UnsupportedError(
"Unsupported operation: equals");
178 static void add_transports_from_native(
179 std::vector<TransportUnicastProperty>& transport_selection,
180 const struct RTI_CDS_TransportSelectionProperty *transport_selection_native)
182 for (
int i = 0; i < transport_selection_native->count; i++) {
183 transport_selection.push_back(TransportUnicastProperty(
184 transport_selection_native->transports[i].alias,
185 transport_selection_native->transports[i].receive_port));
189 static void add_transports_to_native(
190 struct RTI_CDS_TransportSelectionProperty *transport_selection_native,
191 std::vector<TransportUnicastProperty>& transport_selection)
193 transport_selection_native->count = transport_selection.size();
194 for (
unsigned int i = 0; i < transport_selection.size(); i++) {
195 RTIOsapiUtility_strcpy(
196 transport_selection_native->transports[i].alias,
197 RTI_CDS_TRANSPORT_UNICAST_PROPERTY_ALIAS_LENGTH_MAX,
198 transport_selection[i].alias().c_str());
199 transport_selection_native->transports[i].receive_port
200 = transport_selection[i].receive_port();
204 static void add_domain_list_from_native(
205 DomainListProperty& domain_ids,
206 const struct RTI_CDS_DomainListProperty *domain_ids_native)
208 domain_ids.allow_domain_ids(domain_ids_native->allow_domain_ids);
209 domain_ids.deny_domain_ids(domain_ids_native->deny_domain_ids);
212 static void add_domain_list_to_native(
213 struct RTI_CDS_DomainListProperty *domain_ids_native,
214 DomainListProperty& domain_ids)
217 &domain_ids_native->allow_domain_ids,
218 domain_ids.allow_domain_ids().c_str());
220 &domain_ids_native->deny_domain_ids,
221 domain_ids.deny_domain_ids().c_str());
224 static void add_properties_from_native(
225 std::map<std::string, std::string>& properties,
226 const RTI_RoutingServiceProperties *native_properties)
228 for (
int i = 0; i < native_properties->count; i++) {
229 properties[native_properties->properties[i].name] =
230 (
const char *) native_properties->properties[i].value;
234 static void add_properties_to_native(
235 RTI_RoutingServiceProperties *native_properties,
236 const std::map<std::string, std::string>& properties)
238 RTI_RoutingServiceProperties_finalize(native_properties);
239 if (!RTI_RoutingServiceProperties_initialize(native_properties)) {
240 throw dds::core::Error(
"failed to initialize native property");
243 std::map<std::string, std::string>::const_iterator it = properties.begin();
244 for (; it != properties.end(); ++it) {
245 if (!RTI_RoutingServiceProperties_add(
248 it->second.c_str())) {
249 throw dds::core::Error(
"failed to add native property");
255class ServiceProperty;
262struct native_type_traits<
rti::cds::ServiceProperty> {
263 typedef rti::cds::PropertyAdapter adapter_type;
264 typedef RTI_CDS_Property native_type;
281 typedef rti::core::NativeValueType<ServiceProperty> Base;
291 : Base(native_property)
300 return native().cfg_file == NULL ?
"" : native().cfg_file;
339 const std::vector<std::string>& the_cfg_strings)
341 cfg_strings_ = the_cfg_strings;
342 if (cfg_strings_.size() > 0) {
343 if (!RTIOsapiHeap_reallocateArray(
347 throw dds::core::OutOfResourcesError(
"cfg_strings native array");
350 for (uint32_t i = 0; i < cfg_strings_.size(); i++) {
351 native().cfg_strings[i] = cfg_strings_[i].c_str();
354 native().cfg_strings_count =
static_cast<int>(cfg_strings_.size());
364 return native().service_name == NULL ?
"" : native().service_name;
379 DDS_String_replace(&native().
service_name, name.c_str());
388 return native().application_name == NULL ?
"" : native().application_name;
459 PropertyAdapter::add_transports_from_native(
460 transport_selection_,
463 return transport_selection_;
478 PropertyAdapter::add_transports_to_native(
480 transport_selection_);
490 PropertyAdapter::add_domain_list_from_native(
507 PropertyAdapter::add_domain_list_to_native(
543 return native().administration_domain_id;
590 return native().monitoring_domain_id;
614 return native().license_file_name == NULL
616 : native().license_file_name;
641 std::map<std::string, std::string> properties;
643 PropertyAdapter::add_properties_from_native(
662 PropertyAdapter::add_properties_to_native(
670 std::vector<std::string> cfg_strings_;
671 std::vector<TransportUnicastProperty> transport_selection_;
Specifies the list of domain IDs to allow or deny. Overrides XML configuration if specified.
Definition: ServiceProperty.hpp:30
void deny_domain_ids(std::string deny_domain_ids)
The list of domain IDs to deny or ignore. Overrides allow_domain_ids.
Definition: ServiceProperty.hpp:67
void allow_domain_ids(std::string allow_domain_ids)
The list of domain IDs where RTI Cloud Discovery Service processes the incoming participant announcem...
Definition: ServiceProperty.hpp:48
std::string & allow_domain_ids()
Getter (see setter with the same name)
Definition: ServiceProperty.hpp:56
std::string & deny_domain_ids()
Getter (see setter with the same name)
Definition: ServiceProperty.hpp:75
Configuration properties for a RTI Cloud Discovery Service object.
Definition: ServiceProperty.hpp:277
ServiceProperty & administration_domain_id(const int domain_id)
If ServiceProperty::enable_administration is true, this is the domain ID to use for remote administra...
Definition: ServiceProperty.hpp:556
ServiceProperty & enable_monitoring(const bool enable)
Set this to true to enable monitoring or false to disable it.
Definition: ServiceProperty.hpp:577
ServiceProperty()
Creates a property object with default settings.
Definition: ServiceProperty.hpp:286
bool enable_administration() const
Getter (see setter with the same name)
Definition: ServiceProperty.hpp:517
ServiceProperty & application_name(const std::string &name)
Assigns a name to the execution of the RTI Cloud Discovery Service.
Definition: ServiceProperty.hpp:399
bool enforce_xsd_validation() const
Getter (see setter with the same name)
Definition: ServiceProperty.hpp:408
std::string cfg_file() const
Getter (see setter with the same name)
Definition: ServiceProperty.hpp:298
ServiceProperty & domain_list(const DomainListProperty &domain_list)
Specifies the set of domain IDs the service will accept announcements from.
Definition: ServiceProperty.hpp:503
ServiceProperty & transport_selection(const std::vector< TransportUnicastProperty > &transport_selection)
Specifies the transport and receive ports used to receive and send discovery traffic....
Definition: ServiceProperty.hpp:474
const std::vector< std::string > & cfg_strings() const
Getter (see setter with the same name)
Definition: ServiceProperty.hpp:319
ServiceProperty & service_name(const std::string &name)
The name of the RTI Cloud Discovery Service configuration to run.
Definition: ServiceProperty.hpp:377
int administration_domain_id() const
Getter (see setter with the same name)
Definition: ServiceProperty.hpp:541
std::string application_name() const
Getter (see setter with the same name)
Definition: ServiceProperty.hpp:386
ServiceProperty & user_environment(const std::map< std::string, std::string > &user_environment)
Dictionary of user variables.
Definition: ServiceProperty.hpp:659
int monitoring_domain_id() const
Getter (see setter with the same name)
Definition: ServiceProperty.hpp:588
ServiceProperty & monitoring_domain_id(const int domain_id)
If ServiceProperty::enable_monitoring is true, this is the domain ID to use for publishing monitoring...
Definition: ServiceProperty.hpp:603
ServiceProperty & cfg_file(const std::string &filename)
Path to an RTI Cloud Discovery Service configuration file.
Definition: ServiceProperty.hpp:308
DomainListProperty domain_list()
Getter (see setter with the same name)
Definition: ServiceProperty.hpp:488
ServiceProperty & enforce_xsd_validation(const bool enforce_xsd_validation)
Controls whether the service applies XSD validation to the loaded configuration.
Definition: ServiceProperty.hpp:421
std::string service_name() const
Getter (see setter with the same name)
Definition: ServiceProperty.hpp:362
std::map< std::string, std::string > user_environment() const
Getter (see setter with the same name)
Definition: ServiceProperty.hpp:639
ServiceProperty & enable_administration(const bool enable)
Set this to true to enable remote administration or false to disable it.
Definition: ServiceProperty.hpp:530
std::vector< TransportUnicastProperty > transport_selection()
Getter (see setter with the same name)
Definition: ServiceProperty.hpp:457
std::string license_file_name() const
Getter (see setter with the same name)
Definition: ServiceProperty.hpp:612
bool skip_default_files() const
Getter (see setter with the same name)
Definition: ServiceProperty.hpp:430
ServiceProperty & skip_default_files(const bool &skip)
Set it to true to avoid loading the standard files usually loaded by RTI Cloud Discovery Service.
Definition: ServiceProperty.hpp:446
bool enable_monitoring() const
Getter (see setter with the same name)
Definition: ServiceProperty.hpp:565
ServiceProperty & license_file_name(const std::string &file_name)
Path to an RTI Cloud Discovery Service license file.
Definition: ServiceProperty.hpp:628
ServiceProperty & cfg_strings(const std::vector< std::string > &the_cfg_strings)
XML configuration represented as strings.
Definition: ServiceProperty.hpp:338
Specifies the alias name of the transport to be used by RTI Cloud Discovery Service for sending or re...
Definition: ServiceProperty.hpp:94
std::string & alias()
Getter (see setter with the same name)
Definition: ServiceProperty.hpp:113
void alias(std::string alias)
Transport alias name.
Definition: ServiceProperty.hpp:105
void receive_port(int receive_port)
Receive port.
Definition: ServiceProperty.hpp:121
int receive_port()
Getter (see setter with the same name)
Definition: ServiceProperty.hpp:129
Definition: CloudDiscoveryServiceImpl.hpp:20