summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-01-05 12:58:20 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-01-08 16:23:16 +0200
commit8b0de29c416c81be2d98b73effe6c7315b1fc1e1 (patch)
tree8713f726e6ce9051c34920879e374c829dc36f6d /src
parentf3829b5745be5ee448394da28b24943a807321bb (diff)
libcamera: camera_manager: Make the class a singleton
There can only be a single camera manager instance in the application. Creating it as a singleton helps avoiding mistakes. It also allows the camera manager to be used as a storage of global data, such as the future event dispatcher. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/camera_manager.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp
index 50a805fc..1a9d2f38 100644
--- a/src/libcamera/camera_manager.cpp
+++ b/src/libcamera/camera_manager.cpp
@@ -161,4 +161,19 @@ Camera *CameraManager::get(const std::string &name)
return nullptr;
}
+/**
+ * \brief Retrieve the camera manager instance
+ *
+ * The CameraManager is a singleton and can't be constructed manually. This
+ * function shall instead be used to retrieve the single global instance of the
+ * manager.
+ *
+ * \return The camera manager instance
+ */
+CameraManager *CameraManager::instance()
+{
+ static CameraManager manager;
+ return &manager;
+}
+
} /* namespace libcamera */