blob: 8612f86511a101cad3b3ea61ca995c12e82e1852 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* file_descriptor.h - File descriptor wrapper
*/
#ifndef __LIBCAMERA_FILE_DESCRIPTOR_H__
#define __LIBCAMERA_FILE_DESCRIPTOR_H__
#include <memory>
namespace libcamera {
class FileDescriptor final
{
public:
explicit FileDescriptor(int fd = -1);
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;
private:
class Descriptor
{
public:
Descriptor(int fd);
~Descriptor();
int fd() const { return fd_; }
private:
int fd_;
};
std::shared_ptr<Descriptor> fd_;
};
} /* namespace libcamera */
#endif /* __LIBCAMERA_FILE_DESCRIPTOR_H__ */
|