From aae2b5d6665f7878f234d4ce19de04e81154354e Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 28 Sep 2019 02:42:49 +0300 Subject: libcamera: Add ControlValidator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new abstract ControlValidator class defines an interface that will be used by the ControlList class to validate controls. This will allow controls to the validated against different object types, such as Camera and V4L2Device. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/libcamera/control_validator.cpp | 45 +++++++++++++++++++++++++++++++ src/libcamera/include/control_validator.h | 27 +++++++++++++++++++ src/libcamera/include/meson.build | 1 + src/libcamera/meson.build | 1 + 4 files changed, 74 insertions(+) create mode 100644 src/libcamera/control_validator.cpp create mode 100644 src/libcamera/include/control_validator.h (limited to 'src') diff --git a/src/libcamera/control_validator.cpp b/src/libcamera/control_validator.cpp new file mode 100644 index 00000000..8e5cf3c3 --- /dev/null +++ b/src/libcamera/control_validator.cpp @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * control_validator.cpp - Control validator + */ + +#include "control_validator.h" + +/** + * \file control_validator.h + * \brief Abstract control validator + */ + +namespace libcamera { + +/** + * \class ControlValidator + * \brief Interface for the control validator + * + * The ControlValidator class is used by the ControlList class to validate + * controls added to the list. It is an abstract class providing an interface + * for object-specific control validation, such a Camera controls and V4L2 + * controls. + */ + +/** + * \fn ControlValidator::name() + * \brief Retrieve the name of the object associated with the validator + * \return The name of the object associated with the validator + */ + +/** + * \fn ControlValidator::validate() + * \brief Validate a control + * \param[in] id The control ID + * + * This method validates the control \a id against the object corresponding to + * the validator. It shall at least validate that the control is applicable to + * the object instance, and may perform additional checks. + * + * \return True if the control is valid, false otherwise + */ + +} /* namespace libcamera */ diff --git a/src/libcamera/include/control_validator.h b/src/libcamera/include/control_validator.h new file mode 100644 index 00000000..3598b18f --- /dev/null +++ b/src/libcamera/include/control_validator.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * control_validator.h - Control validator + */ +#ifndef __LIBCAMERA_CONTROL_VALIDATOR_H__ +#define __LIBCAMERA_CONTROL_VALIDATOR_H__ + +#include + +namespace libcamera { + +class ControlId; + +class ControlValidator +{ +public: + virtual ~ControlValidator() {} + + virtual const std::string &name() const = 0; + virtual bool validate(const ControlId &id) const = 0; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_CONTROL_VALIDATOR_H__ */ diff --git a/src/libcamera/include/meson.build b/src/libcamera/include/meson.build index 933be854..1cf47204 100644 --- a/src/libcamera/include/meson.build +++ b/src/libcamera/include/meson.build @@ -1,5 +1,6 @@ libcamera_headers = files([ 'camera_sensor.h', + 'control_validator.h', 'device_enumerator.h', 'device_enumerator_sysfs.h', 'device_enumerator_udev.h', diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index f0795bbd..be845b48 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -5,6 +5,7 @@ libcamera_sources = files([ 'camera_manager.cpp', 'camera_sensor.cpp', 'controls.cpp', + 'control_validator.cpp', 'device_enumerator.cpp', 'device_enumerator_sysfs.cpp', 'event_dispatcher.cpp', -- cgit v1.2.1