From 6c6acaa7ea1893b99adbf2becc46238e4a5c78b2 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 28 Nov 2021 05:07:54 +0200 Subject: libcamera: Move file_descriptor.h to base/ The FileDescriptor class is a generic helper that matches the criteria for the base library. Move it there. Signed-off-by: Laurent Pinchart Reviewed-by: Hirokazu Honda Reviewed-by: Jacopo Mondi --- include/libcamera/base/file_descriptor.h | 49 ++++++++++++++++++++++++++++++++ include/libcamera/base/meson.build | 1 + include/libcamera/file_descriptor.h | 49 -------------------------------- include/libcamera/framebuffer.h | 3 +- include/libcamera/internal/ipc_pipe.h | 3 +- include/libcamera/meson.build | 1 - 6 files changed, 52 insertions(+), 54 deletions(-) create mode 100644 include/libcamera/base/file_descriptor.h delete mode 100644 include/libcamera/file_descriptor.h (limited to 'include') diff --git a/include/libcamera/base/file_descriptor.h b/include/libcamera/base/file_descriptor.h new file mode 100644 index 00000000..8d764f8b --- /dev/null +++ b/include/libcamera/base/file_descriptor.h @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * file_descriptor.h - File descriptor wrapper + */ + +#pragma once + +#include +#include + +namespace libcamera { + +class FileDescriptor final +{ +public: + explicit FileDescriptor(const int &fd = -1); + explicit FileDescriptor(int &&fd); + FileDescriptor(const FileDescriptor &other); + FileDescriptor(FileDescriptor &&other); + ~FileDescriptor(); + + FileDescriptor &operator=(const FileDescriptor &other); + FileDescriptor &operator=(FileDescriptor &&other); + + bool isValid() const { return fd_ != nullptr; } + int fd() const { return fd_ ? fd_->fd() : -1; } + FileDescriptor dup() const; + + ino_t inode() const; + +private: + class Descriptor + { + public: + Descriptor(int fd, bool duplicate); + ~Descriptor(); + + int fd() const { return fd_; } + + private: + int fd_; + }; + + std::shared_ptr fd_; +}; + +} /* namespace libcamera */ diff --git a/include/libcamera/base/meson.build b/include/libcamera/base/meson.build index 210a54f8..abd4cfc7 100644 --- a/include/libcamera/base/meson.build +++ b/include/libcamera/base/meson.build @@ -11,6 +11,7 @@ libcamera_base_headers = files([ 'event_dispatcher_poll.h', 'event_notifier.h', 'file.h', + 'file_descriptor.h', 'flags.h', 'log.h', 'message.h', diff --git a/include/libcamera/file_descriptor.h b/include/libcamera/file_descriptor.h deleted file mode 100644 index 8d764f8b..00000000 --- a/include/libcamera/file_descriptor.h +++ /dev/null @@ -1,49 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * file_descriptor.h - File descriptor wrapper - */ - -#pragma once - -#include -#include - -namespace libcamera { - -class FileDescriptor final -{ -public: - explicit FileDescriptor(const int &fd = -1); - explicit FileDescriptor(int &&fd); - FileDescriptor(const FileDescriptor &other); - FileDescriptor(FileDescriptor &&other); - ~FileDescriptor(); - - FileDescriptor &operator=(const FileDescriptor &other); - FileDescriptor &operator=(FileDescriptor &&other); - - bool isValid() const { return fd_ != nullptr; } - int fd() const { return fd_ ? fd_->fd() : -1; } - FileDescriptor dup() const; - - ino_t inode() const; - -private: - class Descriptor - { - public: - Descriptor(int fd, bool duplicate); - ~Descriptor(); - - int fd() const { return fd_; } - - private: - int fd_; - }; - - std::shared_ptr fd_; -}; - -} /* namespace libcamera */ diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h index 4e710e33..2fbea9c5 100644 --- a/include/libcamera/framebuffer.h +++ b/include/libcamera/framebuffer.h @@ -13,10 +13,9 @@ #include #include +#include #include -#include - namespace libcamera { class Request; diff --git a/include/libcamera/internal/ipc_pipe.h b/include/libcamera/internal/ipc_pipe.h index bd8824f2..986f8d88 100644 --- a/include/libcamera/internal/ipc_pipe.h +++ b/include/libcamera/internal/ipc_pipe.h @@ -9,10 +9,9 @@ #include +#include #include -#include - #include "libcamera/internal/ipc_unixsocket.h" namespace libcamera { diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build index a8cca2a8..5f42977c 100644 --- a/include/libcamera/meson.build +++ b/include/libcamera/meson.build @@ -6,7 +6,6 @@ libcamera_public_headers = files([ 'camera.h', 'camera_manager.h', 'controls.h', - 'file_descriptor.h', 'framebuffer.h', 'framebuffer_allocator.h', 'geometry.h', -- cgit v1.2.1