summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-04-06 18:12:54 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-04-07 10:20:28 +0300
commite2d00fbcbb1a9b2da50fa2e280817a0de1a7d286 (patch)
tree4316fa4c60da30057933a19c1ebc4e82879494a8
parent1a9587b8f2de010026784c251179a64105f1fc91 (diff)
libcamera: base: utils: Add missing constructor for Duration
The Duration class is missing the equivalent to the std::chrono::duration constructor that takes a number of ticks expressed as a scalar. Fix it, which allows initializing a Duration instance to 0 or 0.0. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
-rw-r--r--include/libcamera/base/utils.h6
-rw-r--r--src/libcamera/base/utils.cpp9
2 files changed, 15 insertions, 0 deletions
diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h
index 9ab18101..cfff0583 100644
--- a/include/libcamera/base/utils.h
+++ b/include/libcamera/base/utils.h
@@ -327,6 +327,12 @@ class Duration : public std::chrono::duration<double, std::nano>
public:
Duration() = default;
+ template<typename Rep>
+ constexpr explicit Duration(const Rep &r)
+ : BaseDuration(r)
+ {
+ }
+
template<typename Rep, typename Period>
constexpr Duration(const std::chrono::duration<Rep, Period> &d)
: BaseDuration(d)
diff --git a/src/libcamera/base/utils.cpp b/src/libcamera/base/utils.cpp
index 8cf8a5b2..6a307940 100644
--- a/src/libcamera/base/utils.cpp
+++ b/src/libcamera/base/utils.cpp
@@ -407,6 +407,15 @@ std::string toAscii(const std::string &str)
*/
/**
+ * \fn Duration::Duration(const Rep &r)
+ * \brief Construct a Duration with \a r ticks
+ * \param[in] r The number of ticks
+ *
+ * The constructed \a Duration object is internally represented in double
+ * precision with \a r nanoseconds ticks.
+ */
+
+/**
* \fn Duration::Duration(const std::chrono::duration<Rep, Period> &d)
* \brief Construct a Duration by converting an arbitrary std::chrono::duration
* \param[in] d The std::chrono::duration object to convert from