[libcamera-devel] libcamera: fix odd include file hierarchy

Message ID 20190123112957.25580-1-niklas.soderlund@ragnatech.se
State Accepted
Headers show
Series
  • [libcamera-devel] libcamera: fix odd include file hierarchy
Related show

Commit Message

Niklas Söderlund Jan. 23, 2019, 11:29 a.m. UTC
There is no need for pipeline_handler.h to include camera.h, instead it
should be included in the source file which needs it;
camera_manager.cpp. Fix this by adding a forward declaration of Camera
in pipeline_handler.h and include the header in the correct file.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 src/libcamera/camera_manager.cpp         | 1 +
 src/libcamera/include/pipeline_handler.h | 3 +--
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Laurent Pinchart Jan. 23, 2019, 3:51 p.m. UTC | #1
Hi Niklas,

Thank you for the patch.

On Wed, Jan 23, 2019 at 12:29:57PM +0100, Niklas Söderlund wrote:
> There is no need for pipeline_handler.h to include camera.h, instead it
> should be included in the source file which needs it;
> camera_manager.cpp. Fix this by adding a forward declaration of Camera
> in pipeline_handler.h and include the header in the correct file.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> ---
>  src/libcamera/camera_manager.cpp         | 1 +
>  src/libcamera/include/pipeline_handler.h | 3 +--
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp
> index 37ccbd533790856a..4ea7ed44cc31f747 100644
> --- a/src/libcamera/camera_manager.cpp
> +++ b/src/libcamera/camera_manager.cpp
> @@ -5,6 +5,7 @@
>   * camera_manager.h - Camera management
>   */
>  
> +#include <libcamera/camera.h>
>  #include <libcamera/camera_manager.h>
>  #include <libcamera/event_dispatcher.h>
>  
> diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h
> index f05f201f7ca824eb..87dc3debd795eb3e 100644
> --- a/src/libcamera/include/pipeline_handler.h
> +++ b/src/libcamera/include/pipeline_handler.h
> @@ -11,10 +11,9 @@
>  #include <string>
>  #include <vector>
>  
> -#include <libcamera/camera.h>
> -
>  namespace libcamera {
>  
> +class Camera;

In the master branch this isn't needed, you can drop the forward
declaration (please make sure everything compiles :-))..

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  class CameraManager;
>  class DeviceEnumerator;
>
Niklas Söderlund Jan. 23, 2019, 4:03 p.m. UTC | #2
Hi Laurent,

On 2019-01-23 17:51:26 +0200, Laurent Pinchart wrote:
> Hi Niklas,
> 
> Thank you for the patch.
> 
> On Wed, Jan 23, 2019 at 12:29:57PM +0100, Niklas Söderlund wrote:
> > There is no need for pipeline_handler.h to include camera.h, instead it
> > should be included in the source file which needs it;
> > camera_manager.cpp. Fix this by adding a forward declaration of Camera
> > in pipeline_handler.h and include the header in the correct file.
> > 
> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> > ---
> >  src/libcamera/camera_manager.cpp         | 1 +
> >  src/libcamera/include/pipeline_handler.h | 3 +--
> >  2 files changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp
> > index 37ccbd533790856a..4ea7ed44cc31f747 100644
> > --- a/src/libcamera/camera_manager.cpp
> > +++ b/src/libcamera/camera_manager.cpp
> > @@ -5,6 +5,7 @@
> >   * camera_manager.h - Camera management
> >   */
> >  
> > +#include <libcamera/camera.h>
> >  #include <libcamera/camera_manager.h>
> >  #include <libcamera/event_dispatcher.h>
> >  
> > diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h
> > index f05f201f7ca824eb..87dc3debd795eb3e 100644
> > --- a/src/libcamera/include/pipeline_handler.h
> > +++ b/src/libcamera/include/pipeline_handler.h
> > @@ -11,10 +11,9 @@
> >  #include <string>
> >  #include <vector>
> >  
> > -#include <libcamera/camera.h>
> > -
> >  namespace libcamera {
> >  
> > +class Camera;
> 
> In the master branch this isn't needed, you can drop the forward
> declaration (please make sure everything compiles :-))..

You are correct, I guess that is what I get by writing fix-up patches on 
top of my devel branches :-)

> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Thanks, with the forward declaration removed (code+commit message) and 
making sure everything compiles pushed to master.

> 
> >  class CameraManager;
> >  class DeviceEnumerator;
> >  
> 
> -- 
> Regards,
> 
> Laurent Pinchart

Patch

diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp
index 37ccbd533790856a..4ea7ed44cc31f747 100644
--- a/src/libcamera/camera_manager.cpp
+++ b/src/libcamera/camera_manager.cpp
@@ -5,6 +5,7 @@ 
  * camera_manager.h - Camera management
  */
 
+#include <libcamera/camera.h>
 #include <libcamera/camera_manager.h>
 #include <libcamera/event_dispatcher.h>
 
diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h
index f05f201f7ca824eb..87dc3debd795eb3e 100644
--- a/src/libcamera/include/pipeline_handler.h
+++ b/src/libcamera/include/pipeline_handler.h
@@ -11,10 +11,9 @@ 
 #include <string>
 #include <vector>
 
-#include <libcamera/camera.h>
-
 namespace libcamera {
 
+class Camera;
 class CameraManager;
 class DeviceEnumerator;