Skip to content

Commit

Permalink
Fix build after rebase.
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Company <[email protected]>
  • Loading branch information
MiguelCompany committed Sep 9, 2024
1 parent 92b9b53 commit 1453374
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 22 deletions.
5 changes: 5 additions & 0 deletions include/fastrtps/xmlparser/XMLParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,11 @@ class XMLParser
uint16_t* ui16,
uint8_t ident);

RTPS_DllAPI static XMLP_ret getXMLUint(
tinyxml2::XMLElement* elem,
uint64_t* ui64,
uint8_t ident);

RTPS_DllAPI static XMLP_ret getXMLBool(
tinyxml2::XMLElement* elem,
bool* b,
Expand Down
1 change: 0 additions & 1 deletion include/fastrtps/xmlparser/XMLParserCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ extern const char* BYTES_PER_SECOND;
extern const char* PERIOD_MILLISECS;
extern const char* FLOW_CONTROLLER_DESCRIPTOR;
extern const char* SCHEDULER;
extern const char* SENDER_THREAD;
extern const char* MAX_BYTES_PER_PERIOD;
extern const char* PERIOD_MS;
extern const char* FLOW_CONTROLLER_NAME;
Expand Down
95 changes: 83 additions & 12 deletions src/cpp/rtps/xmlparser/XMLElementParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@

#include <utils/string_utilities.hpp>

namespace eprosima {
namespace fastrtps {
namespace xmlparser {

std::mutex XMLParser::collections_mtx_;
std::set<std::string> XMLParser::flow_controller_descriptor_names_;

using namespace eprosima::fastrtps;
using namespace eprosima::fastrtps::rtps;
using namespace eprosima::fastrtps::xmlparser;

XMLP_ret XMLParser::getXMLParticipantAllocationAttributes(
tinyxml2::XMLElement* elem,
Expand Down Expand Up @@ -853,7 +855,12 @@ XMLP_ret XMLParser::getXMLFlowControllerDescriptorList(
{
std::lock_guard<std::mutex> lock(collections_mtx_);
// name - stringType
std::string element = get_element_text(p_aux1);
std::string element;
const char* text = nullptr;
if (nullptr != (text = p_aux1->GetText()))
{
element = text;
}
if (element.empty())
{
EPROSIMA_LOG_ERROR(XMLPARSER, "Node '" << NAME << "' without content");
Expand All @@ -871,15 +878,20 @@ XMLP_ret XMLParser::getXMLFlowControllerDescriptorList(
}
else if (strcmp(name, SCHEDULER) == 0)
{
std::string text = get_element_text(p_aux1);
if (text.empty())
std::string element;
const char* text = nullptr;
if (nullptr != (text = p_aux1->GetText()))
{
element = text;
}
if (element.empty())
{
EPROSIMA_LOG_ERROR(XMLPARSER, "Node '" << SCHEDULER << "' without content");
return XMLP_ret::XML_ERROR;
}

// scheduler - flowControllerSchedulerPolicy
if (!get_element_enum_value(text.c_str(), flow_controller_descriptor->scheduler,
if (!get_element_enum_value(element.c_str(), flow_controller_descriptor->scheduler,
FIFO, fastdds::rtps::FlowControllerSchedulerPolicy::FIFO,
HIGH_PRIORITY, fastdds::rtps::FlowControllerSchedulerPolicy::HIGH_PRIORITY,
ROUND_ROBIN, fastdds::rtps::FlowControllerSchedulerPolicy::ROUND_ROBIN,
Expand All @@ -906,11 +918,6 @@ XMLP_ret XMLParser::getXMLFlowControllerDescriptorList(
return XMLP_ret::XML_ERROR;
}
}
else if (strcmp(name, SENDER_THREAD) == 0)
{
// sender_thread - threadSettingsType
getXMLThreadSettings(*p_aux1, flow_controller_descriptor->sender_thread);
}
else
{
EPROSIMA_LOG_ERROR(XMLPARSER,
Expand Down Expand Up @@ -2676,7 +2683,12 @@ XMLP_ret XMLParser::getXMLPublishModeQos(
else if (strcmp(name, FLOW_CONTROLLER_NAME) == 0)
{
std::lock_guard<std::mutex> lock(collections_mtx_);
std::string element = get_element_text(p_aux0);
std::string element;
const char* text = nullptr;
if (nullptr != (text = p_aux0->GetText()))
{
element = text;
}
if (element.empty())
{
EPROSIMA_LOG_ERROR(XMLPARSER, "Node '" << FLOW_CONTROLLER_NAME << "' without content");
Expand Down Expand Up @@ -3783,6 +3795,61 @@ XMLP_ret XMLParser::getXMLUint(
return XMLP_ret::XML_OK;
}

XMLP_ret XMLParser::getXMLUint(
tinyxml2::XMLElement* elem,
uint64_t* ui64,
uint8_t /*ident*/)
{
unsigned long int ui = 0u;
if (nullptr == elem || nullptr == ui64)
{
EPROSIMA_LOG_ERROR(XMLPARSER, "nullptr when getXMLUint XML_ERROR!");
return XMLP_ret::XML_ERROR;
}

auto to_uint64 = [](const char* str, unsigned long int* value) -> bool
{
// Look for a '-' sign
bool ret = false;
const char minus = '-';
const char* minus_result = str;
if (nullptr == std::strchr(minus_result, minus))
{
// Minus not found
ret = true;
}

if (ret)
{
ret = false;
#ifdef _WIN32
if (sscanf_s(str, "%lu", value) == 1)
#else
if (sscanf(str, "%lu", value) == 1)
#endif // ifdef _WIN32
{
// Number found
ret = true;
}
}
return ret;
};

std::string element;
const char* text = nullptr;
if (nullptr != (text = elem->GetText()))
{
element = text;
}
if (element.empty() || !to_uint64(element.c_str(), &ui))
{
EPROSIMA_LOG_ERROR(XMLPARSER, "<" << elem->Value() << "> getXMLUint XML_ERROR!");
return XMLP_ret::XML_ERROR;
}
*ui64 = static_cast<uint64_t>(ui);
return XMLP_ret::XML_OK;
}

XMLP_ret XMLParser::getXMLBool(
tinyxml2::XMLElement* elem,
bool* b,
Expand Down Expand Up @@ -4502,3 +4569,7 @@ XMLP_ret XMLParser::getXMLBuiltinTransports(

return XMLP_ret::XML_OK;
}

} // namespace xmlparser
} // namespace fastrtps
} // namespace eprosima
1 change: 0 additions & 1 deletion src/cpp/rtps/xmlparser/XMLParserCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ const char* BYTES_PER_SECOND = "bytesPerPeriod";
const char* PERIOD_MILLISECS = "periodMillisecs";
const char* FLOW_CONTROLLER_DESCRIPTOR = "flow_controller_descriptor";
const char* SCHEDULER = "scheduler";
const char* SENDER_THREAD = "sender_thread";
const char* MAX_BYTES_PER_PERIOD = "max_bytes_per_period";
const char* PERIOD_MS = "period_ms";
const char* FLOW_CONTROLLER_NAME = "flow_controller_name";
Expand Down
8 changes: 0 additions & 8 deletions test/unittest/xmlparser/XMLElementParserTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2047,14 +2047,6 @@ TEST_F(XMLParserTests, getXMLFlowControllerDescriptorList)
ASSERT_EQ(flow_controller_descriptor_list.at(0)->max_bytes_per_period,
static_cast<int32_t>(std::stoi(params[2])));
ASSERT_EQ(flow_controller_descriptor_list.at(0)->period_ms, static_cast<uint64_t>(std::stoi(params[3])));
ASSERT_EQ(flow_controller_descriptor_list.at(0)->sender_thread.scheduling_policy,
static_cast<int32_t>(std::stoi(params[4])));
ASSERT_EQ(flow_controller_descriptor_list.at(0)->sender_thread.priority,
static_cast<int32_t>(std::stoi(params[5])));
ASSERT_EQ(flow_controller_descriptor_list.at(0)->sender_thread.affinity,
static_cast<uint64_t>(std::stoi(params[6])));
ASSERT_EQ(flow_controller_descriptor_list.at(0)->sender_thread.stack_size,
static_cast<int32_t>(std::stoi(params[7])));
}
}
}
Expand Down

0 comments on commit 1453374

Please sign in to comment.