RTI Cloud Discovery Service Version 7.3.0
ServiceProperty.hpp
1
10#ifndef RTI_CDS_CLOUD_DISCOVERY_SERVICE_PROPERTY_HPP_
11#define RTI_CDS_CLOUD_DISCOVERY_SERVICE_PROPERTY_HPP_
12
17#include <dds/core/macros.hpp>
18#include <rti/core/NativeValueType.hpp>
19
20#include "clouddiscoveryservice/clouddiscoveryservice_infrastructure.h"
21#include "clouddiscoveryservice/clouddiscoveryservice_service.h"
22
23namespace rti { namespace cds {
24
31public:
32 DomainListProperty() : allow_domain_ids_(""), deny_domain_ids_("")
33 {
34 }
35
37 {
38 allow_domain_ids_ = allow_domain_ids;
39 deny_domain_ids_ = deny_domain_ids;
40 }
41
49 {
50 allow_domain_ids_ = allow_domain_ids;
51 }
52
56 std::string& allow_domain_ids()
57 {
58 return allow_domain_ids_;
59 }
60
68 {
69 deny_domain_ids_ = deny_domain_ids;
70 }
71
75 std::string& deny_domain_ids()
76 {
77 return deny_domain_ids_;
78 }
79
80private:
81 std::string allow_domain_ids_;
82 std::string deny_domain_ids_;
83};
84
95public:
97 {
98 alias_ = alias;
99 receive_port_ = receive_port;
100 }
101
105 void alias(std::string alias)
106 {
107 alias_ = alias;
108 }
109
113 std::string& alias()
114 {
115 return alias_;
116 }
117
122 {
123 receive_port_ = receive_port;
124 }
125
130 {
131 return receive_port_;
132 }
133
134private:
135 std::string alias_;
136 int receive_port_;
137};
138
139class PropertyAdapter {
140public:
141 typedef RTI_CDS_Property native_type;
142
143 static void initialize(native_type& native_value)
144 {
145 static const native_type DEFAULT
146 = RTI_CDS_Property_INITIALIZER;
147 native_value = DEFAULT;
148 // Replicating the defaults from the C Library API as specified in service.ifc
149 native_value.service_verbosity = RTI_LOG_BIT_EXCEPTION;
150 native_value.dds_verbosity = RTI_LOG_BIT_EXCEPTION;
151 }
152
153 static void finalize(native_type& native_value)
154 {
155 if (native_value.cfg_strings != NULL) {
156 RTIOsapiHeap_freeArray(native_value.cfg_strings);
157 native_value.cfg_strings = NULL;
158 }
159
160 RTI_CDS_Property_finalize(&native_value);
161 }
162
163 static void copy(native_type& destination, const native_type& source)
164 {
165 if (RTI_CDS_Property_copy(&destination, &source) == NULL) {
166 throw dds::core::Error("Native RTI_CDS_Property_copy");
167 }
168 }
169
170 static bool equals(const native_type& first, const native_type& second)
171 {
172 RTIOsapiUtility_unusedParameter(first);
173 RTIOsapiUtility_unusedParameter(second);
174
175 throw dds::core::UnsupportedError("Unsupported operation: equals");
176 }
177
178 static void add_transports_from_native(
179 std::vector<TransportUnicastProperty>& transport_selection,
180 const struct RTI_CDS_TransportSelectionProperty *transport_selection_native)
181 {
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));
186 }
187 }
188
189 static void add_transports_to_native(
190 struct RTI_CDS_TransportSelectionProperty *transport_selection_native,
191 std::vector<TransportUnicastProperty>& transport_selection)
192 {
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();
201 }
202 }
203
204 static void add_domain_list_from_native(
205 DomainListProperty& domain_ids,
206 const struct RTI_CDS_DomainListProperty *domain_ids_native)
207 {
208 domain_ids.allow_domain_ids(domain_ids_native->allow_domain_ids);
209 domain_ids.deny_domain_ids(domain_ids_native->deny_domain_ids);
210 }
211
212 static void add_domain_list_to_native(
213 struct RTI_CDS_DomainListProperty *domain_ids_native,
214 DomainListProperty& domain_ids)
215 {
216 DDS_String_replace(
217 &domain_ids_native->allow_domain_ids,
218 domain_ids.allow_domain_ids().c_str());
219 DDS_String_replace(
220 &domain_ids_native->deny_domain_ids,
221 domain_ids.deny_domain_ids().c_str());
222 }
223
224 static void add_properties_from_native(
225 std::map<std::string, std::string>& properties,
226 const RTI_RoutingServiceProperties *native_properties)
227 {
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;
231 }
232 }
233
234 static void add_properties_to_native(
235 RTI_RoutingServiceProperties *native_properties,
236 const std::map<std::string, std::string>& properties)
237 {
238 RTI_RoutingServiceProperties_finalize(native_properties);
239 if (!RTI_RoutingServiceProperties_initialize(native_properties)) {
240 throw dds::core::Error("failed to initialize native property");
241 }
242
243 std::map<std::string, std::string>::const_iterator it = properties.begin();
244 for (; it != properties.end(); ++it) {
245 if (!RTI_RoutingServiceProperties_add(
246 native_properties,
247 it->first.c_str(),
248 it->second.c_str())) {
249 throw dds::core::Error("failed to add native property");
250 }
251 }
252 }
253};
254
255class ServiceProperty;
256
257}
258
259namespace core {
260
261template<>
262struct native_type_traits<rti::cds::ServiceProperty> {
263 typedef rti::cds::PropertyAdapter adapter_type;
264 typedef RTI_CDS_Property native_type;
265};
266
267}
268
269namespace cds {
270
276class ServiceProperty : public rti::core::NativeValueType<ServiceProperty>
277{
278public:
279 RTI_NATIVE_VALUE_TYPE_DEFINE_DEFAULT_MOVE_OPERATIONS(ServiceProperty)
280
281 typedef rti::core::NativeValueType<ServiceProperty> Base;
282
287 {
288 }
289
290 ServiceProperty(const struct RTI_CDS_Property &native_property)
291 : Base(native_property)
292 {
293 }
294
298 std::string cfg_file() const
299 {
300 return native().cfg_file == NULL ? "" : native().cfg_file;
301 }
302
308 ServiceProperty& cfg_file(const std::string& filename)
309 {
310 DDS_String_replace(
311 &native().cfg_file,
312 filename.c_str());
313 return *this;
314 }
315
319 const std::vector<std::string>& cfg_strings() const
320 {
321 return cfg_strings_;
322 }
323
339 const std::vector<std::string>& the_cfg_strings)
340 {
341 cfg_strings_ = the_cfg_strings;
342 if (cfg_strings_.size() > 0) {
343 if (!RTIOsapiHeap_reallocateArray(
344 (char ***) &native().cfg_strings,
345 cfg_strings_.size(),
346 char *)) {
347 throw dds::core::OutOfResourcesError("cfg_strings native array");
348 }
349
350 for (uint32_t i = 0; i < cfg_strings_.size(); i++) {
351 native().cfg_strings[i] = cfg_strings_[i].c_str();
352 }
353 }
354 native().cfg_strings_count = static_cast<int>(cfg_strings_.size());
355
356 return *this;
357 }
358
362 std::string service_name() const
363 {
364 return native().service_name == NULL ? "" : native().service_name;
365 }
366
377 ServiceProperty& service_name(const std::string& name)
378 {
379 DDS_String_replace(&native().service_name, name.c_str());
380 return *this;
381 }
382
386 std::string application_name() const
387 {
388 return native().application_name == NULL ? "" : native().application_name;
389 }
390
399 ServiceProperty& application_name(const std::string& name)
400 {
401 DDS_String_replace(&native().application_name, name.c_str());
402 return *this;
403 }
404
409 {
410 return (native().enforce_xsd_validation == DDS_BOOLEAN_TRUE)
411 ? true
412 : false;
413 }
414
422 {
424 return *this;
425 }
426
431 {
432 return (native().skip_default_files == DDS_BOOLEAN_TRUE)
433 ? true
434 : false;
435 }
436
447 {
448 native().skip_default_files = skip
449 ? DDS_BOOLEAN_TRUE
450 : DDS_BOOLEAN_FALSE;
451 return *this;
452 }
453
457 std::vector<TransportUnicastProperty> transport_selection()
458 {
459 PropertyAdapter::add_transports_from_native(
460 transport_selection_,
461 &native().transport_selection);
462
463 return transport_selection_;
464 }
465
475 const std::vector<TransportUnicastProperty>& transport_selection)
476 {
477 transport_selection_ = transport_selection;
478 PropertyAdapter::add_transports_to_native(
479 &native().transport_selection,
480 transport_selection_);
481
482 return *this;
483 }
484
489 {
490 PropertyAdapter::add_domain_list_from_native(
491 domain_list_,
492 &native().domain_list);
493
494 return domain_list_;
495 }
496
505 {
506 domain_list_ = domain_list;
507 PropertyAdapter::add_domain_list_to_native(
508 &native().domain_list,
509 domain_list_);
510
511 return *this;
512 }
513
518 {
519 return (native().enable_administration == DDS_BOOLEAN_TRUE)
520 ? true
521 : false;
522 }
523
531 {
532 native().enable_administration = enable
533 ? DDS_BOOLEAN_TRUE
534 : DDS_BOOLEAN_FALSE;
535 return *this;
536 }
537
542 {
543 return native().administration_domain_id;
544 }
545
557 {
558 native().administration_domain_id = domain_id;
559 return *this;
560 }
561
565 bool enable_monitoring() const
566 {
567 return (native().enable_monitoring == DDS_BOOLEAN_TRUE)
568 ? true
569 : false;
570 }
571
578 {
579 native().enable_monitoring = enable
580 ? DDS_BOOLEAN_TRUE
581 : DDS_BOOLEAN_FALSE;
582 return *this;
583 }
584
589 {
590 return native().monitoring_domain_id;
591 }
592
604 {
605 native().monitoring_domain_id = domain_id;
606 return *this;
607 }
608
612 std::string license_file_name() const
613 {
614 return native().license_file_name == NULL
615 ? ""
616 : native().license_file_name;
617 }
618
628 ServiceProperty& license_file_name(const std::string& file_name)
629 {
630 DDS_String_replace(
631 &native().license_file_name,
632 file_name.c_str());
633 return *this;
634 }
635
639 std::map<std::string, std::string> user_environment() const
640 {
641 std::map<std::string, std::string> properties;
642
643 PropertyAdapter::add_properties_from_native(
644 properties,
645 &native().user_environment);
646
647 return properties;
648 }
649
660 const std::map<std::string, std::string>& user_environment)
661 {
662 PropertyAdapter::add_properties_to_native(
663 &native().user_environment,
665
666 return *this;
667 }
668
669private:
670 std::vector<std::string> cfg_strings_;
671 std::vector<TransportUnicastProperty> transport_selection_;
672 DomainListProperty domain_list_;
673
674};
675
676}}
677
678#endif // RTI_CDS_CLOUD_DISCOVERY_SERVICE_PROPERTY_HPP_
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