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

[18273] Refactor enum EntityKind::DOMAIN with EntityKind::DOMAIN_ENTITY #195

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 docs/rst/exports/alias.include
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
.. |HOST-api| replace:: :cpp:enumerator:`HOST<eprosima::statistics_backend::EntityKind::HOST>`
.. |USER-api| replace:: :cpp:enumerator:`USER<eprosima::statistics_backend::EntityKind::USER>`
.. |PROCESS-api| replace:: :cpp:enumerator:`PROCESS<eprosima::statistics_backend::EntityKind::PROCESS>`
.. |DOMAIN-api| replace:: :cpp:enumerator:`DOMAIN<eprosima::statistics_backend::EntityKind::DOMAIN>`
.. |DOMAIN-api| replace:: :cpp:enumerator:`DOMAIN<eprosima::statistics_backend::EntityKind::DOMAIN_ENTITY>`
.. |TOPIC-api| replace:: :cpp:enumerator:`TOPIC<eprosima::statistics_backend::EntityKind::TOPIC>`
.. |PARTICIPANT-api| replace:: :cpp:enumerator:`PARTICIPANT<eprosima::statistics_backend::EntityKind::PARTICIPANT>`
.. |DATAWRITER-api| replace:: :cpp:enumerator:`DATAWRITER<eprosima::statistics_backend::EntityKind::DATAWRITER>`
Expand Down
2 changes: 1 addition & 1 deletion include/fastdds_statistics_backend/types/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ enum class EntityKind
PROCESS,

/// Abstract DDS network by Domain or by Discovery Server
DOMAIN,
DOMAIN_ENTITY,

/// DDS Topic
TOPIC,
Expand Down
32 changes: 16 additions & 16 deletions src/cpp/database/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ void Database::insert_nts(
process->user->processes[process->id] = process;
break;
}
case EntityKind::DOMAIN:
case EntityKind::DOMAIN_ENTITY:
{
std::shared_ptr<Domain> domain = std::static_pointer_cast<Domain>(entity);

Expand Down Expand Up @@ -1436,7 +1436,7 @@ std::vector<std::pair<EntityId, EntityId>> Database::get_entities_by_name(
}
break;
}
case EntityKind::DOMAIN:
case EntityKind::DOMAIN_ENTITY:
{
for (const auto& domain_it : domains_)
{
Expand Down Expand Up @@ -1528,7 +1528,7 @@ void Database::erase(
// Check that the given domain_id corresponds to a known monitor.
// Upper layer ensures that the monitor has been stopped.
// Upper layer also ensures that the monitor_id is valid and corresponds to a known domain.
if (EntityKind::DOMAIN != get_entity_kind(domain_id))
if (EntityKind::DOMAIN_ENTITY != get_entity_kind(domain_id))
{
throw BadParameter("Incorrect EntityKind");
}
Expand Down Expand Up @@ -2200,7 +2200,7 @@ const std::vector<std::shared_ptr<const Entity>> Database::get_entities(
case EntityKind::PROCESS:
map_to_vector(processes_, entities);
break;
case EntityKind::DOMAIN:
case EntityKind::DOMAIN_ENTITY:
map_to_vector(domains_, entities);
break;
case EntityKind::TOPIC:
Expand Down Expand Up @@ -2241,7 +2241,7 @@ const std::vector<std::shared_ptr<const Entity>> Database::get_entities(
}
break;
case EntityKind::PROCESS:
case EntityKind::DOMAIN:
case EntityKind::DOMAIN_ENTITY:
case EntityKind::PARTICIPANT:
case EntityKind::TOPIC:
case EntityKind::DATAREADER:
Expand Down Expand Up @@ -2275,7 +2275,7 @@ const std::vector<std::shared_ptr<const Entity>> Database::get_entities(
entities.push_back(process.second);
}
break;
case EntityKind::DOMAIN:
case EntityKind::DOMAIN_ENTITY:
case EntityKind::PARTICIPANT:
case EntityKind::TOPIC:
case EntityKind::DATAREADER:
Expand Down Expand Up @@ -2315,7 +2315,7 @@ const std::vector<std::shared_ptr<const Entity>> Database::get_entities(
entities.push_back(participant.second);
}
break;
case EntityKind::DOMAIN:
case EntityKind::DOMAIN_ENTITY:
case EntityKind::TOPIC:
case EntityKind::DATAREADER:
case EntityKind::DATAWRITER:
Expand All @@ -2331,12 +2331,12 @@ const std::vector<std::shared_ptr<const Entity>> Database::get_entities(
}
break;
}
case EntityKind::DOMAIN:
case EntityKind::DOMAIN_ENTITY:
{
const std::shared_ptr<const Domain>& domain = std::dynamic_pointer_cast<const Domain>(origin);
switch (entity_kind)
{
case EntityKind::DOMAIN:
case EntityKind::DOMAIN_ENTITY:
entities.push_back(domain);
break;
case EntityKind::PARTICIPANT:
Expand Down Expand Up @@ -2392,7 +2392,7 @@ const std::vector<std::shared_ptr<const Entity>> Database::get_entities(
entities.push_back(participant->process);
}
break;
case EntityKind::DOMAIN:
case EntityKind::DOMAIN_ENTITY:
entities.push_back(participant->domain);
break;
case EntityKind::PARTICIPANT:
Expand Down Expand Up @@ -2433,7 +2433,7 @@ const std::vector<std::shared_ptr<const Entity>> Database::get_entities(
const std::shared_ptr<const Topic>& topic = std::dynamic_pointer_cast<const Topic>(origin);
switch (entity_kind)
{
case EntityKind::DOMAIN:
case EntityKind::DOMAIN_ENTITY:
entities.push_back(topic->domain);
break;
case EntityKind::TOPIC:
Expand Down Expand Up @@ -2501,7 +2501,7 @@ const std::vector<std::shared_ptr<const Entity>> Database::get_entities(
case EntityKind::HOST:
case EntityKind::USER:
case EntityKind::PROCESS:
case EntityKind::DOMAIN:
case EntityKind::DOMAIN_ENTITY:
{
auto sub_entities = get_entities(entity_kind, writer->participant);
entities.insert(entities.end(), sub_entities.begin(), sub_entities.end());
Expand Down Expand Up @@ -2541,7 +2541,7 @@ const std::vector<std::shared_ptr<const Entity>> Database::get_entities(
case EntityKind::HOST:
case EntityKind::USER:
case EntityKind::PROCESS:
case EntityKind::DOMAIN:
case EntityKind::DOMAIN_ENTITY:
{
auto sub_entities = get_entities(entity_kind, reader->participant);
entities.insert(entities.end(), sub_entities.begin(), sub_entities.end());
Expand Down Expand Up @@ -2577,7 +2577,7 @@ const std::vector<std::shared_ptr<const Entity>> Database::get_entities(
case EntityKind::PROCESS:
case EntityKind::PARTICIPANT:
case EntityKind::TOPIC:
case EntityKind::DOMAIN:
case EntityKind::DOMAIN_ENTITY:
for (const auto& writer : locator->data_writers)
{
auto sub_entities = get_entities(entity_kind, writer.second);
Expand Down Expand Up @@ -4731,7 +4731,7 @@ void Database::change_entity_status_of_kind(
}
break;
}
case EntityKind::DOMAIN:
case EntityKind::DOMAIN_ENTITY:
{
std::shared_ptr<Domain> domain;

Expand Down Expand Up @@ -5004,7 +5004,7 @@ void Database::change_entity_status(
// Check that the entity is a discovered/undiscovered dds_entity or a started/stopped monitor
assert(
entity_kind == EntityKind::PARTICIPANT || entity_kind == EntityKind::DATAWRITER ||
entity_kind == EntityKind::DATAREADER || entity_kind == EntityKind::DOMAIN);
entity_kind == EntityKind::DATAREADER || entity_kind == EntityKind::DOMAIN_ENTITY);

std::lock_guard<std::shared_timed_mutex> guard(mutex_);
change_entity_status_of_kind(entity_id, active, entity_kind);
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/database/entities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ struct Domain : Entity
{
Domain(
std::string domain_name) noexcept
: Entity(EntityKind::DOMAIN, domain_name)
: Entity(EntityKind::DOMAIN_ENTITY, domain_name)
{
}

Expand Down
28 changes: 14 additions & 14 deletions test/dds/communication/Monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ int main(
if (!StatisticsBackend::get_entities(EntityKind::HOST).empty() ||
!StatisticsBackend::get_entities(EntityKind::USER).empty() ||
!StatisticsBackend::get_entities(EntityKind::PROCESS).empty() ||
!StatisticsBackend::get_entities(EntityKind::DOMAIN).empty() ||
!StatisticsBackend::get_entities(EntityKind::DOMAIN_ENTITY).empty() ||
!StatisticsBackend::get_entities(EntityKind::TOPIC).empty() ||
!StatisticsBackend::get_entities(EntityKind::PARTICIPANT).empty() ||
!StatisticsBackend::get_entities(EntityKind::DATAWRITER).empty() ||
Expand Down Expand Up @@ -227,12 +227,12 @@ int main(
!StatisticsBackend::get_entities(EntityKind::DATAWRITER).empty() ||
!StatisticsBackend::get_entities(EntityKind::DATAREADER).empty() ||
!StatisticsBackend::get_entities(EntityKind::LOCATOR).empty() ||
(StatisticsBackend::get_entities(EntityKind::DOMAIN).size() != 1) ||
(StatisticsBackend::get_entities(EntityKind::DOMAIN).begin()->value() != monitor_id))
(StatisticsBackend::get_entities(EntityKind::DOMAIN_ENTITY).size() != 1) ||
(StatisticsBackend::get_entities(EntityKind::DOMAIN_ENTITY).begin()->value() != monitor_id))
{
throw Error("Error: database contains unexpected entities");
}
for (auto entity : StatisticsBackend::get_entities(EntityKind::DOMAIN, monitor_id))
for (auto entity : StatisticsBackend::get_entities(EntityKind::DOMAIN_ENTITY, monitor_id))
{
if (!StatisticsBackend::is_active(entity))
{
Expand Down Expand Up @@ -272,8 +272,8 @@ int main(
{
throw Error("Error: database contains unexpected entities");
}
else if (StatisticsBackend::get_entities(EntityKind::DOMAIN).size() != 1 ||
StatisticsBackend::get_entities(EntityKind::DOMAIN).begin()->value() != monitor_id)
else if (StatisticsBackend::get_entities(EntityKind::DOMAIN_ENTITY).size() != 1 ||
StatisticsBackend::get_entities(EntityKind::DOMAIN_ENTITY).begin()->value() != monitor_id)
{
throw Error("Error: database contains unexpected DOMAIN");
}
Expand Down Expand Up @@ -303,7 +303,7 @@ int main(
{
throw Error("Error: database contains unexpected LOCATOR");
}
for (auto entity : StatisticsBackend::get_entities(EntityKind::DOMAIN, monitor_id))
for (auto entity : StatisticsBackend::get_entities(EntityKind::DOMAIN_ENTITY, monitor_id))
{
if (!StatisticsBackend::is_active(entity))
{
Expand Down Expand Up @@ -372,8 +372,8 @@ int main(
{
throw Error("Error: database contains unexpected entities");
}
else if (StatisticsBackend::get_entities(EntityKind::DOMAIN).size() != 1 ||
StatisticsBackend::get_entities(EntityKind::DOMAIN).begin()->value() != monitor_id)
else if (StatisticsBackend::get_entities(EntityKind::DOMAIN_ENTITY).size() != 1 ||
StatisticsBackend::get_entities(EntityKind::DOMAIN_ENTITY).begin()->value() != monitor_id)
{
throw Error("Error: database contains unexpected DOMAIN");
}
Expand Down Expand Up @@ -403,7 +403,7 @@ int main(
{
throw Error("Error: database contains unexpected LOCATOR");
}
for (auto entity : StatisticsBackend::get_entities(EntityKind::DOMAIN, monitor_id))
for (auto entity : StatisticsBackend::get_entities(EntityKind::DOMAIN_ENTITY, monitor_id))
{
if (!StatisticsBackend::is_active(entity))
{
Expand Down Expand Up @@ -474,8 +474,8 @@ int main(
{
throw Error("Error: database contains unexpected entities");
}
else if (StatisticsBackend::get_entities(EntityKind::DOMAIN).size() != 1 ||
StatisticsBackend::get_entities(EntityKind::DOMAIN).begin()->value() != monitor_id)
else if (StatisticsBackend::get_entities(EntityKind::DOMAIN_ENTITY).size() != 1 ||
StatisticsBackend::get_entities(EntityKind::DOMAIN_ENTITY).begin()->value() != monitor_id)
{
throw Error("Error: database contains unexpected DOMAIN");
}
Expand Down Expand Up @@ -505,7 +505,7 @@ int main(
{
throw Error("Error: database contains unexpected LOCATOR");
}
for (auto entity : StatisticsBackend::get_entities(EntityKind::DOMAIN, monitor_id))
for (auto entity : StatisticsBackend::get_entities(EntityKind::DOMAIN_ENTITY, monitor_id))
{
if (StatisticsBackend::is_active(entity))
{
Expand Down Expand Up @@ -564,7 +564,7 @@ int main(
// if (!StatisticsBackend::get_entities(EntityKind::HOST).empty() ||
// !StatisticsBackend::get_entities(EntityKind::USER).empty() ||
// !StatisticsBackend::get_entities(EntityKind::PROCESS).empty() ||
// !StatisticsBackend::get_entities(EntityKind::DOMAIN).empty() ||
// !StatisticsBackend::get_entities(EntityKind::DOMAIN_ENTITY).empty() ||
// !StatisticsBackend::get_entities(EntityKind::TOPIC).empty() ||
// !StatisticsBackend::get_entities(EntityKind::PARTICIPANT).empty() ||
// !StatisticsBackend::get_entities(EntityKind::DATAWRITER).empty() ||
Expand Down
4 changes: 2 additions & 2 deletions test/unittest/Database/DatabaseClearTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ TEST(database, clear_inactive_entities_database_simple)
EntityKind::HOST,
EntityKind::USER,
EntityKind::PROCESS,
EntityKind::DOMAIN,
EntityKind::DOMAIN_ENTITY,
EntityKind::TOPIC
};
for (const auto& kind : entities_kind_to_check)
Expand Down Expand Up @@ -242,7 +242,7 @@ TEST(database, clear_inactive_entities_database_simple)
}

// 2 entities remain: Domain and 1 locator
ASSERT_EQ(db.get_entity_ids(EntityKind::DOMAIN, EntityId::all()).size(), 1u);
ASSERT_EQ(db.get_entity_ids(EntityKind::DOMAIN_ENTITY, EntityId::all()).size(), 1u);
ASSERT_EQ(db.get_entity_ids(EntityKind::LOCATOR, EntityId::all()).size(), 1u);
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/unittest/Database/DatabaseEraseTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void erase_and_check(
db.load_database(initial_dump);

// Call erase monitor removing domain_1
std::vector<std::pair<EntityId, EntityId>> domains = db.get_entities_by_name(EntityKind::DOMAIN, domain);
std::vector<std::pair<EntityId, EntityId>> domains = db.get_entities_by_name(EntityKind::DOMAIN_ENTITY, domain);
EntityId domain_id = domains.begin()->first;
// Save entities associated to the erased domain to check that the cross maps are correctly erased.
std::vector<std::shared_ptr<const Entity>> participants = db.get_entities(EntityKind::PARTICIPANT, domain_id);
Expand Down Expand Up @@ -148,7 +148,7 @@ TEST(database_erase_tests, erase_domain_unlinked_participant_process)
"120");
}

// This test checks that calling erase with an EntityId that does not correspond with EntityKind::DOMAIN, kills the
// This test checks that calling erase with an EntityId that does not correspond with EntityKind::DOMAIN_ENTITY, kills the
// thread with an assertion
TEST(database_erase_tests, erase_wrong_kind)
{
Expand Down
Loading