Skip to content

Commit

Permalink
Add missing methods attributes/specifiers to util namespace
Browse files Browse the repository at this point in the history
Linked: #171
  • Loading branch information
AndreasLrx committed Oct 18, 2024
1 parent 9788234 commit 4354a3c
Show file tree
Hide file tree
Showing 36 changed files with 323 additions and 295 deletions.
6 changes: 3 additions & 3 deletions src/ecstasy/integrations/user_action/UserProfile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace ecstasy::integration::user_action
/// @author Andréas Leroux ([email protected])
/// @since 1.0.0 (2022-11-25)
///
constexpr ActionBindings &getActionBindings() noexcept
[[nodiscard]] constexpr ActionBindings &getActionBindings() noexcept
{
return _actionBindings;
}
Expand All @@ -65,7 +65,7 @@ namespace ecstasy::integration::user_action
/// @author Andréas Leroux ([email protected])
/// @since 1.0.0 (2022-11-25)
///
constexpr const ActionBindings &getActionBindings() const noexcept
[[nodiscard]] constexpr const ActionBindings &getActionBindings() const noexcept
{
return _actionBindings;
}
Expand All @@ -80,7 +80,7 @@ namespace ecstasy::integration::user_action
/// @author Andréas Leroux ([email protected])
/// @since 1.0.0 (2022-12-02)
///
constexpr Id getId() const noexcept
[[nodiscard]] constexpr Id getId() const noexcept
{
return _id;
}
Expand Down
6 changes: 3 additions & 3 deletions src/ecstasy/integrations/user_action/Users.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@

namespace ecstasy::integration::user_action
{
Users::Users(size_t count) noexcept : _users(count)
Users::Users(size_t count) : _users(count)
{
for (size_t i = 1; i < count; i++)
_users[i].setId(i);
}

void Users::updateBindings(Registry &registry) noexcept
void Users::updateBindings(Registry &registry)
{
if (!registry.hasResource<Users>()) [[unlikely]]
return;
registry.getResource<Users>()->updateBindings();
}

void Users::updateBindings() noexcept
void Users::updateBindings()
{
removeOutdatedBindings(_mouseButtonToAction);
removeOutdatedBindings(_keyToAction);
Expand Down
18 changes: 10 additions & 8 deletions src/ecstasy/integrations/user_action/Users.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ namespace ecstasy::integration::user_action
/// @author Andréas Leroux ([email protected])
/// @since 1.0.0 (2022-12-02)
///
Users(size_t count = 1) noexcept;
Users(size_t count = 1);

///
/// @brief Default destructor.
///
/// @author Andréas Leroux ([email protected])
/// @since 1.0.0 (2022-12-02)
///
~Users() noexcept = default;
~Users() = default;

///
/// @brief Update the internal bindings associative maps.
Expand All @@ -75,7 +75,7 @@ namespace ecstasy::integration::user_action
/// @author Andréas Leroux ([email protected])
/// @since 1.0.0 (2022-12-02)
///
void updateBindings() noexcept;
void updateBindings();

///
/// @brief Fetch the @ref Users resource in the registry if available and call @ref updateBindings().
Expand All @@ -85,7 +85,7 @@ namespace ecstasy::integration::user_action
/// @author Andréas Leroux ([email protected])
/// @since 1.0.0 (2022-12-02)
///
static void updateBindings(Registry &registry) noexcept;
static void updateBindings(Registry &registry);

///
/// @brief Call action listeners associated to the event if any.
Expand All @@ -107,16 +107,18 @@ namespace ecstasy::integration::user_action
///
/// @return UserProfile& A reference to the requested user.
///
/// @throw std::out_of_range If the index is out of bounds.
///
/// @author Andréas Leroux ([email protected])
/// @since 1.0.0 (2022-12-05)
///
[[nodiscard]] constexpr UserProfile &getUserProfile(size_t index = 0) noexcept
[[nodiscard]] constexpr UserProfile &getUserProfile(size_t index = 0)
{
return _users[index];
}

/// @copydoc getUserProfile
[[nodiscard]] constexpr const UserProfile &getUserProfile(size_t index = 0) const noexcept
[[nodiscard]] constexpr const UserProfile &getUserProfile(size_t index = 0) const
{
return _users[index];
}
Expand All @@ -125,7 +127,7 @@ namespace ecstasy::integration::user_action
/// @internal
/// @brief Remove the bindings present in @p map and not in the @p _users bindings.
template <typename T>
void removeOutdatedBindings(std::unordered_multimap<T, UserActionLink> &map) noexcept
void removeOutdatedBindings(std::unordered_multimap<T, UserActionLink> &map)
{
for (auto it = map.begin(); it != map.end();) {
if (it->second.userId >= _users.size()
Expand All @@ -141,7 +143,7 @@ namespace ecstasy::integration::user_action
/// @brief Add the @p binding in the @p map if it is missing for the user @p user.
template <typename T>
void addBindingIfMissing(const UserProfile &user, const ActionBinding &binding, T input,
std::unordered_multimap<T, UserActionLink> &map) noexcept
std::unordered_multimap<T, UserActionLink> &map)
{
bool add = true;
auto range = map.equal_range(input);
Expand Down
3 changes: 1 addition & 2 deletions src/ecstasy/thread/Lockable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ namespace ecstasy::thread
/// @since 1.0.0 (20224-31-03)
///
template <typename L>
concept Lockable = requires(L &lockable)
{
concept Lockable = requires(L &lockable) {
// clang-format off
{ lockable.lock() } -> std::same_as<void>;
{ lockable.unlock() } -> std::same_as<void>;
Expand Down
2 changes: 1 addition & 1 deletion src/util/Allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace util
/// @since 1.0.0 (2022-10-24)
///
template <std::derived_from<Base> T, typename... Args>
T &instanciate(Args &&...args)
[[nodiscard]] T &instanciate(Args &&...args)
{
return dynamic_cast<T &>(*_instances.emplace_back(std::make_unique<T>(std::forward<Args>(args)...)).get());
}
Expand Down
18 changes: 9 additions & 9 deletions src/util/BitSet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,23 @@ namespace util
BitSet(std::string_view bitString);

/// @returns The number of bits in the set.
constexpr std::size_t size() const noexcept
[[nodiscard]] constexpr std::size_t size() const noexcept
{
return this->_size;
}

/// @note This function does not perform bounds-checking.
///
/// @returns The value of the bit at @b pos.
BIT_SET_CONSTEXPR bool test(std::size_t pos) const noexcept
[[nodiscard]] BIT_SET_CONSTEXPR bool test(std::size_t pos) const noexcept
{
return (this->_store[pos >> 6] & mask(pos)) != 0;
}

/// @note This function does not perform bounds-checking.
///
/// @returns The value of the bit at @b pos.
BIT_SET_CONSTEXPR bool operator[](std::size_t pos) const noexcept
[[nodiscard]] BIT_SET_CONSTEXPR bool operator[](std::size_t pos) const noexcept
{
return this->test(pos);
}
Expand Down Expand Up @@ -129,10 +129,10 @@ namespace util
}

/// @returns Whether the bit sets are equal, both sets must have the same size.
bool operator==(BitSet const &other) const noexcept;
[[nodiscard]] bool operator==(BitSet const &other) const noexcept;

/// @returns Whether the bit sets are not equal, both sets must have the same size.
bool operator!=(BitSet const &other) const noexcept;
[[nodiscard]] bool operator!=(BitSet const &other) const noexcept;

/// Flips all the bits in the set.
///
Expand Down Expand Up @@ -226,7 +226,7 @@ namespace util
/// @param start The bit position of where to start the search for a set bit.
///
/// @returns The position of the first set bit.
BIT_SET_CONSTEXPR std::size_t firstSet(std::size_t start = 0) const
[[nodiscard]] BIT_SET_CONSTEXPR std::size_t firstSet(std::size_t start = 0) const
{
std::uint64_t mask = (~std::uint64_t(0)) << (start & 0b111111);
std::size_t word_pos = start >> 6;
Expand All @@ -244,7 +244,7 @@ namespace util
/// @note If the set does not contain a single 'one' bit, the return value is 0.
///
/// @returns The position of the last set bit.
BIT_SET_CONSTEXPR std::size_t lastSet() const
[[nodiscard]] BIT_SET_CONSTEXPR std::size_t lastSet() const
{
std::uint64_t mask = ~((~std::uint64_t(0)) << (_size & 0b111111));
std::size_t word_pos = _size >> 6;
Expand All @@ -269,7 +269,7 @@ namespace util
/// @param start The bit position of where to start the search for an unset bit.
///
/// @returns The position of the first unset bit.
BIT_SET_CONSTEXPR std::size_t firstUnset(std::size_t start = 0) const
[[nodiscard]] BIT_SET_CONSTEXPR std::size_t firstUnset(std::size_t start = 0) const
{
std::uint64_t mask = (~std::uint64_t(0)) << (start & 0b111111);
std::size_t word_pos = start >> 6;
Expand All @@ -287,7 +287,7 @@ namespace util
/// @note If the set does not contain a single 'zero' bit, the return value is 0.
///
/// @returns The position of the last set bit.
BIT_SET_CONSTEXPR std::size_t lastUnset() const
[[nodiscard]] BIT_SET_CONSTEXPR std::size_t lastUnset() const
{
std::uint64_t mask = ~((~std::uint64_t(0)) << (_size & 0b111111));
std::size_t word_pos = _size >> 6;
Expand Down
4 changes: 2 additions & 2 deletions src/util/StackAllocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ namespace util
/// @since 1.0.0 (2022-10-24)
///
template <std::derived_from<Base> T, typename... Args>
T &instanciate(Args &&...args)
[[nodiscard]] T &instanciate(Args &&...args)
{
T *newObject = new (reinterpret_cast<void *>(&_memory[_cursor])) T(std::forward<Args>(args)...);

Expand All @@ -130,7 +130,7 @@ namespace util
/// @author Andréas Leroux ([email protected])
/// @since 1.0.0 (2023-11-08)
///
constexpr const std::vector<Base *> &getInstances() const
[[nodiscard]] constexpr const std::vector<Base *> &getInstances() const noexcept
{
return _instances;
}
Expand Down
2 changes: 1 addition & 1 deletion src/util/meta/Traits.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
///
/// @file Traits.hpp
/// @author Andréas Leroux ([email protected])
/// @brief
/// @brief Helper types for parameter packs.
/// @version 1.0.0
/// @date 2022-10-28
///
Expand Down
2 changes: 1 addition & 1 deletion src/util/meta/add_optional.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
///
/// @file add_optional.hpp
/// @author Andréas Leroux ([email protected])
/// @brief
/// @brief Add std::optional to a type if required.
/// @version 1.0.0
/// @date 2022-10-27
///
Expand Down
2 changes: 1 addition & 1 deletion src/util/meta/apply.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
///
/// @file apply.hpp
/// @author Andréas Leroux ([email protected])
/// @brief
/// @brief Apply a modification on all types in a list.
/// @version 1.0.0
/// @date 2022-12-15
///
Expand Down
2 changes: 1 addition & 1 deletion src/util/meta/contains.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
///
/// @file contains.hpp
/// @author Andréas Leroux ([email protected])
/// @brief
/// @brief Checks if a type exists in a list of types.
/// @version 1.0.0
/// @date 2022-10-28
///
Expand Down
2 changes: 1 addition & 1 deletion src/util/meta/filter.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
///
/// @file filter.hpp
/// @author Andréas Leroux ([email protected])
/// @brief
/// @brief Filter types from a list.
/// @version 1.0.0
/// @date 2022-12-15
///
Expand Down
2 changes: 1 addition & 1 deletion src/util/meta/index.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
///
/// @file index.hpp
/// @author Andréas Leroux ([email protected])
/// @brief
/// @brief Get the index of the first occurence of a type in a list of types.
/// @version 1.0.0
/// @date 2022-10-28
///
Expand Down
2 changes: 1 addition & 1 deletion src/util/meta/is_std_vector.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
///
/// @file is_std_vector.hpp
/// @author Andréas Leroux ([email protected])
/// @brief
/// @brief Check if a type is a std::vector.
/// @version 1.0.0
/// @date 2024-04-30
///
Expand Down
2 changes: 1 addition & 1 deletion src/util/meta/is_type_bounded_array.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
///
/// @file is_type_bounded_array.hpp
/// @author Andréas Leroux ([email protected])
/// @brief
/// @brief Check if a type is a bounded array of a given element type.
/// @version 1.0.0
/// @date 2024-10-10
///
Expand Down
2 changes: 1 addition & 1 deletion src/util/meta/outer_join.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
///
/// @file outer_join.hpp
/// @author Andréas Leroux ([email protected])
/// @brief
/// @brief Performs a left outer join between two parameter packs.
/// @version 1.0.0
/// @date 2022-10-28
///
Expand Down
2 changes: 1 addition & 1 deletion src/util/meta/type_set_eq.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
///
/// @file type_set_eq.hpp
/// @author Andréas Leroux ([email protected])
/// @brief
/// @brief Test if two tuple types contains the exact same types independently of the order.
/// @version 1.0.0
/// @date 2022-10-28
///
Expand Down
Loading

0 comments on commit 4354a3c

Please sign in to comment.