Skip to content

Commit 0e21ab0

Browse files
committed
constanst docs + mkdoxy update
1 parent 84b777a commit 0e21ab0

2 files changed

Lines changed: 72 additions & 1 deletion

File tree

include/gl/constants.hpp

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// This file is part of the CPP-GL project (https://github.com/SpectraL519/cpp-gl).
33
// Licensed under the MIT License. See the LICENSE file in the project root for full license information.
44

5+
/// @file gl/constants.hpp
6+
/// @brief Defines common constant values and types used across the CPP-GL library.
7+
58
#pragma once
69

710
#include "gl/types/core.hpp"
@@ -10,35 +13,103 @@
1013

1114
namespace gl {
1215

16+
/// @ingroup GL GL-Core
17+
/// @brief A constant representing the initial ID value of 0 for graph elements.
18+
/// @tparam IdType The type of the ID, which must satisfy the [**c_id_type**](gl_traits.md#gl-traits-c-id-type) concept.
19+
/// ### See Also
20+
/// - [**c_id_type**](gl_traits.md#gl-traits-c-id-type)
21+
/// - @ref gl::initial_id_t "initial_id_t"
22+
/// - @ref gl::initial_id "initial_id"
1323
template <traits::c_id_type IdType>
1424
inline constexpr IdType initial_id_v{0};
1525

26+
/// @ingroup GL GL-Core
27+
/// @brief A helper type that can be implicitly converted to the initial ID value of 0 for any valid ID type.
28+
/// ### See Also
29+
/// - [**c_id_type**](gl_traits.md#gl-traits-c-id-type)
30+
/// - @ref gl::initial_id_v "initial_id_v"
31+
/// - @ref gl::initial_id "initial_id"
1632
struct initial_id_t {
33+
/// @brief Implicitly converts to the initial ID value of 0 for any type that satisfies the [**c_id_type**](gl_traits.md#gl-traits-c-id-type) concept.
1734
template <traits::c_id_type IdType>
1835
[[nodiscard]] constexpr operator IdType() const noexcept {
1936
return initial_id_v<IdType>;
2037
}
2138
};
2239

40+
/// @ingroup GL GL-Core
41+
/// @brief A constant instance of `initial_id_t` that can be used to represent the initial ID value of 0 for graph elements in a type-safe manner.
42+
///
43+
/// ### Example Usage
44+
/// ```cpp
45+
/// using vertex_id_t = std::uint32_t;
46+
/// vertex_id_t v1 = gl::initial_id; // (1)!
47+
/// ```
48+
///
49+
/// 1\. The `initial_id` constant can be implicitly converted to the `v1`'s type (`vertex_id_t`), resulting in `v1` being initialized to the value of 0.
50+
///
51+
/// ### See Also
52+
/// - [**c_id_type**](gl_traits.md#gl-traits-c-id-type)
53+
/// - @ref gl::initial_id_v "initial_id_v"
54+
/// - @ref gl::initial_id_t "initial_id_t"
2355
inline constexpr initial_id_t initial_id{};
2456

2557
// --- invalid id ---
2658

59+
/// @ingroup GL GL-Core
60+
/// @brief A constant representing the invalid ID value for graph elements, defined as the maximum value of the specified ID type.
61+
/// @tparam IdType The type of the ID, which must satisfy the [**c_id_type**](gl_traits.md#gl-traits-c-id-type) concept.
62+
/// ### See Also
63+
/// - [**c_id_type**](gl_traits.md#gl-traits-c-id-type)
64+
/// - @ref gl::invalid_id_t "invalid_id_t"
65+
/// - @ref gl::invalid_id "invalid_id"
2766
template <traits::c_id_type IdType>
2867
inline constexpr IdType invalid_id_v{std::numeric_limits<IdType>::max()};
2968

69+
/// @ingroup GL GL-Core
70+
/// @brief A helper type that can be implicitly converted to the invalid ID value for any valid ID type.
71+
/// ### See Also
72+
/// - [**c_id_type**](gl_traits.md#gl-traits-c-id-type)
73+
/// - @ref gl::invalid_id_v "invalid_id_v"
74+
/// - @ref gl::invalid_id "invalid_id"
3075
struct invalid_id_t {
76+
/// @brief Implicitly converts to the invalid ID value for any type that satisfies the [**c_id_type**](gl_traits.md#gl-traits-c-id-type) concept.
3177
template <traits::c_id_type IdType>
3278
[[nodiscard]] constexpr operator IdType() const noexcept {
3379
return invalid_id_v<IdType>;
3480
}
3581

82+
/// @brief Equality comparison operator to compare an ID value with the invalid ID constant.
83+
///
84+
/// This operator allows for direct comparison between an ID value and the `invalid_id` constant,
85+
/// enabling easy checking if a given ID is invalid without needing to explicitly reference
86+
/// the `invalid_id_v` constant for the specific ID type.
87+
///
88+
/// @tparam IdType The type of the ID, which must satisfy the [**c_id_type**](gl_traits.md#gl-traits-c-id-type) concept.
89+
/// @param lhs The ID value to compare againsyt the invalid ID constant.
90+
/// @param rhs The `invalid_id` constant (of type `invalid_id_t`) to compare with the ID value.
91+
/// @return Returns `true` if `lhs` is equal to the invalid ID value for its type, and `false` otherwise.
3692
template <traits::c_id_type IdType>
3793
[[nodiscard]] friend constexpr bool operator==(const IdType& lhs, invalid_id_t) noexcept {
3894
return lhs == invalid_id_v<IdType>;
3995
}
4096
};
4197

98+
/// @ingroup GL GL-Core
99+
/// @brief A constant instance of `invalid_id_t` that can be used to represent the invalid ID value for graph elements in a type-safe manner.
100+
///
101+
/// ### Example Usage
102+
/// ```cpp
103+
/// using vertex_id_t = std::uint32_t;
104+
/// vertex_id_t v1 = gl::invalid_id; // (1)!
105+
/// ```
106+
///
107+
/// 1\. The `invalid_id` constant can be implicitly converted to the `v1`'s type (`vertex_id_t`), resulting in `v1` being initialized to the maximum value of `vertex_id_t`, which represents an invalid ID.
108+
///
109+
/// ### See Also
110+
/// - [**c_id_type**](gl_traits.md#gl-traits-c-id-type)
111+
/// - @ref gl::invalid_id_v "invalid_id_v"
112+
/// - @ref gl::invalid_id_t "invalid_id_t"
42113
inline constexpr invalid_id_t invalid_id{};
43114

44115
} // namespace gl

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)