Skip to content

Commit

Permalink
Clean up API naming for non get/set pairs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ASxa86 committed Jun 17, 2024
1 parent 83003d7 commit f070c27
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions include/aspire/core/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace aspire::core

/// @brief Get the owning parent of this object.
/// @return The pointer to the owning parent. Nullptr if this object does not have a parent.
[[nodiscard]] auto getParent() const -> Object*;
[[nodiscard]] auto parent() const -> Object*;

/// @brief Add the given object to this object as a child. Claiming ownership of the child object.
/// @param x The object to be added to this object.
Expand All @@ -66,7 +66,7 @@ namespace aspire::core

/// @brief Get the, read-only, list of child objects.
/// @return The list of children owned by this object.
[[nodiscard]] auto getChildren() const -> const std::vector<std::unique_ptr<Object>>&;
[[nodiscard]] auto children() const -> const std::vector<std::unique_ptr<Object>>&;

/// @brief Override to handle any event this object has received.
/// @param x The event to be handled.
Expand Down
4 changes: 2 additions & 2 deletions src/core/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ auto Object::getName() const -> std::string_view
return this->pimpl->name;
}

auto Object::getParent() const -> Object*
auto Object::parent() const -> Object*
{
return this->pimpl->parent;
}
Expand Down Expand Up @@ -79,7 +79,7 @@ auto Object::remove() -> std::unique_ptr<Object>
return node;
}

auto Object::getChildren() const -> const std::vector<std::unique_ptr<Object>>&
auto Object::children() const -> const std::vector<std::unique_ptr<Object>>&
{
return this->pimpl->children;
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/test/Object.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ TEST(Object, remove)
auto child = std::make_unique<Object>();
auto* childObject = child.get();
parent.addChild(std::move(child));
EXPECT_EQ(childObject->getParent(), &parent);
EXPECT_FALSE(parent.getChildren().empty());
EXPECT_EQ(childObject->parent(), &parent);
EXPECT_FALSE(parent.children().empty());

child = childObject->remove();
ASSERT_NE(child, nullptr);
EXPECT_EQ(child->getParent(), nullptr);
EXPECT_TRUE(parent.getChildren().empty());
EXPECT_EQ(child->parent(), nullptr);
EXPECT_TRUE(parent.children().empty());
}

0 comments on commit f070c27

Please sign in to comment.