Skip to content

Commit 74c6c1f

Browse files
Add EntityId getters and delete Endpoint kind prefixes (#254)
* Refs #21817: Remove EndpointName_ prefix Signed-off-by: Carlosespicur <[email protected]> * Refs #21817: Add new EntityId getters Signed-off-by: Carlosespicur <[email protected]> * Refs #21817: Uncrustify Signed-off-by: Carlosespicur <[email protected]> * Refs #21817: Fix database queue broken tests Signed-off-by: Carlosespicur <[email protected]> * Refs #21817: Fix documentation tests errors Signed-off-by: Carlosespicur <[email protected]> * Refs #21817: Add suggested changes & uncrustify Signed-off-by: Carlosespicur <[email protected]> --------- Signed-off-by: Carlosespicur <[email protected]>
1 parent 28e3062 commit 74c6c1f

File tree

9 files changed

+136
-43
lines changed

9 files changed

+136
-43
lines changed

docs/conf.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,9 @@ def configure_doxyfile(
348348

349349
suppress_warnings = [
350350
'cpp.duplicate_declaration',
351-
'cpp.parse_function_declaration'
351+
'cpp.parse_function_declaration',
352+
'config.cache'
353+
352354
]
353355

354356
# If true, `todo` and `todoList` produce output, else they produce nothing.

include/fastdds_statistics_backend/StatisticsBackend.hpp

+22
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,28 @@ class StatisticsBackend
273273
static std::string get_type_idl(
274274
EntityId entity_id);
275275

276+
/**
277+
* @brief Returns the id of the topic associated to an endpoint.
278+
*
279+
* @param endpoint_id The ID of a given endpoint.
280+
*
281+
* @return EntityId of the topic on which the endpoint publishes/receives messages.
282+
*/
283+
FASTDDS_STATISTICS_BACKEND_DllAPI
284+
static EntityId get_endpoint_topic_id(
285+
EntityId endpoint_id);
286+
287+
/**
288+
* @brief Returns the id of the domain to which a given entity (Domain, DomainParticipant, Topic, endpoints) belongs.
289+
*
290+
* @param entity_id The ID of a given entity.
291+
*
292+
* @return EntityId of the domain.
293+
*/
294+
FASTDDS_STATISTICS_BACKEND_DllAPI
295+
static EntityId get_domain_id(
296+
EntityId entity_id);
297+
276298
/**
277299
* @brief Provides access to the data measured during the monitoring.
278300
*

src/cpp/StatisticsBackend.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,18 @@ std::string StatisticsBackend::get_type_idl(
549549
return StatisticsBackendData::get_instance()->database_->get_type_idl(topic_info[DATA_TYPE_TAG]);
550550
}
551551

552+
EntityId StatisticsBackend::get_endpoint_topic_id(
553+
EntityId endpoint_id)
554+
{
555+
return StatisticsBackendData::get_instance()->database_->get_endpoint_topic_id(endpoint_id);
556+
}
557+
558+
EntityId StatisticsBackend::get_domain_id(
559+
EntityId entity_id)
560+
{
561+
return StatisticsBackendData::get_instance()->database_->get_domain_id(entity_id);
562+
}
563+
552564
std::vector<StatisticsData> StatisticsBackend::get_data(
553565
DataKind data_type,
554566
const std::vector<EntityId>& entity_ids_source,

src/cpp/database/database.cpp

+48
Original file line numberDiff line numberDiff line change
@@ -5343,6 +5343,54 @@ Info Database::get_info(
53435343
return info;
53445344
}
53455345

5346+
EntityId Database::get_endpoint_topic_id(
5347+
const EntityId& endpoint_id)
5348+
{
5349+
std::shared_lock<std::shared_timed_mutex> lock(mutex_);
5350+
std::shared_ptr<const Entity> endpoint = get_entity_nts(endpoint_id);
5351+
5352+
// Check if the entity is a valid endpoint
5353+
if (endpoint->kind != EntityKind::DATAWRITER && endpoint->kind != EntityKind::DATAREADER)
5354+
{
5355+
throw BadParameter("Error: Entity is not a valid endpoint");
5356+
}
5357+
5358+
return std::dynamic_pointer_cast<const DDSEndpoint>(endpoint)->topic->id;
5359+
}
5360+
5361+
EntityId Database::get_domain_id(
5362+
const EntityId& entity_id)
5363+
{
5364+
std::shared_lock<std::shared_timed_mutex> lock(mutex_);
5365+
std::shared_ptr<const Entity> entity = get_entity_nts(entity_id);
5366+
5367+
switch (entity->kind)
5368+
{
5369+
case EntityKind::DOMAIN:
5370+
{
5371+
return entity_id;
5372+
}
5373+
case EntityKind::PARTICIPANT:
5374+
{
5375+
return std::dynamic_pointer_cast<const DomainParticipant>(entity)->domain->id;
5376+
}
5377+
case EntityKind::TOPIC:
5378+
{
5379+
return std::dynamic_pointer_cast<const Topic>(entity)->domain->id;
5380+
}
5381+
case EntityKind::DATAWRITER:
5382+
case EntityKind::DATAREADER:
5383+
{
5384+
return std::dynamic_pointer_cast<const DDSEndpoint>(entity)->participant->domain->id;
5385+
}
5386+
default:
5387+
{
5388+
return EntityId::invalid();
5389+
}
5390+
}
5391+
5392+
}
5393+
53465394
void Database::check_entity_kinds(
53475395
EntityKind kind,
53485396
const std::vector<EntityId>& entity_ids,

src/cpp/database/database.hpp

+20
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,26 @@ class Database
694694
Info get_info(
695695
const EntityId& entity_id);
696696

697+
/**
698+
* @brief Returns the id of the topic associated to an endpoint.
699+
*
700+
* @param endpoint_id The ID of a given endpoint.
701+
*
702+
* @return EntityId of the topic on which the endpoint publishes/receives messages.
703+
*/
704+
EntityId get_endpoint_topic_id(
705+
const EntityId& endpoint_id);
706+
707+
/**
708+
* @brief Returns the id of the domain associated to a given entity (Domain, Participant, topic and endpoint).
709+
*
710+
* @param entity_id The ID of an entity.
711+
*
712+
* @return EntityId of the domain which the entity belongs.
713+
*/
714+
EntityId get_domain_id(
715+
const EntityId& entity_id);
716+
697717
/**
698718
* @brief Check if the entities passed correspond to the specified entity kind.
699719
*

src/cpp/database/database_queue.cpp

+4-12
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ EntityId DatabaseEntityQueue::process_datareader(
190190
if (participant_id.first != info.domain_id)
191191
{
192192
throw BadParameter("Participant " + to_string(participant_guid)
193-
+ " found in the database but it is not in the current domain");
193+
+ " found in the database but it is not in the current domain");
194194
}
195195
}
196196
catch (const Exception&)
@@ -265,7 +265,7 @@ EntityId DatabaseEntityQueue::process_datawriter(
265265
if (participant_id.first != info.domain_id)
266266
{
267267
throw BadParameter("Participant " + to_string(participant_guid)
268-
+ " found in the database but it is not in the current domain");
268+
+ " found in the database but it is not in the current domain");
269269
}
270270
}
271271
catch (const Exception&)
@@ -328,7 +328,7 @@ EntityId DatabaseEntityQueue::process_endpoint_discovery(
328328
if (participant_id.first != info.domain_id)
329329
{
330330
throw BadParameter("Participant " + to_string(participant_guid)
331-
+ " found in the database but it is not in the current domain");
331+
+ " found in the database but it is not in the current domain");
332332
}
333333
}
334334
catch (const Exception&)
@@ -377,15 +377,7 @@ EntityId DatabaseEntityQueue::process_endpoint_discovery(
377377
// Create the endpoint
378378
EntityId endpoint_id;
379379
std::stringstream name;
380-
381-
if (info.kind() == EntityKind::DATAREADER)
382-
{
383-
name << "DataReader_" << info.topic_name << "_" << info.guid.entityId;
384-
}
385-
else
386-
{
387-
name << "DataWriter_" << info.topic_name << "_" << info.guid.entityId;
388-
}
380+
name << info.topic_name << "_" << info.guid.entityId;
389381

390382
// Endpoint AppId and metadata
391383
// TODO: get app data from info (parameters), not from participant

test/dds/communication/Communication.hpp

+5-8
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ class Communication
8080
eProsima_user_DllExport Communication(
8181
const Communication& x)
8282
{
83-
m_index = x.m_index;
83+
m_index = x.m_index;
8484

85-
m_message = x.m_message;
85+
m_message = x.m_message;
8686

8787
}
8888

@@ -105,9 +105,9 @@ class Communication
105105
const Communication& x)
106106
{
107107

108-
m_index = x.m_index;
108+
m_index = x.m_index;
109109

110-
m_message = x.m_message;
110+
m_message = x.m_message;
111111

112112
return *this;
113113
}
@@ -133,7 +133,7 @@ class Communication
133133
const Communication& x) const
134134
{
135135
return (m_index == x.m_index &&
136-
m_message == x.m_message);
136+
m_message == x.m_message);
137137
}
138138

139139
/*!
@@ -174,7 +174,6 @@ class Communication
174174
return m_index;
175175
}
176176

177-
178177
/*!
179178
* @brief This function copies the value in member message
180179
* @param _message New value to be copied in member message
@@ -213,8 +212,6 @@ class Communication
213212
return m_message;
214213
}
215214

216-
217-
218215
private:
219216

220217
uint32_t m_index{0};

test/unittest/DatabaseQueue/DatabaseQueueTests.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,7 @@ TEST_F(database_queue_tests, push_datawriter)
13561356
std::chrono::system_clock::time_point timestamp = std::chrono::system_clock::now();
13571357

13581358
// Create the writer info
1359-
std::string datawriter_name = "DataWriter_topic_name_0.0.0.1"; //< Name constructed from the topic and entity_id
1359+
std::string datawriter_name = "topic_name_0.0.0.1"; //< Name constructed from the topic and entity_id
13601360
Qos datawriter_qos;
13611361
std::string datawriter_guid_str = "01.02.03.04.05.06.07.08.09.0a.0b.0c|0.0.0.1";
13621362
std::string topic_name = "topic_name";
@@ -1594,7 +1594,7 @@ TEST_F(database_queue_tests, push_datawriter_topic_does_not_exist)
15941594
std::chrono::system_clock::time_point timestamp = std::chrono::system_clock::now();
15951595

15961596
// Create the writer info
1597-
std::string datawriter_name = "DataWriter_topic_name_0.0.0.1"; //< Name constructed from the topic and entity_id
1597+
std::string datawriter_name = "topic_name_0.0.0.1"; //< Name constructed from the topic and entity_id
15981598
Qos datawriter_qos;
15991599
std::string datawriter_guid_str = "01.02.03.04.05.06.07.08.09.0a.0b.0c|0.0.0.1";
16001600
std::string topic_name = "topic_name";
@@ -1720,7 +1720,7 @@ TEST_F(database_queue_tests, push_datareader)
17201720
std::chrono::system_clock::time_point timestamp = std::chrono::system_clock::now();
17211721

17221722
// Create the reader info
1723-
std::string datareader_name = "DataReader_topic_name_0.0.0.2"; //< Name constructed from the topic and entity_id
1723+
std::string datareader_name = "topic_name_0.0.0.2"; //< Name constructed from the topic and entity_id
17241724
Qos datareader_qos;
17251725
std::string datareader_guid_str = "01.02.03.04.05.06.07.08.09.0a.0b.0c|0.0.0.2";
17261726
std::string topic_name = "topic_name";
@@ -1958,7 +1958,7 @@ TEST_F(database_queue_tests, push_datareader_topic_does_not_exist)
19581958
std::chrono::system_clock::time_point timestamp = std::chrono::system_clock::now();
19591959

19601960
// Create the reader info
1961-
std::string datareader_name = "DataReader_topic_name_0.0.0.2"; //< Name constructed from the topic and entity_id
1961+
std::string datareader_name = "topic_name_0.0.0.2"; //< Name constructed from the topic and entity_id
19621962
Qos datareader_qos;
19631963
std::string datareader_guid_str = "01.02.03.04.05.06.07.08.09.0a.0b.0c|0.0.0.2";
19641964
std::string topic_name = "topic_name";

0 commit comments

Comments
 (0)