libcamera: file: Use Flags<> class for map flags
Use the newly introduced Flags<> class to store a bitfield of File::MapFlag in a type-safe way. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include <libcamera/base/private.h>
|
||||
|
||||
#include <libcamera/base/class.h>
|
||||
#include <libcamera/base/flags.h>
|
||||
#include <libcamera/base/span.h>
|
||||
|
||||
namespace libcamera {
|
||||
@@ -27,6 +28,8 @@ public:
|
||||
MapPrivate = (1 << 0),
|
||||
};
|
||||
|
||||
using MapFlags = Flags<MapFlag>;
|
||||
|
||||
enum OpenMode {
|
||||
NotOpen = 0,
|
||||
ReadOnly = (1 << 0),
|
||||
@@ -57,7 +60,7 @@ public:
|
||||
ssize_t write(const Span<const uint8_t> &data);
|
||||
|
||||
Span<uint8_t> map(off_t offset = 0, ssize_t size = -1,
|
||||
MapFlag flags = MapNoOption);
|
||||
MapFlags flags = MapNoOption);
|
||||
bool unmap(uint8_t *addr);
|
||||
|
||||
static bool exists(const std::string &name);
|
||||
|
||||
@@ -52,6 +52,11 @@ LOG_DEFINE_CATEGORY(File)
|
||||
* the file constents
|
||||
*/
|
||||
|
||||
/**
|
||||
* \typedef File::MapFlags
|
||||
* \brief A bitwise combination of File::MapFlag values
|
||||
*/
|
||||
|
||||
/**
|
||||
* \enum File::OpenMode
|
||||
* \brief Mode in which a file is opened
|
||||
@@ -371,7 +376,7 @@ ssize_t File::write(const Span<const uint8_t> &data)
|
||||
*
|
||||
* \return The mapped memory on success, or an empty span otherwise
|
||||
*/
|
||||
Span<uint8_t> File::map(off_t offset, ssize_t size, enum File::MapFlag flags)
|
||||
Span<uint8_t> File::map(off_t offset, ssize_t size, File::MapFlags flags)
|
||||
{
|
||||
if (!isOpen()) {
|
||||
error_ = -EBADF;
|
||||
|
||||
Reference in New Issue
Block a user