[libcamera-devel] [PATCH 02/12] libcamera: signal: Replace object.h inclusion with forward declatation

Laurent Pinchart laurent.pinchart at ideasonboard.com
Sun Jan 21 04:59:38 CET 2024


The signal.h header doesn't need to include object.h. Replace it with a
forward declaration, and instead include object.h in source files that
require it. To can speed up compilation a little bit, but more
importantly avoids unintended dependencies from the Signal class to the
Object class to be added later as the compiler will catch them.

Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
 include/libcamera/base/signal.h                                | 3 ++-
 src/libcamera/base/bound_method.cpp                            | 1 +
 src/libcamera/base/signal.cpp                                  | 1 +
 src/libcamera/base/thread.cpp                                  | 1 +
 test/event-thread.cpp                                          | 1 +
 test/ipa/ipa_interface_test.cpp                                | 1 +
 test/message.cpp                                               | 1 +
 test/signal-threads.cpp                                        | 1 +
 test/timer-thread.cpp                                          | 1 +
 .../ipc/generators/libcamera_templates/module_ipa_proxy.h.tmpl | 1 +
 10 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/libcamera/base/signal.h b/include/libcamera/base/signal.h
index 841e4b4ca15c..444997b4525d 100644
--- a/include/libcamera/base/signal.h
+++ b/include/libcamera/base/signal.h
@@ -13,10 +13,11 @@
 #include <vector>
 
 #include <libcamera/base/bound_method.h>
-#include <libcamera/base/object.h>
 
 namespace libcamera {
 
+class Object;
+
 class SignalBase
 {
 public:
diff --git a/src/libcamera/base/bound_method.cpp b/src/libcamera/base/bound_method.cpp
index 3ecec51c4b75..c83d623f107d 100644
--- a/src/libcamera/base/bound_method.cpp
+++ b/src/libcamera/base/bound_method.cpp
@@ -7,6 +7,7 @@
 
 #include <libcamera/base/bound_method.h>
 #include <libcamera/base/message.h>
+#include <libcamera/base/object.h>
 #include <libcamera/base/semaphore.h>
 #include <libcamera/base/thread.h>
 
diff --git a/src/libcamera/base/signal.cpp b/src/libcamera/base/signal.cpp
index a46386a05abf..de51d060c21a 100644
--- a/src/libcamera/base/signal.cpp
+++ b/src/libcamera/base/signal.cpp
@@ -8,6 +8,7 @@
 #include <libcamera/base/signal.h>
 
 #include <libcamera/base/mutex.h>
+#include <libcamera/base/object.h>
 
 /**
  * \file base/signal.h
diff --git a/src/libcamera/base/thread.cpp b/src/libcamera/base/thread.cpp
index b96951ac19ba..75693c92a0b1 100644
--- a/src/libcamera/base/thread.cpp
+++ b/src/libcamera/base/thread.cpp
@@ -18,6 +18,7 @@
 #include <libcamera/base/log.h>
 #include <libcamera/base/message.h>
 #include <libcamera/base/mutex.h>
+#include <libcamera/base/object.h>
 
 /**
  * \page thread Thread Support
diff --git a/test/event-thread.cpp b/test/event-thread.cpp
index ef8a52c3de55..88a8c07ef9f0 100644
--- a/test/event-thread.cpp
+++ b/test/event-thread.cpp
@@ -11,6 +11,7 @@
 #include <unistd.h>
 
 #include <libcamera/base/event_notifier.h>
+#include <libcamera/base/object.h>
 #include <libcamera/base/thread.h>
 #include <libcamera/base/timer.h>
 
diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp
index 051ef96e7ed2..56f3cd6d57ba 100644
--- a/test/ipa/ipa_interface_test.cpp
+++ b/test/ipa/ipa_interface_test.cpp
@@ -16,6 +16,7 @@
 
 #include <libcamera/base/event_dispatcher.h>
 #include <libcamera/base/event_notifier.h>
+#include <libcamera/base/object.h>
 #include <libcamera/base/thread.h>
 #include <libcamera/base/timer.h>
 
diff --git a/test/message.cpp b/test/message.cpp
index d148a13d6c7a..0e76f323e3b9 100644
--- a/test/message.cpp
+++ b/test/message.cpp
@@ -11,6 +11,7 @@
 #include <thread>
 
 #include <libcamera/base/message.h>
+#include <libcamera/base/object.h>
 #include <libcamera/base/thread.h>
 
 #include "test.h"
diff --git a/test/signal-threads.cpp b/test/signal-threads.cpp
index d5e2eb662df2..8c550eb014d8 100644
--- a/test/signal-threads.cpp
+++ b/test/signal-threads.cpp
@@ -10,6 +10,7 @@
 #include <thread>
 
 #include <libcamera/base/message.h>
+#include <libcamera/base/object.h>
 #include <libcamera/base/thread.h>
 #include <libcamera/base/utils.h>
 
diff --git a/test/timer-thread.cpp b/test/timer-thread.cpp
index 618217538779..0bcd0d8ce194 100644
--- a/test/timer-thread.cpp
+++ b/test/timer-thread.cpp
@@ -9,6 +9,7 @@
 #include <iostream>
 
 #include <libcamera/base/event_dispatcher.h>
+#include <libcamera/base/object.h>
 #include <libcamera/base/thread.h>
 #include <libcamera/base/timer.h>
 
diff --git a/utils/ipc/generators/libcamera_templates/module_ipa_proxy.h.tmpl b/utils/ipc/generators/libcamera_templates/module_ipa_proxy.h.tmpl
index ed270f5cd49c..6e823598930e 100644
--- a/utils/ipc/generators/libcamera_templates/module_ipa_proxy.h.tmpl
+++ b/utils/ipc/generators/libcamera_templates/module_ipa_proxy.h.tmpl
@@ -18,6 +18,7 @@
 #include <libcamera/ipa/ipa_interface.h>
 #include <libcamera/ipa/{{module_name}}_ipa_interface.h>
 
+#include <libcamera/base/object.h>
 #include <libcamera/base/thread.h>
 
 #include "libcamera/internal/control_serializer.h"
-- 
Regards,

Laurent Pinchart



More information about the libcamera-devel mailing list