Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[20301] Make XML Parser API private #4318

Merged
merged 29 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4dcd846
Refs #20301: move XML Parser implementation to root source folder
JLBuenoLopez Jan 23, 2024
68291f9
Refs #20301: sort alphabetically source files
JLBuenoLopez Jan 23, 2024
10169bd
Refs #20301: make XML Parser private
JLBuenoLopez Jan 24, 2024
7a0fde2
Refs #20301: remove private headers from Blackbox tests
JLBuenoLopez Jan 24, 2024
18ce128
Refs #20301: new LibrarySettings class superseding LibrarySettingsAtt…
JLBuenoLopez Jan 24, 2024
1054c2a
Refs #20301: add library settings DDS & RTPS API. RTPSDomainTests tes…
JLBuenoLopez Jan 26, 2024
d06a31b
Refs #20301: library settings DDS API test
JLBuenoLopez Jan 26, 2024
668b8ab
Refs #20301: generate monitor service types in blackbox types and use…
JLBuenoLopez Jan 29, 2024
e14a428
Refs #20301: XML profile manager get dynamic type builder wrapper and…
JLBuenoLopez Jan 29, 2024
8e36613
Refs #20301: refactor XML library settings, use new migrated structure
JLBuenoLopez Jan 29, 2024
830f4ea
Refs #20301: migrate to public API
JLBuenoLopez Jan 29, 2024
d782897
Refs #20301: reintroduce private headers in blackbox tests
JLBuenoLopez Jan 29, 2024
dece5cc
Refs #20301: update versions.md and copyright
JLBuenoLopez Jan 29, 2024
7c1e163
Refs #20301: remove exportation macro from private API
JLBuenoLopez Jan 29, 2024
6259903
Refs #20301: remove participant without using mocked code
JLBuenoLopez Jan 29, 2024
107b094
Refs #20301: apply review suggestion
JLBuenoLopez Feb 29, 2024
cc12a3e
Refs #20301: linters
JLBuenoLopez Feb 29, 2024
9f9df94
Refs #20301: avoid using protected interface name
JLBuenoLopez Mar 1, 2024
6e08b98
Refs #20301: avoid using non-exported API in ParticipantTests
JLBuenoLopez Mar 5, 2024
0d19dc1
Refs #20301: linters
JLBuenoLopez Mar 5, 2024
463ea3b
Refs #20301: fix Publisher and Subscriber tests
JLBuenoLopez Mar 5, 2024
30bd92d
Refs #20301: add get_topic_attributes_from_profile API
JLBuenoLopez Mar 5, 2024
5fb7b6c
Refs #20301: get topic attributes from profile test
JLBuenoLopez Mar 5, 2024
8d0d6e3
Refs #20301: fixes after rebase
JLBuenoLopez Mar 6, 2024
9d0917c
Refs #20301: fix Windows warning
JLBuenoLopez Mar 6, 2024
1e40e53
Refs #20301: linters
JLBuenoLopez Mar 6, 2024
bf982bb
Refs #20301: fix Windows warning
JLBuenoLopez Mar 7, 2024
d4ca4ec
Refs #20301: fix memory leak
JLBuenoLopez Mar 8, 2024
ca9568d
Refs #20301: Run Github Windows CI on 3.0.x-devel PRs
EduPonz Mar 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/windows-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ on:

pull_request:
branches:
- 'master'
- '3.0.x-devel'
paths-ignore:
- '**.md'
- '**.txt'
Expand Down
17 changes: 12 additions & 5 deletions examples/cpp/dds/DynamicHelloWorldExample/HelloWorldPublisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <fastdds/dds/publisher/qos/DataWriterQos.hpp>
#include <fastdds/dds/publisher/qos/PublisherQos.hpp>
#include <fastrtps/types/DynamicDataFactory.h>
#include <fastrtps/xmlparser/XMLProfileManager.h>

using namespace eprosima::fastdds::dds;

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

bool HelloWorldPublisher::init()
{
if (eprosima::fastrtps::xmlparser::XMLP_ret::XML_OK !=
eprosima::fastrtps::xmlparser::XMLProfileManager::loadXMLFile("helloworld_example_type_profile.xml"))
if (ReturnCode_t::RETCODE_OK !=
DomainParticipantFactory::get_instance()->load_XML_profiles_file("helloworld_example_type_profile.xml"))
{
std::cout <<
"Cannot open XML file \"helloworld_example_type_profile.xml\". Please, run the publisher from the folder "
<< "that contatins this XML file." << std::endl;
return false;
}

eprosima::fastrtps::types::DynamicType_ptr dyn_type =
eprosima::fastrtps::xmlparser::XMLProfileManager::getDynamicTypeByName("HelloWorld")->build();
eprosima::fastrtps::types::DynamicTypeBuilder* type;
if (ReturnCode_t::RETCODE_OK !=
DomainParticipantFactory::get_instance()->get_dynamic_type_builder_from_xml_by_name("HelloWorld", type))
{
std::cout <<
"Error getting dynamic type \"HelloWorld\"." << std::endl;
return false;
}

eprosima::fastrtps::types::DynamicType_ptr dyn_type = type->build();
TypeSupport m_type(new eprosima::fastrtps::types::DynamicPubSubType(dyn_type));
m_Hello = eprosima::fastrtps::types::DynamicDataFactory::get_instance()->create_data(dyn_type);

Expand Down
15 changes: 11 additions & 4 deletions examples/cpp/dds/TypeLookupService/TypeLookupPublisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <fastdds/dds/publisher/qos/DataWriterQos.hpp>
#include <fastdds/dds/publisher/qos/PublisherQos.hpp>
#include <fastrtps/types/DynamicDataFactory.h>
#include <fastrtps/xmlparser/XMLProfileManager.h>

using namespace eprosima::fastdds::dds;
using namespace eprosima::fastrtps;
Expand All @@ -41,15 +40,23 @@ TypeLookupPublisher::TypeLookupPublisher()

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

types::DynamicType_ptr dyn_type = xmlparser::XMLProfileManager::getDynamicTypeByName("TypeLookup")->build();
eprosima::fastrtps::types::DynamicTypeBuilder* type;
if (ReturnCode_t::RETCODE_OK !=
DomainParticipantFactory::get_instance()->get_dynamic_type_builder_from_xml_by_name("TypeLookup", type))
{
std::cout <<
"Error getting dynamic type \"TypeLookup\"." << std::endl;
return false;
}
types::DynamicType_ptr dyn_type = type->build();
TypeSupport m_type(new types::DynamicPubSubType(dyn_type));
m_Hello = types::DynamicDataFactory::get_instance()->create_data(dyn_type);

Expand Down
6 changes: 3 additions & 3 deletions fuzz/C++/fuzz_XMLProfiles/fuzz_XMLProfiles.cxx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <fastrtps/xmlparser/XMLProfileManager.h>

#include "fuzz_utils.h"

#include <fastdds/dds/domain/DomainParticipantFactory.hpp>

using namespace eprosima;
using namespace eprosima::fastrtps;

Expand Down Expand Up @@ -31,7 +31,7 @@ extern "C" int LLVMFuzzerTestOneInput(

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

if (delete_file(filename) != 0)
{
Expand Down
66 changes: 66 additions & 0 deletions include/fastdds/LibrarySettings.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @file LibrarySettings.hpp
*
*/

#ifndef _FASTDDS_LIBRARY_SETTINGS_HPP_
#define _FASTDDS_LIBRARY_SETTINGS_HPP_

namespace eprosima {
namespace fastdds {

enum IntraprocessDeliveryType
{
INTRAPROCESS_OFF,
INTRAPROCESS_USER_DATA_ONLY,
INTRAPROCESS_FULL
};

/**
* Class LibraySettings, used by the user to define the Fast DDS library behaviour
* @ingroup FASTDDS_MODULE
*/
class LibrarySettings
{
public:

LibrarySettings()
{
}

virtual ~LibrarySettings()
{
}

bool operator ==(
const LibrarySettings& b) const
{
return (intraprocess_delivery == b.intraprocess_delivery);
}

IntraprocessDeliveryType intraprocess_delivery =
#if HAVE_STRICT_REALTIME
INTRAPROCESS_OFF;
#else
INTRAPROCESS_FULL;
#endif // if HAVE_STRICT_REALTIME
};

} // namespace fastdds
} // namespace eprosima

#endif /* _FASTDDS_LIBRARY_SETTINGS_HPP_ */
38 changes: 38 additions & 0 deletions include/fastdds/dds/domain/DomainParticipantFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include <fastdds/dds/core/status/StatusMask.hpp>
#include <fastdds/dds/domain/qos/DomainParticipantFactoryQos.hpp>
#include <fastdds/dds/domain/qos/DomainParticipantQos.hpp>
#include <fastdds/LibrarySettings.hpp>
#include <fastrtps/types/DynamicTypeBuilder.h>
#include <fastrtps/types/TypesBase.h>

using eprosima::fastrtps::types::ReturnCode_t;
Expand Down Expand Up @@ -267,6 +269,42 @@ class DomainParticipantFactory
RTPS_DllAPI ReturnCode_t set_qos(
const DomainParticipantFactoryQos& qos);

/**
* @brief This operation returns the value of the DomainParticipant library settings.
*
* @param library_settings LibrarySettings reference where the settings are returned.
* @return RETCODE_OK
*/
RTPS_DllAPI ReturnCode_t get_library_settings(
LibrarySettings& library_settings) const;

/**
* @brief This operation sets the library settings.
*
* Library settings must be set before enabling the DomainParticipants.
* Otherwise, failure of the setting operation is expected.
*
* @param library_settings LibrarySettings to be set.
* @return RETCODE_PRECONDITION_NOT_MET if any DomainParticipant is already enabled.
* RETCODE_OK otherwise.
*/
RTPS_DllAPI ReturnCode_t set_library_settings(
const LibrarySettings& library_settings);

/**
* @brief Get the DynamicTypeBuilder defined in XML file.
* The XML file shall be previously loaded.
*
* @param type_name Dynamic type name.
* @param type Reference where the Dynamic type builder is returned.
* @return RETCODE_BAD_PARAMETER if type_name is empty.
* RETCODE_NO_DATA if type_name is unknown.
* RETCODE_OK otherwise.
*/
RTPS_DllAPI ReturnCode_t get_dynamic_type_builder_from_xml_by_name(
const std::string& type_name,
fastrtps::types::DynamicTypeBuilder*& type);

protected:

friend class DomainParticipant;
Expand Down
33 changes: 33 additions & 0 deletions include/fastdds/rtps/RTPSDomain.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
#include <mutex>
#include <set>

#include <fastdds/LibrarySettings.hpp>
#include <fastdds/rtps/attributes/RTPSParticipantAttributes.h>
#include <fastdds/rtps/attributes/ThreadSettings.hpp>
#include <fastdds/rtps/common/Types.h>
#include <fastdds/rtps/history/IPayloadPool.h>
#include <fastdds/rtps/history/IChangePool.h>
#include <fastrtps/attributes/TopicAttributes.h>

namespace eprosima {
namespace fastrtps {
Expand Down Expand Up @@ -291,6 +293,37 @@ class RTPSDomain
RTPS_DllAPI static bool removeRTPSParticipant(
RTPSParticipant* p);

/**
* @brief Get the library settings.
*
* @param library_settings LibrarySettings reference where the settings are returned.
* @return True.
*/
RTPS_DllAPI static bool get_library_settings(
fastdds::LibrarySettings& library_settings);

/**
* @brief Set the library settings-
*
* @param library_settings LibrarySettings to be set.
* @return False if there is any RTPSParticipant already created.
* True if correctly set.
*/
RTPS_DllAPI static bool set_library_settings(
const fastdds::LibrarySettings& library_settings);

/**
* @brief Get the TopicAttributes from XML profile.
*
* @param profile_name Topic profile name.
* @param topic_att TopicAttributes object where the attributes are returned.
* @return bool true if the profile exists.
* false otherwise.
*/
RTPS_DllAPI static bool get_topic_attributes_from_profile(
const std::string& profile_name,
TopicAttributes& topic_att);

private:

RTPSDomain() = delete;
Expand Down
12 changes: 6 additions & 6 deletions src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,6 @@ set(${PROJECT_NAME}_source_files
rtps/writer/StatefulWriter.cpp
rtps/writer/StatelessPersistentWriter.cpp
rtps/writer/StatelessWriter.cpp
rtps/xmlparser/XMLDynamicParser.cpp
rtps/xmlparser/XMLElementParser.cpp
rtps/xmlparser/XMLEndpointParser.cpp
rtps/xmlparser/XMLParser.cpp
rtps/xmlparser/XMLParserCommon.cpp
rtps/xmlparser/XMLProfileManager.cpp
statistics/fastdds/domain/DomainParticipant.cpp
statistics/fastdds/publisher/qos/DataWriterQos.cpp
statistics/fastdds/subscriber/qos/DataReaderQos.cpp
Expand All @@ -227,6 +221,12 @@ set(${PROJECT_NAME}_source_files
utils/SystemInfo.cpp
utils/TimedConditionVariable.cpp
utils/UnitsParser.cpp
xmlparser/XMLDynamicParser.cpp
xmlparser/XMLElementParser.cpp
xmlparser/XMLEndpointParser.cpp
xmlparser/XMLParser.cpp
xmlparser/XMLParserCommon.cpp
xmlparser/XMLProfileManager.cpp
)

# Statistics support
Expand Down
40 changes: 37 additions & 3 deletions src/cpp/fastdds/domain/DomainParticipantFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
*
*/

#include <fastdds/dds/domain/DomainParticipantFactory.hpp>

#include <thread>

#include <fastdds/dds/domain/DomainParticipant.hpp>
#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
#include <fastdds/dds/domain/qos/DomainParticipantFactoryQos.hpp>
#include <fastdds/dds/log/Log.hpp>
#include <fastdds/domain/DomainParticipantImpl.hpp>
Expand All @@ -31,14 +32,14 @@
#include <fastrtps/types/DynamicDataFactory.h>
#include <fastrtps/types/DynamicTypeBuilderFactory.h>
#include <fastrtps/types/TypeObjectFactory.h>
#include <fastrtps/xmlparser/XMLEndpointParser.h>
#include <fastrtps/xmlparser/XMLProfileManager.h>

#include <rtps/history/TopicPayloadPoolRegistry.hpp>
#include <rtps/RTPSDomainImpl.hpp>
#include <statistics/fastdds/domain/DomainParticipantImpl.hpp>
#include <utils/shared_memory/SharedMemWatchdog.hpp>
#include <utils/SystemInfo.hpp>
#include <xmlparser/XMLEndpointParser.h>
#include <xmlparser/XMLProfileManager.h>

using namespace eprosima::fastrtps::xmlparser;

Expand Down Expand Up @@ -481,6 +482,39 @@ void DomainParticipantFactory::participant_has_been_deleted(
}
}

ReturnCode_t DomainParticipantFactory::get_library_settings(
LibrarySettings& library_settings) const
{
rtps_domain_->get_library_settings(library_settings);
return ReturnCode_t::RETCODE_OK;
}

ReturnCode_t DomainParticipantFactory::set_library_settings(
const LibrarySettings& library_settings)
{
if (rtps_domain_->set_library_settings(library_settings))
{
return ReturnCode_t::RETCODE_OK;
}
return ReturnCode_t::RETCODE_PRECONDITION_NOT_MET;
}

ReturnCode_t DomainParticipantFactory::get_dynamic_type_builder_from_xml_by_name(
const std::string& type_name,
fastrtps::types::DynamicTypeBuilder*& type)
{
if (type_name.empty())
{
return ReturnCode_t::RETCODE_BAD_PARAMETER;
}
type = XMLProfileManager::getDynamicTypeByName(type_name);
if (nullptr == type)
{
return ReturnCode_t::RETCODE_NO_DATA;
}
return ReturnCode_t::RETCODE_OK;
}

} /* namespace dds */
} /* namespace fastdds */
} /* namespace eprosima */
Loading