Skip to content

Commit 9ec0f6c

Browse files
JLBuenoLopezEduPonz
andcommitted
Make XML Parser API private (#4318)
* Refs #20301: move XML Parser implementation to root source folder Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: sort alphabetically source files Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: make XML Parser private Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: remove private headers from Blackbox tests Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: new LibrarySettings class superseding LibrarySettingsAttributes Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: add library settings DDS & RTPS API. RTPSDomainTests testing the new API Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: library settings DDS API test Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: generate monitor service types in blackbox types and use them in corresponding test Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: XML profile manager get dynamic type builder wrapper and related test Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: refactor XML library settings, use new migrated structure Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: migrate to public API Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: reintroduce private headers in blackbox tests Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: update versions.md and copyright Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: remove exportation macro from private API Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: remove participant without using mocked code Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: apply review suggestion Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: linters Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: avoid using protected interface name Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: avoid using non-exported API in ParticipantTests Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: linters Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: fix Publisher and Subscriber tests Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: add get_topic_attributes_from_profile API Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: get topic attributes from profile test Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: fixes after rebase Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: fix Windows warning Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: linters Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: fix Windows warning Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: fix memory leak Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> * Refs #20301: Run Github Windows CI on 3.0.x-devel PRs Signed-off-by: EduPonz <eduardoponz@eprosima.com> --------- Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com> Signed-off-by: EduPonz <eduardoponz@eprosima.com> Co-authored-by: EduPonz <eduardoponz@eprosima.com>
1 parent 6bed46c commit 9ec0f6c

138 files changed

Lines changed: 13016 additions & 1079 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/windows-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ on:
2626

2727
pull_request:
2828
branches:
29-
- 'master'
29+
- '3.0.x-devel'
3030
paths-ignore:
3131
- '**.md'
3232
- '**.txt'

examples/cpp/dds/DynamicHelloWorldExample/HelloWorldPublisher.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <fastdds/dds/publisher/qos/DataWriterQos.hpp>
2828
#include <fastdds/dds/publisher/qos/PublisherQos.hpp>
2929
#include <fastrtps/types/DynamicDataFactory.h>
30-
#include <fastrtps/xmlparser/XMLProfileManager.h>
3130

3231
using namespace eprosima::fastdds::dds;
3332

@@ -39,17 +38,25 @@ HelloWorldPublisher::HelloWorldPublisher()
3938

4039
bool HelloWorldPublisher::init()
4140
{
42-
if (eprosima::fastrtps::xmlparser::XMLP_ret::XML_OK !=
43-
eprosima::fastrtps::xmlparser::XMLProfileManager::loadXMLFile("helloworld_example_type_profile.xml"))
41+
if (ReturnCode_t::RETCODE_OK !=
42+
DomainParticipantFactory::get_instance()->load_XML_profiles_file("helloworld_example_type_profile.xml"))
4443
{
4544
std::cout <<
4645
"Cannot open XML file \"helloworld_example_type_profile.xml\". Please, run the publisher from the folder "
4746
<< "that contatins this XML file." << std::endl;
4847
return false;
4948
}
5049

51-
eprosima::fastrtps::types::DynamicType_ptr dyn_type =
52-
eprosima::fastrtps::xmlparser::XMLProfileManager::getDynamicTypeByName("HelloWorld")->build();
50+
eprosima::fastrtps::types::DynamicTypeBuilder* type;
51+
if (ReturnCode_t::RETCODE_OK !=
52+
DomainParticipantFactory::get_instance()->get_dynamic_type_builder_from_xml_by_name("HelloWorld", type))
53+
{
54+
std::cout <<
55+
"Error getting dynamic type \"HelloWorld\"." << std::endl;
56+
return false;
57+
}
58+
59+
eprosima::fastrtps::types::DynamicType_ptr dyn_type = type->build();
5360
TypeSupport m_type(new eprosima::fastrtps::types::DynamicPubSubType(dyn_type));
5461
m_Hello = eprosima::fastrtps::types::DynamicDataFactory::get_instance()->create_data(dyn_type);
5562

examples/cpp/dds/TypeLookupService/TypeLookupPublisher.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <fastdds/dds/publisher/qos/DataWriterQos.hpp>
2828
#include <fastdds/dds/publisher/qos/PublisherQos.hpp>
2929
#include <fastrtps/types/DynamicDataFactory.h>
30-
#include <fastrtps/xmlparser/XMLProfileManager.h>
3130

3231
using namespace eprosima::fastdds::dds;
3332
using namespace eprosima::fastrtps;
@@ -41,15 +40,23 @@ TypeLookupPublisher::TypeLookupPublisher()
4140

4241
bool TypeLookupPublisher::init()
4342
{
44-
if (xmlparser::XMLP_ret::XML_OK !=
45-
xmlparser::XMLProfileManager::loadXMLFile("example_type_profile.xml"))
43+
if (ReturnCode_t::RETCODE_OK !=
44+
DomainParticipantFactory::get_instance()->load_XML_profiles_file("example_type_profile.xml"))
4645
{
4746
std::cout << "Cannot open XML file \"example_type_profile.xml\". Please, run the publisher from the folder "
4847
<< "that contatins this XML file." << std::endl;
4948
return false;
5049
}
5150

52-
types::DynamicType_ptr dyn_type = xmlparser::XMLProfileManager::getDynamicTypeByName("TypeLookup")->build();
51+
eprosima::fastrtps::types::DynamicTypeBuilder* type;
52+
if (ReturnCode_t::RETCODE_OK !=
53+
DomainParticipantFactory::get_instance()->get_dynamic_type_builder_from_xml_by_name("TypeLookup", type))
54+
{
55+
std::cout <<
56+
"Error getting dynamic type \"TypeLookup\"." << std::endl;
57+
return false;
58+
}
59+
types::DynamicType_ptr dyn_type = type->build();
5360
TypeSupport m_type(new types::DynamicPubSubType(dyn_type));
5461
m_Hello = types::DynamicDataFactory::get_instance()->create_data(dyn_type);
5562

fuzz/C++/fuzz_XMLProfiles/fuzz_XMLProfiles.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#include <fastrtps/xmlparser/XMLProfileManager.h>
2-
31
#include "fuzz_utils.h"
42

3+
#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
4+
55
using namespace eprosima;
66
using namespace eprosima::fastrtps;
77

@@ -31,7 +31,7 @@ extern "C" int LLVMFuzzerTestOneInput(
3131

3232
// TODO change this to a func. taking buf + len (or C string)
3333
// to avoid using `buf_to_file`
34-
xmlparser::XMLProfileManager::loadXMLFile(filename);
34+
fastdds::DomainParticipantFactory::get_instance()->load_XML_profiles_file(filename);
3535

3636
if (delete_file(filename) != 0)
3737
{
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
/**
16+
* @file LibrarySettings.hpp
17+
*
18+
*/
19+
20+
#ifndef _FASTDDS_LIBRARY_SETTINGS_HPP_
21+
#define _FASTDDS_LIBRARY_SETTINGS_HPP_
22+
23+
namespace eprosima {
24+
namespace fastdds {
25+
26+
enum IntraprocessDeliveryType
27+
{
28+
INTRAPROCESS_OFF,
29+
INTRAPROCESS_USER_DATA_ONLY,
30+
INTRAPROCESS_FULL
31+
};
32+
33+
/**
34+
* Class LibraySettings, used by the user to define the Fast DDS library behaviour
35+
* @ingroup FASTDDS_MODULE
36+
*/
37+
class LibrarySettings
38+
{
39+
public:
40+
41+
LibrarySettings()
42+
{
43+
}
44+
45+
virtual ~LibrarySettings()
46+
{
47+
}
48+
49+
bool operator ==(
50+
const LibrarySettings& b) const
51+
{
52+
return (intraprocess_delivery == b.intraprocess_delivery);
53+
}
54+
55+
IntraprocessDeliveryType intraprocess_delivery =
56+
#if HAVE_STRICT_REALTIME
57+
INTRAPROCESS_OFF;
58+
#else
59+
INTRAPROCESS_FULL;
60+
#endif // if HAVE_STRICT_REALTIME
61+
};
62+
63+
} // namespace fastdds
64+
} // namespace eprosima
65+
66+
#endif /* _FASTDDS_LIBRARY_SETTINGS_HPP_ */

include/fastdds/dds/domain/DomainParticipantFactory.hpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include <fastdds/dds/core/status/StatusMask.hpp>
2828
#include <fastdds/dds/domain/qos/DomainParticipantFactoryQos.hpp>
2929
#include <fastdds/dds/domain/qos/DomainParticipantQos.hpp>
30+
#include <fastdds/LibrarySettings.hpp>
31+
#include <fastrtps/types/DynamicTypeBuilder.h>
3032
#include <fastrtps/types/TypesBase.h>
3133

3234
using eprosima::fastrtps::types::ReturnCode_t;
@@ -267,6 +269,42 @@ class DomainParticipantFactory
267269
RTPS_DllAPI ReturnCode_t set_qos(
268270
const DomainParticipantFactoryQos& qos);
269271

272+
/**
273+
* @brief This operation returns the value of the DomainParticipant library settings.
274+
*
275+
* @param library_settings LibrarySettings reference where the settings are returned.
276+
* @return RETCODE_OK
277+
*/
278+
RTPS_DllAPI ReturnCode_t get_library_settings(
279+
LibrarySettings& library_settings) const;
280+
281+
/**
282+
* @brief This operation sets the library settings.
283+
*
284+
* Library settings must be set before enabling the DomainParticipants.
285+
* Otherwise, failure of the setting operation is expected.
286+
*
287+
* @param library_settings LibrarySettings to be set.
288+
* @return RETCODE_PRECONDITION_NOT_MET if any DomainParticipant is already enabled.
289+
* RETCODE_OK otherwise.
290+
*/
291+
RTPS_DllAPI ReturnCode_t set_library_settings(
292+
const LibrarySettings& library_settings);
293+
294+
/**
295+
* @brief Get the DynamicTypeBuilder defined in XML file.
296+
* The XML file shall be previously loaded.
297+
*
298+
* @param type_name Dynamic type name.
299+
* @param type Reference where the Dynamic type builder is returned.
300+
* @return RETCODE_BAD_PARAMETER if type_name is empty.
301+
* RETCODE_NO_DATA if type_name is unknown.
302+
* RETCODE_OK otherwise.
303+
*/
304+
RTPS_DllAPI ReturnCode_t get_dynamic_type_builder_from_xml_by_name(
305+
const std::string& type_name,
306+
fastrtps::types::DynamicTypeBuilder*& type);
307+
270308
protected:
271309

272310
friend class DomainParticipant;

include/fastdds/rtps/RTPSDomain.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@
2323
#include <mutex>
2424
#include <set>
2525

26+
#include <fastdds/LibrarySettings.hpp>
2627
#include <fastdds/rtps/attributes/RTPSParticipantAttributes.h>
2728
#include <fastdds/rtps/attributes/ThreadSettings.hpp>
2829
#include <fastdds/rtps/common/Types.h>
2930
#include <fastdds/rtps/history/IPayloadPool.h>
3031
#include <fastdds/rtps/history/IChangePool.h>
32+
#include <fastrtps/attributes/TopicAttributes.h>
3133

3234
namespace eprosima {
3335
namespace fastrtps {
@@ -291,6 +293,37 @@ class RTPSDomain
291293
RTPS_DllAPI static bool removeRTPSParticipant(
292294
RTPSParticipant* p);
293295

296+
/**
297+
* @brief Get the library settings.
298+
*
299+
* @param library_settings LibrarySettings reference where the settings are returned.
300+
* @return True.
301+
*/
302+
RTPS_DllAPI static bool get_library_settings(
303+
fastdds::LibrarySettings& library_settings);
304+
305+
/**
306+
* @brief Set the library settings-
307+
*
308+
* @param library_settings LibrarySettings to be set.
309+
* @return False if there is any RTPSParticipant already created.
310+
* True if correctly set.
311+
*/
312+
RTPS_DllAPI static bool set_library_settings(
313+
const fastdds::LibrarySettings& library_settings);
314+
315+
/**
316+
* @brief Get the TopicAttributes from XML profile.
317+
*
318+
* @param profile_name Topic profile name.
319+
* @param topic_att TopicAttributes object where the attributes are returned.
320+
* @return bool true if the profile exists.
321+
* false otherwise.
322+
*/
323+
RTPS_DllAPI static bool get_topic_attributes_from_profile(
324+
const std::string& profile_name,
325+
TopicAttributes& topic_att);
326+
294327
private:
295328

296329
RTPSDomain() = delete;

src/cpp/CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,6 @@ set(${PROJECT_NAME}_source_files
217217
rtps/writer/StatefulWriter.cpp
218218
rtps/writer/StatelessPersistentWriter.cpp
219219
rtps/writer/StatelessWriter.cpp
220-
rtps/xmlparser/XMLDynamicParser.cpp
221-
rtps/xmlparser/XMLElementParser.cpp
222-
rtps/xmlparser/XMLEndpointParser.cpp
223-
rtps/xmlparser/XMLParser.cpp
224-
rtps/xmlparser/XMLParserCommon.cpp
225-
rtps/xmlparser/XMLProfileManager.cpp
226220
statistics/fastdds/domain/DomainParticipant.cpp
227221
statistics/fastdds/publisher/qos/DataWriterQos.cpp
228222
statistics/fastdds/subscriber/qos/DataReaderQos.cpp
@@ -234,6 +228,12 @@ set(${PROJECT_NAME}_source_files
234228
utils/SystemInfo.cpp
235229
utils/TimedConditionVariable.cpp
236230
utils/UnitsParser.cpp
231+
xmlparser/XMLDynamicParser.cpp
232+
xmlparser/XMLElementParser.cpp
233+
xmlparser/XMLEndpointParser.cpp
234+
xmlparser/XMLParser.cpp
235+
xmlparser/XMLParserCommon.cpp
236+
xmlparser/XMLProfileManager.cpp
237237
)
238238

239239
# Statistics support

src/cpp/fastdds/domain/DomainParticipantFactory.cpp

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
*
1818
*/
1919

20+
#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
21+
2022
#include <thread>
2123

2224
#include <fastdds/dds/domain/DomainParticipant.hpp>
23-
#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
2425
#include <fastdds/dds/domain/qos/DomainParticipantFactoryQos.hpp>
2526
#include <fastdds/dds/log/Log.hpp>
2627
#include <fastdds/domain/DomainParticipantImpl.hpp>
@@ -31,14 +32,14 @@
3132
#include <fastrtps/types/DynamicDataFactory.h>
3233
#include <fastrtps/types/DynamicTypeBuilderFactory.h>
3334
#include <fastrtps/types/TypeObjectFactory.h>
34-
#include <fastrtps/xmlparser/XMLEndpointParser.h>
35-
#include <fastrtps/xmlparser/XMLProfileManager.h>
3635

3736
#include <rtps/history/TopicPayloadPoolRegistry.hpp>
3837
#include <rtps/RTPSDomainImpl.hpp>
3938
#include <statistics/fastdds/domain/DomainParticipantImpl.hpp>
4039
#include <utils/shared_memory/SharedMemWatchdog.hpp>
4140
#include <utils/SystemInfo.hpp>
41+
#include <xmlparser/XMLEndpointParser.h>
42+
#include <xmlparser/XMLProfileManager.h>
4243

4344
using namespace eprosima::fastrtps::xmlparser;
4445

@@ -481,6 +482,39 @@ void DomainParticipantFactory::participant_has_been_deleted(
481482
}
482483
}
483484

485+
ReturnCode_t DomainParticipantFactory::get_library_settings(
486+
LibrarySettings& library_settings) const
487+
{
488+
rtps_domain_->get_library_settings(library_settings);
489+
return ReturnCode_t::RETCODE_OK;
490+
}
491+
492+
ReturnCode_t DomainParticipantFactory::set_library_settings(
493+
const LibrarySettings& library_settings)
494+
{
495+
if (rtps_domain_->set_library_settings(library_settings))
496+
{
497+
return ReturnCode_t::RETCODE_OK;
498+
}
499+
return ReturnCode_t::RETCODE_PRECONDITION_NOT_MET;
500+
}
501+
502+
ReturnCode_t DomainParticipantFactory::get_dynamic_type_builder_from_xml_by_name(
503+
const std::string& type_name,
504+
fastrtps::types::DynamicTypeBuilder*& type)
505+
{
506+
if (type_name.empty())
507+
{
508+
return ReturnCode_t::RETCODE_BAD_PARAMETER;
509+
}
510+
type = XMLProfileManager::getDynamicTypeByName(type_name);
511+
if (nullptr == type)
512+
{
513+
return ReturnCode_t::RETCODE_NO_DATA;
514+
}
515+
return ReturnCode_t::RETCODE_OK;
516+
}
517+
484518
} /* namespace dds */
485519
} /* namespace fastdds */
486520
} /* namespace eprosima */

0 commit comments

Comments
 (0)