1818
1919#include < tinyxml2.h>
2020
21- #include < fastrtps/xmlparser/XMLProfileManager.h >
22-
21+ #include < fastdds/dds/domain/DomainParticipant.hpp >
22+ # include < fastdds/rtps/RTPSDomain.h >
2323#include < fastdds/rtps/transport/UDPv4TransportDescriptor.h>
2424#include < fastdds/rtps/transport/TCPv4TransportDescriptor.h>
2525#include < fastdds/rtps/transport/TCPv6TransportDescriptor.h>
@@ -104,13 +104,25 @@ DiscoveryServerManager::DiscoveryServerManager(
104104 for (auto child = doc.FirstChildElement (s_sDS.c_str ());
105105 child != nullptr ; child = child->NextSiblingElement (s_sDS.c_str ()))
106106 {
107- // first make XMLProfileManager:: loadProfiles parse the config file. Afterwards loaded info is accessible
108- // through XMLProfileManager::fillParticipantAttributes and related
107+ // first make loadProfiles parse the config file. Afterwards loaded info is accessible
108+ // through get_participant_qos_from_profile() and related
109109
110110 tinyxml2::XMLElement* profiles = child->FirstChildElement (DSxmlparser::PROFILES );
111111 if (profiles != nullptr )
112112 {
113- loadProfiles (profiles);
113+ tinyxml2::XMLPrinter printer;
114+ profiles->Accept (&printer);
115+ std::string xmlString = R"( ")" + std::string (printer.CStr ()) + R"( ")" ;
116+ if (ReturnCode_t::RETCODE_OK ==
117+ DomainParticipantFactory::get_instance ()->load_XML_profiles_string (xmlString.c_str (),
118+ std::string (printer.CStr ()).length ()))
119+ {
120+ LOG_INFO (" Profiles parsed successfully." );
121+ }
122+ else
123+ {
124+ LOG_ERROR (" Error parsing profiles!" );
125+ }
114126 }
115127
116128 // Server processing requires a two pass analysis
@@ -670,21 +682,6 @@ Topic* DiscoveryServerManager::getParticipantTopicByName(
670682 return returnTopic;
671683}
672684
673- void DiscoveryServerManager::loadProfiles (
674- tinyxml2::XMLElement* profiles)
675- {
676- xmlparser::XMLP_ret ret = xmlparser::XMLProfileManager::loadXMLProfiles (*profiles);
677-
678- if (ret == xmlparser::XMLP_ret::XML_OK )
679- {
680- LOG_INFO (" Profiles parsed successfully." );
681- }
682- else
683- {
684- LOG_ERROR (" Error parsing profiles!" );
685- }
686- }
687-
688685void DiscoveryServerManager::onTerminate ()
689686{
690687 {
@@ -1400,36 +1397,17 @@ void DiscoveryServerManager::loadSubscriber(
14001397 // default topic is the static HelloWorld one
14011398 const char * profile_name = sub->Attribute (DSxmlparser::PROFILE_NAME );
14021399
1403- SubscriberAttributes subatts;
1404-
1405- if (profile_name == nullptr )
1406- {
1407- // get default subscriber attributes
1408- xmlparser::XMLProfileManager::getDefaultSubscriberAttributes (subatts);
1409- }
1410- else
1411- {
1412- // try load from profile
1413- if (xmlparser::XMLP_ret::XML_OK !=
1414- xmlparser::XMLProfileManager::fillSubscriberAttributes (std::string (profile_name), subatts))
1415- {
1416- LOG_ERROR (" DiscoveryServerManager::loadSubscriber couldn't load profile " << profile_name);
1417- return ;
1418- }
1419- }
1420-
14211400 // see if topic is specified
14221401 const char * topic_name = sub->Attribute (DSxmlparser::TOPIC );
1423-
1402+ TopicAttributes topicAttr;
14241403 if (topic_name != nullptr )
14251404 {
1426- if (xmlparser::XMLP_ret:: XML_OK !=
1427- xmlparser::XMLProfileManager::fillTopicAttributes ( std::string ( topic_name), subatts. topic ))
1405+ if (! eprosima::fastrtps::rtps::RTPSDomain::get_topic_attributes_from_profile ( std::string (
1406+ topic_name), topicAttr ))
14281407 {
14291408 LOG_ERROR (" DiscoveryServerManager::loadSubscriber couldn't load topic profile " );
14301409 return ;
14311410 }
1432-
14331411 }
14341412
14351413 DelayedEndpointDestruction<DataReader>* pDE = nullptr ; // subscriber destruction event
@@ -1451,8 +1429,8 @@ void DiscoveryServerManager::loadSubscriber(
14511429 endpoint_profile = std::string (profile_name);
14521430 }
14531431
1454- DelayedEndpointCreation<DataReader> event (creation_time, subatts. topic .getTopicName ().to_string (),
1455- subatts. topic .getTopicDataType ().to_string (), topic_name, endpoint_profile, part_guid, pDE,
1432+ DelayedEndpointCreation<DataReader> event (creation_time, topicAttr .getTopicName ().to_string (),
1433+ topicAttr .getTopicDataType ().to_string (), topic_name, endpoint_profile, part_guid, pDE,
14561434 participant_creation_event);
14571435
14581436 if (creation_time == getTime ())
@@ -1522,31 +1500,13 @@ void DiscoveryServerManager::loadPublisher(
15221500 // default topic is the static HelloWorld one
15231501 const char * profile_name = sub->Attribute (DSxmlparser::PROFILE_NAME );
15241502
1525- PublisherAttributes pubatts;
1526-
1527- if (profile_name == nullptr )
1528- {
1529- // get default subscriber attributes
1530- xmlparser::XMLProfileManager::getDefaultPublisherAttributes (pubatts);
1531- }
1532- else
1533- {
1534- // try load from profile
1535- if (xmlparser::XMLP_ret::XML_OK !=
1536- xmlparser::XMLProfileManager::fillPublisherAttributes (std::string (profile_name), pubatts))
1537- {
1538- LOG_ERROR (" DiscoveryServerManager::loadPublisher couldn't load profile " << profile_name);
1539- return ;
1540- }
1541- }
1542-
15431503 // see if topic is specified
15441504 const char * topic_name = sub->Attribute (DSxmlparser::TOPIC );
1545-
1505+ TopicAttributes topicAttr;
15461506 if (topic_name != nullptr )
15471507 {
1548- if (xmlparser::XMLP_ret:: XML_OK !=
1549- xmlparser::XMLProfileManager::fillTopicAttributes ( std::string ( topic_name), pubatts. topic ))
1508+ if (! eprosima::fastrtps::rtps::RTPSDomain::get_topic_attributes_from_profile ( std::string (
1509+ topic_name), topicAttr ))
15501510 {
15511511 LOG_ERROR (" DiscoveryServerManager::loadPublisher couldn't load topic profile " );
15521512 return ;
@@ -1573,8 +1533,8 @@ void DiscoveryServerManager::loadPublisher(
15731533 endpoint_profile = std::string (profile_name);
15741534 }
15751535
1576- DelayedEndpointCreation<DataWriter> event (creation_time, pubatts. topic .getTopicName ().to_string (),
1577- pubatts. topic .getTopicDataType ().to_string (), topic_name, endpoint_profile, part_guid, pDE,
1536+ DelayedEndpointCreation<DataWriter> event (creation_time, topicAttr .getTopicName ().to_string (),
1537+ topicAttr .getTopicDataType ().to_string (), topic_name, endpoint_profile, part_guid, pDE,
15781538 participant_creation_event);
15791539
15801540 if (creation_time == getTime ())
@@ -1667,8 +1627,6 @@ void DiscoveryServerManager::MapServerInfo(
16671627{
16681628 std::lock_guard<std::recursive_mutex> lock (management_mutex);
16691629
1670- uint8_t ident = 1 ;
1671-
16721630 // profile name is mandatory
16731631 std::string profile_name (server->Attribute (DSxmlparser::PROFILE_NAME ));
16741632
@@ -1682,7 +1640,17 @@ void DiscoveryServerManager::MapServerInfo(
16821640 // server GuidPrefix is either pass as an attribute (preferred to allow profile reuse)
16831641 // or inside the profile.
16841642 GuidPrefix_t prefix;
1685- std::shared_ptr<ParticipantAttributes> atts;
1643+
1644+ std::shared_ptr<DomainParticipantQos> pqos;
1645+ // I must load the prefix from the profile
1646+ // retrieve profile QOS
1647+ pqos = std::make_shared<DomainParticipantQos>();
1648+ if (ReturnCode_t::RETCODE_OK !=
1649+ DomainParticipantFactory::get_instance ()->get_participant_qos_from_profile (profile_name, *pqos))
1650+ {
1651+ LOG_ERROR (" DiscoveryServerManager::loadServer couldn't load profile " << profile_name);
1652+ return ;
1653+ }
16861654
16871655 const char * cprefix = server->Attribute (DSxmlparser::PREFIX );
16881656
@@ -1692,17 +1660,7 @@ void DiscoveryServerManager::MapServerInfo(
16921660 }
16931661 else
16941662 {
1695- // I must load the prefix from the profile
1696- // retrieve profile attributes
1697- atts = std::make_shared<ParticipantAttributes>();
1698- if (xmlparser::XMLP_ret::XML_OK !=
1699- xmlparser::XMLProfileManager::fillParticipantAttributes (profile_name, *atts))
1700- {
1701- LOG_ERROR (" DiscoveryServerManager::loadServer couldn't load profile " << profile_name);
1702- return ;
1703- }
1704-
1705- prefix = atts->rtps .prefix ;
1663+ prefix = pqos->wire_protocol ().prefix ;
17061664 }
17071665
17081666 if (prefix == c_GuidPrefix_Unknown)
@@ -1714,44 +1672,8 @@ void DiscoveryServerManager::MapServerInfo(
17141672 // Now we search the locator lists
17151673 serverLocator_map::mapped_type pair;
17161674
1717- tinyxml2::XMLElement* LP = server->FirstChildElement (s_sLP.c_str ());
1718- if (LP != nullptr )
1719- {
1720- tinyxml2::XMLElement* list = LP ->FirstChildElement (DSxmlparser::META_MULTI_LOC_LIST );
1721-
1722- if (list != nullptr &&
1723- (xmlparser::XMLP_ret::XML_OK != getXMLLocatorList (list, pair.first , ident)))
1724- {
1725- LOG_ERROR (" Server " << prefix << " has an ill formed " << DSxmlparser::META_MULTI_LOC_LIST );
1726- }
1727-
1728- list = LP ->FirstChildElement (DSxmlparser::META_UNI_LOC_LIST );
1729- if (list != nullptr &&
1730- (xmlparser::XMLP_ret::XML_OK != getXMLLocatorList (list, pair.second , ident)))
1731- {
1732- LOG_ERROR (" Server " << prefix << " has an ill formed " << DSxmlparser::META_UNI_LOC_LIST );
1733- }
1734-
1735- }
1736- else
1737- {
1738- LocatorList_t multicast, unicast;
1739-
1740- // retrieve profile attributes
1741- if (!atts)
1742- {
1743- atts = std::make_shared<ParticipantAttributes>();
1744- if (xmlparser::XMLP_ret::XML_OK !=
1745- xmlparser::XMLProfileManager::fillParticipantAttributes (profile_name, *atts))
1746- {
1747- LOG_ERROR (" DiscoveryServerManager::loadServer couldn't load profile " << profile_name);
1748- return ;
1749- }
1750- }
1751-
1752- pair.first = atts->rtps .builtin .metatrafficMulticastLocatorList ;
1753- pair.second = atts->rtps .builtin .metatrafficUnicastLocatorList ;
1754- }
1675+ pair.first = pqos->wire_protocol ().builtin .metatrafficMulticastLocatorList ;
1676+ pair.second = pqos->wire_protocol ().builtin .metatrafficUnicastLocatorList ;
17551677
17561678 // now save the value
17571679 server_locators[GUID_t (prefix, c_EntityId_RTPSParticipant)] = std::move (pair);
@@ -1765,7 +1687,7 @@ void DiscoveryServerManager::on_participant_discovery(
17651687 bool server = false ;
17661688 const GUID_t& partid = info.info .m_guid ;
17671689 static_cast <void >(should_be_ignored);
1768-
1690+
17691691 // if the callback origin was removed ignore
17701692 GUID_t srcGuid = participant->guid ();
17711693 if ( nullptr == getParticipant (srcGuid))
0 commit comments