Skip to content

Commit

Permalink
style: follow clang-tidy suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
RiscadoA committed Jan 22, 2024
1 parent 9c75392 commit 0f22bb4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 35 deletions.
57 changes: 28 additions & 29 deletions core/include/cubos/core/ecs/table/sparse_relation/registry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,34 @@ namespace cubos::core::ecs
SparseRelationTableRegistry();

/// @brief Stores the ids of tables of a given type.
class TypeIndex;
class TypeIndex
{
public:
/// @brief Inserts a new table identifier into the index.
/// @param id Table identifier.
void insert(SparseRelationTableId id);

/// @brief Returns a reference to a map which maps archetypes to the tables where it is the 'from'
/// archetype.
/// @return Map from archetypes to vectors of table identifiers.
const auto& from() const
{
return mSparseRelationTableIdsByFrom;
}

/// @brief Returns a reference to a map which maps archetypes to the tables where it is the 'to' archetype.
/// @return Map from archetypes to vectors of table identifiers.
const auto& to() const
{
return mSparseRelationTableIdsByTo;
}

private:
std::unordered_map<ArchetypeId, std::vector<SparseRelationTableId>, ArchetypeIdHash>
mSparseRelationTableIdsByFrom;
std::unordered_map<ArchetypeId, std::vector<SparseRelationTableId>, ArchetypeIdHash>
mSparseRelationTableIdsByTo;
};

/// @brief Checks if there's a table with the given identifier.
/// @param id Identifier.
Expand Down Expand Up @@ -104,32 +131,4 @@ namespace cubos::core::ecs
std::vector<SparseRelationTableId> mIds;
TypeIndex* mEmptyTypeIndex; ///< Used as a placeholder when a type hasn't been registered yet.
};

class SparseRelationTableRegistry::TypeIndex
{
public:
/// @brief Inserts a new table identifier into the index.
/// @param id Table identifier.
void insert(SparseRelationTableId id);

/// @brief Returns a reference to a map which maps archetypes to the tables where it is the 'from' archetype.
/// @return Map from archetypes to vectors of table identifiers.
const auto& from() const
{
return mSparseRelationTableIdsByFrom;
}

/// @brief Returns a reference to a map which maps archetypes to the tables where it is the 'to' archetype.
/// @return Map from archetypes to vectors of table identifiers.
const auto& to() const
{
return mSparseRelationTableIdsByTo;
}

private:
std::unordered_map<ArchetypeId, std::vector<SparseRelationTableId>, ArchetypeIdHash>
mSparseRelationTableIdsByFrom;
std::unordered_map<ArchetypeId, std::vector<SparseRelationTableId>, ArchetypeIdHash>
mSparseRelationTableIdsByTo;
};
} // namespace cubos::core::ecs
4 changes: 1 addition & 3 deletions engine/src/cubos/engine/transform/position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@

CUBOS_REFLECT_IMPL(cubos::engine::Position)
{
return core::ecs::TypeBuilder<Position>("cubos::engine::Position")
.withField("vec", &Position::vec)
.build();
return core::ecs::TypeBuilder<Position>("cubos::engine::Position").withField("vec", &Position::vec).build();
}
4 changes: 1 addition & 3 deletions engine/src/cubos/engine/transform/rotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@

CUBOS_REFLECT_IMPL(cubos::engine::Rotation)
{
return core::ecs::TypeBuilder<Rotation>("cubos::engine::Rotation")
.withField("quat", &Rotation::quat)
.build();
return core::ecs::TypeBuilder<Rotation>("cubos::engine::Rotation").withField("quat", &Rotation::quat).build();
}

0 comments on commit 0f22bb4

Please sign in to comment.