OpenDDS::RTPS::RtpsDiscovery::Config Class Reference

#include <RtpsDiscovery.h>

List of all members.

Public Member Functions

int discovery_config (ACE_Configuration_Heap &cf)


Detailed Description

Definition at line 134 of file RtpsDiscovery.h.


Member Function Documentation

int OpenDDS::RTPS::RtpsDiscovery::Config::discovery_config ( ACE_Configuration_Heap &  cf  ) 

Definition at line 64 of file RtpsDiscovery.cpp.

References OpenDDS::DCPS::convertToInteger(), OpenDDS::RTPS::RtpsDiscovery::d0(), OpenDDS::RTPS::RtpsDiscovery::d1(), OpenDDS::RTPS::RtpsDiscovery::default_multicast_group(), OpenDDS::RTPS::RtpsDiscovery::dg(), OpenDDS::RTPS::RtpsDiscovery::dx(), OPENDDS_STRING, OpenDDS::RTPS::RtpsDiscovery::pb(), OpenDDS::RTPS::RtpsDiscovery::pg(), OpenDDS::DCPS::processSections(), OpenDDS::DCPS::pullValues(), OpenDDS::RTPS::RTPS_SECTION_NAME, OpenDDS::RTPS::RtpsDiscovery::RtpsDiscovery(), OpenDDS::RTPS::RtpsDiscovery::spdp_send_addrs(), OpenDDS::DCPS::RcHandle< T >::swap(), TheServiceParticipant, and OpenDDS::RTPS::RtpsDiscovery::ttl().

00065 {
00066   const ACE_Configuration_Section_Key &root = cf.root_section();
00067   ACE_Configuration_Section_Key rtps_sect;
00068 
00069   if (cf.open_section(root, RTPS_SECTION_NAME, 0, rtps_sect) == 0) {
00070 
00071     // Ensure there are no properties in this section
00072     DCPS::ValueMap vm;
00073     if (DCPS::pullValues(cf, rtps_sect, vm) > 0) {
00074       // There are values inside [rtps_discovery]
00075       ACE_ERROR_RETURN((LM_ERROR,
00076                         ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
00077                         ACE_TEXT("rtps_discovery sections must have a subsection name\n")),
00078                        -1);
00079     }
00080     // Process the subsections of this section (the individual rtps_discovery/*)
00081     DCPS::KeyList keys;
00082     if (DCPS::processSections(cf, rtps_sect, keys) != 0) {
00083       ACE_ERROR_RETURN((LM_ERROR,
00084                         ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
00085                         ACE_TEXT("too many nesting layers in the [rtps] section.\n")),
00086                        -1);
00087     }
00088 
00089     // Loop through the [rtps_discovery/*] sections
00090     for (DCPS::KeyList::const_iterator it = keys.begin();
00091          it != keys.end(); ++it) {
00092       const OPENDDS_STRING& rtps_name = it->first;
00093 
00094       int resend;
00095       u_short pb, dg, pg, d0, d1, dx;
00096       unsigned char ttl;
00097       AddrVec spdp_send_addrs;
00098       OPENDDS_STRING default_multicast_group = "239.255.0.1" /*RTPS v2.1 9.6.1.4.1*/;
00099       OPENDDS_STRING mi, sla;
00100       bool has_resend = false, has_pb = false, has_dg = false, has_pg = false,
00101         has_d0 = false, has_d1 = false, has_dx = false, has_sm = false,
00102         has_ttl = false, sm = false;
00103 
00104       DCPS::ValueMap values;
00105       DCPS::pullValues(cf, it->second, values);
00106       for (DCPS::ValueMap::const_iterator it = values.begin();
00107            it != values.end(); ++it) {
00108         const OPENDDS_STRING& name = it->first;
00109         if (name == "ResendPeriod") {
00110           const OPENDDS_STRING& value = it->second;
00111           has_resend = DCPS::convertToInteger(value, resend);
00112           if (!has_resend) {
00113             ACE_ERROR_RETURN((LM_ERROR,
00114               ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
00115               ACE_TEXT("Invalid entry (%C) for ResendPeriod in ")
00116               ACE_TEXT("[rtps_discovery/%C] section.\n"),
00117               value.c_str(), rtps_name.c_str()), -1);
00118           }
00119         } else if (name == "PB") {
00120           const OPENDDS_STRING& value = it->second;
00121           has_pb = DCPS::convertToInteger(value, pb);
00122           if (!has_pb) {
00123             ACE_ERROR_RETURN((LM_ERROR,
00124               ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
00125               ACE_TEXT("Invalid entry (%C) for PB in ")
00126               ACE_TEXT("[rtps_discovery/%C] section.\n"),
00127               value.c_str(), rtps_name.c_str()), -1);
00128           }
00129         } else if (name == "DG") {
00130           const OPENDDS_STRING& value = it->second;
00131           has_dg = DCPS::convertToInteger(value, dg);
00132           if (!has_dg) {
00133             ACE_ERROR_RETURN((LM_ERROR,
00134               ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
00135               ACE_TEXT("Invalid entry (%C) for DG in ")
00136               ACE_TEXT("[rtps_discovery/%C] section.\n"),
00137               value.c_str(), rtps_name.c_str()), -1);
00138           }
00139         } else if (name == "PG") {
00140           const OPENDDS_STRING& value = it->second;
00141           has_pg = DCPS::convertToInteger(value, pg);
00142           if (!has_pg) {
00143             ACE_ERROR_RETURN((LM_ERROR,
00144               ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
00145               ACE_TEXT("Invalid entry (%C) for PG in ")
00146               ACE_TEXT("[rtps_discovery/%C] section.\n"),
00147               value.c_str(), rtps_name.c_str()), -1);
00148           }
00149         } else if (name == "D0") {
00150           const OPENDDS_STRING& value = it->second;
00151           has_d0 = DCPS::convertToInteger(value, d0);
00152           if (!has_d0) {
00153             ACE_ERROR_RETURN((LM_ERROR,
00154               ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
00155               ACE_TEXT("Invalid entry (%C) for D0 in ")
00156               ACE_TEXT("[rtps_discovery/%C] section.\n"),
00157               value.c_str(), rtps_name.c_str()), -1);
00158           }
00159         } else if (name == "D1") {
00160           const OPENDDS_STRING& value = it->second;
00161           has_d1 = DCPS::convertToInteger(value, d1);
00162           if (!has_d1) {
00163             ACE_ERROR_RETURN((LM_ERROR,
00164               ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
00165               ACE_TEXT("Invalid entry (%C) for D1 in ")
00166               ACE_TEXT("[rtps_discovery/%C] section.\n"),
00167               value.c_str(), rtps_name.c_str()), -1);
00168           }
00169         } else if (name == "DX") {
00170           const OPENDDS_STRING& value = it->second;
00171           has_dx = DCPS::convertToInteger(value, dx);
00172           if (!has_dx) {
00173             ACE_ERROR_RETURN((LM_ERROR,
00174                ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
00175                ACE_TEXT("Invalid entry (%C) for DX in ")
00176                ACE_TEXT("[rtps_discovery/%C] section.\n"),
00177                value.c_str(), rtps_name.c_str()), -1);
00178           }
00179         } else if (name == "TTL") {
00180           const OPENDDS_STRING& value = it->second;
00181           unsigned short ttl_us;
00182           has_ttl = DCPS::convertToInteger(value, ttl_us);
00183           ttl = static_cast<unsigned char>(ttl_us);
00184           if (!has_ttl || ttl_us > UCHAR_MAX) {
00185             ACE_ERROR_RETURN((LM_ERROR,
00186                ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
00187                ACE_TEXT("Invalid entry (%C) for TTL in ")
00188                ACE_TEXT("[rtps_discovery/%C] section.\n"),
00189                value.c_str(), rtps_name.c_str()), -1);
00190           }
00191         } else if (name == "SedpMulticast") {
00192           const OPENDDS_STRING& value = it->second;
00193           int smInt;
00194           has_sm = DCPS::convertToInteger(value, smInt);
00195           if (!has_sm) {
00196             ACE_ERROR_RETURN((LM_ERROR,
00197                ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config ")
00198                ACE_TEXT("Invalid entry (%C) for SedpMulticast in ")
00199                ACE_TEXT("[rtps_discovery/%C] section.\n"),
00200                value.c_str(), rtps_name.c_str()), -1);
00201           }
00202           sm = bool(smInt);
00203         } else if (name == "MulticastInterface") {
00204           mi = it->second;
00205         } else if (name == "SedpLocalAddress") {
00206           sla = it->second;
00207         } else if (name == "InteropMulticastOverride") {
00208           /// FUTURE: handle > 1 group.
00209           default_multicast_group = it->second;
00210         } else if (name == "SpdpSendAddrs") {
00211           const OPENDDS_STRING& value = it->second;
00212           size_t i = 0;
00213           do {
00214             i = value.find_first_not_of(' ', i); // skip spaces
00215             const size_t n = value.find_first_of(", ", i);
00216             spdp_send_addrs.push_back(value.substr(i, (n == OPENDDS_STRING::npos) ? n : n - i));
00217             i = value.find(',', i);
00218           } while (i++ != OPENDDS_STRING::npos); // skip past comma if there is one
00219         } else {
00220           ACE_ERROR_RETURN((LM_ERROR,
00221                             ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
00222                             ACE_TEXT("Unexpected entry (%C) in [rtps_discovery/%C] section.\n"),
00223                             name.c_str(), rtps_name.c_str()),
00224                            -1);
00225         }
00226       }
00227 
00228       RtpsDiscovery_rch discovery = new RtpsDiscovery(rtps_name);
00229       if (has_resend) discovery->resend_period(ACE_Time_Value(resend));
00230       if (has_pb) discovery->pb(pb);
00231       if (has_dg) discovery->dg(dg);
00232       if (has_pg) discovery->pg(pg);
00233       if (has_d0) discovery->d0(d0);
00234       if (has_d1) discovery->d1(d1);
00235       if (has_dx) discovery->dx(dx);
00236       if (has_ttl) discovery->ttl(ttl);
00237       if (has_sm) discovery->sedp_multicast(sm);
00238       discovery->multicast_interface(mi);
00239       discovery->default_multicast_group( default_multicast_group);
00240       discovery->spdp_send_addrs().swap(spdp_send_addrs);
00241       discovery->sedp_local_address(sla);
00242       TheServiceParticipant->add_discovery(
00243         DCPS::static_rchandle_cast<Discovery>(discovery));
00244     }
00245   }
00246 
00247   // If the default RTPS discovery object has not been configured,
00248   // instantiate it now.
00249   const DCPS::Service_Participant::RepoKeyDiscoveryMap& discoveryMap = TheServiceParticipant->discoveryMap();
00250   if (discoveryMap.find(Discovery::DEFAULT_RTPS) == discoveryMap.end()) {
00251     RtpsDiscovery_rch discovery = new RtpsDiscovery(Discovery::DEFAULT_RTPS);
00252     TheServiceParticipant->add_discovery(
00253       DCPS::static_rchandle_cast<Discovery>(discovery));
00254   }
00255 
00256   return 0;
00257 }


The documentation for this class was generated from the following files:
Generated on Fri Feb 12 20:06:49 2016 for OpenDDS by  doxygen 1.4.7