summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-08-03 02:10:28 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-08-03 10:55:33 +0300
commit6a8582dc20eedeba90431fa1ab1ba2ee432f5bbc (patch)
tree47611614d13a6984741e5ac696bb9d443df1944c /include
parent91d06ae2fc6114d870ab76a05c1268a6ee417415 (diff)
libcamera: file: Turn MapFlag and OpenModeFlag into enum class
Add type safety by turning the MapFlag and OpenModeFlag enum into enum class. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'include')
-rw-r--r--include/libcamera/base/file.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/include/libcamera/base/file.h b/include/libcamera/base/file.h
index eebb2402..60851d38 100644
--- a/include/libcamera/base/file.h
+++ b/include/libcamera/base/file.h
@@ -23,14 +23,14 @@ namespace libcamera {
class File
{
public:
- enum MapFlag {
- MapNoOption = 0,
- MapPrivate = (1 << 0),
+ enum class MapFlag {
+ NoOption = 0,
+ Private = (1 << 0),
};
using MapFlags = Flags<MapFlag>;
- enum OpenModeFlag {
+ enum class OpenModeFlag {
NotOpen = 0,
ReadOnly = (1 << 0),
WriteOnly = (1 << 1),
@@ -62,7 +62,7 @@ public:
ssize_t write(const Span<const uint8_t> &data);
Span<uint8_t> map(off_t offset = 0, ssize_t size = -1,
- MapFlags flags = MapNoOption);
+ MapFlags flags = MapFlag::NoOption);
bool unmap(uint8_t *addr);
static bool exists(const std::string &name);
@@ -80,6 +80,9 @@ private:
std::map<void *, size_t> maps_;
};
+LIBCAMERA_FLAGS_ENABLE_OPERATORS(File::MapFlag)
+LIBCAMERA_FLAGS_ENABLE_OPERATORS(File::OpenModeFlag)
+
} /* namespace libcamera */
#endif /* __LIBCAMERA_BASE_FILE_H__ */