Skip to content

Commit 9e81f6c

Browse files
feat: better compile; material token access; gui color scheme galleries
1 parent 38168c2 commit 9e81f6c

4 files changed

Lines changed: 52 additions & 16 deletions

File tree

base/include/base/hash/constexpr_fnv1a.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ inline constexpr uint32_t fnv1a32_prime = 16777619U;
6161
* The FNV-1a algorithm provides excellent distribution and
6262
* minimal collisions for string identifiers.
6363
*
64-
* @param str Null-terminated string to hash.
65-
* @param seed Starting hash value (default: FNV offset basis).
64+
* @param[in] str Null-terminated string to hash.
65+
* @param[in] seed Starting hash value (default: FNV offset basis).
6666
*
6767
* @return 64-bit hash value.
6868
*
@@ -91,8 +91,8 @@ constexpr uint64_t fnv1a64(const char* str, uint64_t seed = fnv1a64_offset_basis
9191
/**
9292
* @brief FNV-1a 64-bit hash for std::string_view (runtime/constexpr).
9393
*
94-
* @param sv String view to hash.
95-
* @param seed Starting hash value (default: FNV offset basis).
94+
* @param[in] sv String view to hash.
95+
* @param[in] seed Starting hash value (default: FNV offset basis).
9696
*
9797
* @return 64-bit hash value.
9898
*
@@ -110,8 +110,8 @@ constexpr uint64_t fnv1a64(std::string_view sv, uint64_t seed = fnv1a64_offset_b
110110
/**
111111
* @brief FNV-1a 32-bit hash constexpr implementation.
112112
*
113-
* @param str Null-terminated string to hash.
114-
* @param seed Starting hash value (default: FNV offset basis).
113+
* @param[in] str Null-terminated string to hash.
114+
* @param[in] seed Starting hash value (default: FNV offset basis).
115115
*
116116
* @return 32-bit hash value.
117117
*
@@ -127,8 +127,8 @@ constexpr uint32_t fnv1a32(const char* str, uint32_t seed = fnv1a32_offset_basis
127127
/**
128128
* @brief FNV-1a 32-bit hash for std::string_view.
129129
*
130-
* @param sv String view to hash.
131-
* @param seed Starting hash value (default: FNV offset basis).
130+
* @param[in] sv String view to hash.
131+
* @param[in] seed Starting hash value (default: FNV offset basis).
132132
*
133133
* @return 32-bit hash value.
134134
*
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @file linux_impl.hpp
3+
* @brief Linux-specific memory implementation.
4+
*
5+
* @author Charliechen114514
6+
* @date 2026-02-25
7+
* @version 0.1
8+
* @since 0.1
9+
* @ingroup base_memory
10+
*/
11+
#pragma once

ui/core/material/cfmaterial_scheme.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ class CF_UI_EXPORT MaterialColorScheme : public ICFColorScheme {
219219
/**
220220
* @brief Query a color by name.
221221
*
222-
* @param name Color token name (e.g., "md.primary").
222+
* @param[in] name Color token name (e.g., "md.primary").
223223
* @return Reference to the QColor.
224224
*
225225
* @since 0.1
@@ -229,7 +229,7 @@ class CF_UI_EXPORT MaterialColorScheme : public ICFColorScheme {
229229
/**
230230
* @brief Query a color by name (const overload).
231231
*
232-
* @param name Color token name.
232+
* @param[in] name Color token name.
233233
* @return Copy of the QColor.
234234
*
235235
* @since 0.1

ui/core/token.hpp

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ namespace cf::ui::core {
3535
// Forward Declarations
3636
// =============================================================================
3737
class TokenRegistry;
38+
/// @brief Compile-time type-safe token with zero runtime overhead.
3839
template <typename T, uint64_t Hash> class StaticToken;
3940

4041
// =============================================================================
@@ -126,11 +127,19 @@ struct TokenError {
126127
*/
127128
template <typename T, uint64_t Hash> class StaticToken {
128129
public:
130+
/// @brief Value type stored in this token.
129131
using value_type = T;
132+
133+
/// @brief Compile-time hash of the token name.
130134
static constexpr uint64_t hash_value = Hash;
131135

136+
/// @brief Default constructor is deleted.
132137
StaticToken() = delete;
138+
139+
/// @brief Copy constructor is deleted.
133140
StaticToken(const StaticToken&) = delete;
141+
142+
/// @brief Copy assignment operator is deleted.
134143
StaticToken& operator=(const StaticToken&) = delete;
135144

136145
/**
@@ -302,7 +311,7 @@ class TokenRegistry {
302311
*
303312
* @tparam T Value type to store.
304313
* @param name Token name.
305-
* @param value Value to store (will be copied).
314+
* @param value Value to store (copied).
306315
*
307316
* @return Result containing void or TokenError.
308317
*
@@ -315,7 +324,7 @@ class TokenRegistry {
315324
*
316325
* @tparam T Value type to store.
317326
* @param name Token name.
318-
* @param value Value to store (will be moved).
327+
* @param value Value to store (moved).
319328
*
320329
* @return Result containing void or TokenError.
321330
*
@@ -448,11 +457,25 @@ class TokenRegistry {
448457
// Inline Implementations - StaticToken
449458
// =============================================================================
450459

460+
/**
461+
* @brief Type-safe value accessor for registry.
462+
*
463+
* @return cf::expected containing pointer to the token's value or TokenError.
464+
*
465+
* @since 0.1
466+
*/
451467
template <typename T, uint64_t Hash> auto StaticToken<T, Hash>::get()
452468
-> cf::expected<T*, TokenError> {
453469
return TokenRegistry::get().get<StaticToken<T, Hash>>();
454470
}
455471

472+
/**
473+
* @brief Const version of value accessor.
474+
*
475+
* @return cf::expected containing const pointer to the token's value or TokenError.
476+
*
477+
* @since 0.1
478+
*/
456479
template <typename T, uint64_t Hash> auto StaticToken<T, Hash>::get_const()
457480
-> cf::expected<const T*, TokenError> {
458481
return TokenRegistry::get().get_const<StaticToken<T, Hash>>();
@@ -826,7 +849,7 @@ class EmbeddedTokenRegistry {
826849
*
827850
* @tparam T Value type to store.
828851
* @param name Token name.
829-
* @param value Value to store (will be copied).
852+
* @param value Value to store (copied).
830853
*
831854
* @return Result containing void or TokenError.
832855
*
@@ -839,7 +862,7 @@ class EmbeddedTokenRegistry {
839862
*
840863
* @tparam T Value type to store.
841864
* @param name Token name.
842-
* @param value Value to store (will be moved).
865+
* @param value Value to store (moved).
843866
*
844867
* @return Result containing void or TokenError.
845868
*
@@ -1005,7 +1028,8 @@ inline const detail::TokenSlot* EmbeddedTokenRegistry::find_slot_const(uint64_t
10051028
}
10061029

10071030
template <typename T, typename... Args>
1008-
auto EmbeddedTokenRegistry::register_dynamic(std::string_view name, Args&&... args) -> Result<void> {
1031+
auto EmbeddedTokenRegistry::register_dynamic(std::string_view name, Args&&... args)
1032+
-> Result<void> {
10091033
uint64_t hash = cf::hash::fnv1a64(name);
10101034

10111035
std::unique_lock<std::shared_mutex> lock(registry_mutex_);
@@ -1027,7 +1051,8 @@ auto EmbeddedTokenRegistry::register_dynamic(std::string_view name, Args&&... ar
10271051
}
10281052

10291053
template <typename T>
1030-
auto EmbeddedTokenRegistry::register_dynamic(std::string_view name, const T& value) -> Result<void> {
1054+
auto EmbeddedTokenRegistry::register_dynamic(std::string_view name, const T& value)
1055+
-> Result<void> {
10311056
uint64_t hash = cf::hash::fnv1a64(name);
10321057

10331058
std::unique_lock<std::shared_mutex> lock(registry_mutex_);

0 commit comments

Comments
 (0)