From 9770b548c5619821d7b6ea7a017df2b5a6898d0a Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Mon, 18 Nov 2024 18:10:31 +0100 Subject: add doxygen comments --- src/crepe/api/Asset.h | 10 +++++++++- src/crepe/util/OptionalRef.h | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/crepe/api/Asset.h b/src/crepe/api/Asset.h index 05dccba..685dd3a 100644 --- a/src/crepe/api/Asset.h +++ b/src/crepe/api/Asset.h @@ -1,7 +1,6 @@ #pragma once #include -#include namespace crepe { @@ -52,7 +51,16 @@ private: namespace std { +//! Hash helper struct template<> struct hash { + /** + * \brief Hash operator for crepe::Asset + * + * This function hashes a crepe::Asset instance, allowing it to be used as a key in an \c + * std::unordered_map. + * + * \returns Hash value + */ size_t operator()(const crepe::Asset & asset) const noexcept; }; diff --git a/src/crepe/util/OptionalRef.h b/src/crepe/util/OptionalRef.h index 1ad3a6d..8417a25 100644 --- a/src/crepe/util/OptionalRef.h +++ b/src/crepe/util/OptionalRef.h @@ -12,18 +12,51 @@ namespace crepe { template class OptionalRef { public: + //! Initialize empty (nonexistant) reference OptionalRef() = default; - OptionalRef(T &); - OptionalRef & operator=(T &); + //! Initialize reference with value + OptionalRef(T & ref); + /** + * \brief Assign new reference + * + * \param ref Reference to assign + * + * \return Reference to this (required for operator) + */ + OptionalRef & operator=(T & ref); + /** + * \brief Check if this reference is not empty + * + * \returns `true` if reference is set, or `false` if it is not + */ explicit operator bool() const noexcept; + /** + * \brief Assign new reference + * + * \param ref Reference to assign + */ void set(T &) noexcept; + /** + * \brief Retrieve this reference + * + * \returns Internal reference if it is set + * + * \throws std::runtime_error if this function is called while the reference it not set + */ T & get() const; + /** + * \brief Make this reference empty + */ void clear() noexcept; + //! Copy constructor OptionalRef(const OptionalRef &); + //! Move constructor OptionalRef(OptionalRef &&); + //! Copy assignment OptionalRef & operator=(const OptionalRef &); + //! Move assignment OptionalRef & operator=(OptionalRef &&); private: -- cgit v1.2.3