From c7180f68aa305555ca93f53394b80991bdb20296 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=ED=95=9C=EC=A2=85/On-Device=20Lab=28SR=29/Enginee?= =?utf8?q?r/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Mon, 19 Aug 2019 11:21:03 +0900 Subject: [PATCH] [neurun] Write comments for class Index (#6608) This commit adds comments for class `util::Index`. Signed-off-by: Hanjoung Lee --- runtimes/neurun/core/include/util/Index.h | 72 +++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/runtimes/neurun/core/include/util/Index.h b/runtimes/neurun/core/include/util/Index.h index 9897d4b..d1fdc23 100644 --- a/runtimes/neurun/core/include/util/Index.h +++ b/runtimes/neurun/core/include/util/Index.h @@ -26,33 +26,95 @@ namespace neurun namespace util { +/** + * @brief A wrapper class for unsigned integral Index + * NOTE : Max value of the underlying type is used as the invalid value + * + * @tparam T Underlying type. Must be unsigned integral type otherwise its behavior is undefined. + * @tparam DummyTag Dummy type to distinguish types with a same underlying type. Using an opaque + * type is recommended. + */ template class Index { private: static const T UNDEFINED = std::numeric_limits::max(); public: + /** + * @brief Construct a new Index object + */ explicit Index(void) : _index{UNDEFINED} {} + /** + * @brief Construct a new Index object with a value in the underlying type + * + * @param o Value in the underlying type + */ explicit Index(T o) : _index{o} {} + /** + * @brief Copy Constructor + * + * @param o Object to be copied + */ Index(const Index &o) : _index{o._index} {} + /** + * @brief Assign a value in the underlying time + * + * @param o Value in the underlying type + * @return Index& Reference of this pointer + */ Index &operator=(T o) { _index = o; return *this; } + /** + * @brief Copy assignment operator + * + * @param o Object to be copied + * @return Index& Reference of this pointer + */ Index &operator=(const T &o) { _index = o._index; return *this; } + /** + * @brief Equality operator + * + * @param o The other value in the underlying type to compare + * @return true if underlying value is the same, false otherwise + */ bool operator==(T o) const { return _index == o; } + /** + * @brief Equality operator + * + * @param o The other object to compare + * @return true if underlying value is the same, false otherwise + */ bool operator==(const Index &o) const { return _index == o._index; } + /** + * @brief Inquality operator + * + * @param o The other value in the underlying type to compare + * @return true if underlying value is the same, false otherwise + */ bool operator!=(T o) const { return !(*this == o); } + /** + * @brief Inquality operator + * + * @param o The other object to compare + * @return true if underlying value is the same, false otherwise + */ bool operator!=(const Index &o) const { return !(*this == o); } + /** + * @brief Post increment operator + * + * @return Index Index before increment + */ Index operator++(int) { Index temp = *this; @@ -60,7 +122,17 @@ public: return temp; } + /** + * @brief Check whether the value is valid or not + * + * @return true if valid, false otherwise + */ bool valid() const { return _index != UNDEFINED; } + /** + * @brief Return underlying value + * + * @return T Underlying value + */ T value() const { return _index; } private: -- 2.7.4