Skip to content

Commit

Permalink
* Lowercasing for core/algorithms/static and core/containers/callback
Browse files Browse the repository at this point in the history
  • Loading branch information
harrand committed Jan 18, 2023
1 parent 06efaa2 commit de62eb7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
24 changes: 12 additions & 12 deletions src/tz/core/algorithms/static.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,36 @@ namespace tz
*
* Equivalent to:
* ```
* for(std::size_t i = Begin; i < End; i++)
* for(std::size_t i = begin; i < end; i++)
* {
* function(i);
* }
* ```
*/
template<std::size_t Begin, std::size_t End>
template<std::size_t begin, std::size_t end>
constexpr void static_for(tz::Action<std::size_t> auto function)
{
if constexpr(Begin < End)
if constexpr(begin < end)
{
function(std::integral_constant<std::size_t, Begin>{});
static_for<Begin + 1, End>(function);
function(std::integral_constant<std::size_t, begin>{});
static_for<begin + 1, end>(function);
}
}

/**
* @ingroup tz_core_algorithms
* Check if a Needle is found in a Haystack at compile-time.
* @tparam Needle Needle type to check exists within Haystack...
* @tparam Haystack Parameter pack which may or may not contain the type Needle.
* @return True if the template parameter pack 'Haystack' contains a type such that std::is_same<Needle, Type> is true. Otherwise, returns false.
* Check if a needle is found in a haystack at compile-time.
* @tparam needle needle type to check exists within haystack...
* @tparam haystack Parameter pack which may or may not contain the type needle.
* @return True if the template parameter pack 'haystack' contains a type such that std::is_same<needle, Type> is true. Otherwise, returns false.
*/
template<typename Needle, typename... Haystack>
template<typename needle, typename... haystack>
constexpr bool static_find()
{
bool b = false;
static_for<0, sizeof...(Haystack)>([&b]([[maybe_unused]] auto i) constexpr
static_for<0, sizeof...(haystack)>([&b]([[maybe_unused]] auto i) constexpr
{
if constexpr(std::is_same<std::decay_t<decltype(std::get<i.value>(std::declval<std::tuple<Haystack...>>()))>, Needle>::value)
if constexpr(std::is_same<std::decay_t<decltype(std::get<i.value>(std::declval<std::tuple<haystack...>>()))>, needle>::value)
{
b = true;
}
Expand Down
18 changes: 9 additions & 9 deletions src/tz/core/callback.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ namespace tz
{
namespace detail
{
struct CallbackType{};
struct callback_type{};
}
/**
* @ingroup tz_core_utility
* Opaque handle representing a reference to an existing @ref tz::Callback function.
* Opaque handle representing a reference to an existing @ref tz::callback function.
*/
using CallbackHandle = hdk::handle<detail::CallbackType>;
using callback_handle = hdk::handle<detail::callback_type>;

/**
* @ingroup tz_core_utility
Expand All @@ -27,29 +27,29 @@ namespace tz
*
*/
template<typename... Args>
class Callback
class callback
{
public:
/**
* Create an empty callback object with no registered callables.
*/
Callback() = default;
callback() = default;
/**
* Register a new callable with this callback object. The callable is assumed to remain valid until either the destruction of this callback object, or until it is manually deregistered.
* @param callback_function Callable matching the given signature.
* @return CallbackHandle corresponding to the registered callback. Cache this handle and use it to deregister the callable via @ref remove_callback once the lifetime of the provided callable reaches its end or the functionality is no longer required.
* @return callback_handle corresponding to the registered callback. Cache this handle and use it to deregister the callable via @ref remove_callback once the lifetime of the provided callable reaches its end or the functionality is no longer required.
*/
CallbackHandle add_callback(tz::Action<Args...> auto&& callback_function)
callback_handle add_callback(tz::Action<Args...> auto&& callback_function)
{
this->callback_storage.push_back(callback_function);
return static_cast<hdk::hanval>(this->callback_storage.size() - 1);
}
/**
* Deregister a callable that was registered by this callback object at some point in the past. The corresponding callable will no longer be invoked when the callback object is invoked.
*
* @param handle CallbackHandle corresponding to the result of a previous @ref add_callback invocation.
* @param handle callback_handle corresponding to the result of a previous @ref add_callback invocation.
*/
void remove_callback(CallbackHandle handle)
void remove_callback(callback_handle handle)
{
std::size_t handle_value = static_cast<std::size_t>(static_cast<hdk::hanval>(handle));
this->callback_storage[handle_value] = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/tz/dbgui/dbgui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace tz::dbgui
}

/// Represents a function taking no parameters and returning void.
using GameMenuCallbackType = tz::Callback<>;
using GameMenuCallbackType = tz::callback<>;
using GameBarCallbackType = GameMenuCallbackType;
/**
* @ingroup tz_dbgui
Expand Down
2 changes: 1 addition & 1 deletion src/tz/gl/impl/vulkan/renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace tz::gl
vk2::Image* new_depth_image;
};

using RendererResizeCallbackType = tz::Callback<RendererResizeInfoVulkan>;
using RendererResizeCallbackType = tz::callback<RendererResizeInfoVulkan>;

/**
* @ingroup tz_gl2_graphicsapi_vk_frontend
Expand Down

0 comments on commit de62eb7

Please sign in to comment.