mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-13 23:39:44 +03:00
libcamera: controls: Rename ControlValueType to ControlType
The type of a control value is also the type of the control. Shorten the ControlValueType enumeration to ControlType, and rename ControlValue* to ControlType* for better clarity. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
parent
594de3aed3
commit
c5dfd9d57e
4 changed files with 38 additions and 38 deletions
|
@ -18,11 +18,11 @@ namespace libcamera {
|
||||||
|
|
||||||
class Camera;
|
class Camera;
|
||||||
|
|
||||||
enum ControlValueType {
|
enum ControlType {
|
||||||
ControlValueNone,
|
ControlTypeNone,
|
||||||
ControlValueBool,
|
ControlTypeBool,
|
||||||
ControlValueInteger,
|
ControlTypeInteger,
|
||||||
ControlValueInteger64,
|
ControlTypeInteger64,
|
||||||
};
|
};
|
||||||
|
|
||||||
class ControlValue
|
class ControlValue
|
||||||
|
@ -33,8 +33,8 @@ public:
|
||||||
ControlValue(int value);
|
ControlValue(int value);
|
||||||
ControlValue(int64_t value);
|
ControlValue(int64_t value);
|
||||||
|
|
||||||
ControlValueType type() const { return type_; };
|
ControlType type() const { return type_; };
|
||||||
bool isNone() const { return type_ == ControlValueNone; };
|
bool isNone() const { return type_ == ControlTypeNone; };
|
||||||
|
|
||||||
void set(bool value);
|
void set(bool value);
|
||||||
void set(int value);
|
void set(int value);
|
||||||
|
@ -47,7 +47,7 @@ public:
|
||||||
std::string toString() const;
|
std::string toString() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ControlValueType type_;
|
ControlType type_;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
bool bool_;
|
bool bool_;
|
||||||
|
@ -59,7 +59,7 @@ private:
|
||||||
struct ControlIdentifier {
|
struct ControlIdentifier {
|
||||||
ControlId id;
|
ControlId id;
|
||||||
const char *name;
|
const char *name;
|
||||||
ControlValueType type;
|
ControlType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ControlInfo
|
class ControlInfo
|
||||||
|
@ -70,7 +70,7 @@ public:
|
||||||
|
|
||||||
ControlId id() const { return ident_->id; }
|
ControlId id() const { return ident_->id; }
|
||||||
const char *name() const { return ident_->name; }
|
const char *name() const { return ident_->name; }
|
||||||
ControlValueType type() const { return ident_->type; }
|
ControlType type() const { return ident_->type; }
|
||||||
|
|
||||||
const ControlValue &min() const { return min_; }
|
const ControlValue &min() const { return min_; }
|
||||||
const ControlValue &max() const { return max_; }
|
const ControlValue &max() const { return max_; }
|
||||||
|
|
|
@ -25,16 +25,16 @@ namespace libcamera {
|
||||||
LOG_DEFINE_CATEGORY(Controls)
|
LOG_DEFINE_CATEGORY(Controls)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \enum ControlValueType
|
* \enum ControlType
|
||||||
* \brief Define the data type of value represented by a ControlValue
|
* \brief Define the data type of a Control
|
||||||
* \var ControlValueNone
|
* \var ControlTypeNone
|
||||||
* Identifies an unset control value
|
* Invalid type, for empty values
|
||||||
* \var ControlValueBool
|
* \var ControlTypeBool
|
||||||
* Identifies controls storing a boolean value
|
* The control stores a boolean value
|
||||||
* \var ControlValueInteger
|
* \var ControlTypeInteger
|
||||||
* Identifies controls storing an integer value
|
* The control stores an integer value
|
||||||
* \var ControlValueInteger64
|
* \var ControlTypeInteger64
|
||||||
* Identifies controls storing a 64-bit integer value
|
* The control stores a 64-bit integer value
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,7 +46,7 @@ LOG_DEFINE_CATEGORY(Controls)
|
||||||
* \brief Construct an empty ControlValue.
|
* \brief Construct an empty ControlValue.
|
||||||
*/
|
*/
|
||||||
ControlValue::ControlValue()
|
ControlValue::ControlValue()
|
||||||
: type_(ControlValueNone)
|
: type_(ControlTypeNone)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ ControlValue::ControlValue()
|
||||||
* \param[in] value Boolean value to store
|
* \param[in] value Boolean value to store
|
||||||
*/
|
*/
|
||||||
ControlValue::ControlValue(bool value)
|
ControlValue::ControlValue(bool value)
|
||||||
: type_(ControlValueBool), bool_(value)
|
: type_(ControlTypeBool), bool_(value)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ ControlValue::ControlValue(bool value)
|
||||||
* \param[in] value Integer value to store
|
* \param[in] value Integer value to store
|
||||||
*/
|
*/
|
||||||
ControlValue::ControlValue(int value)
|
ControlValue::ControlValue(int value)
|
||||||
: type_(ControlValueInteger), integer_(value)
|
: type_(ControlTypeInteger), integer_(value)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ ControlValue::ControlValue(int value)
|
||||||
* \param[in] value Integer value to store
|
* \param[in] value Integer value to store
|
||||||
*/
|
*/
|
||||||
ControlValue::ControlValue(int64_t value)
|
ControlValue::ControlValue(int64_t value)
|
||||||
: type_(ControlValueInteger64), integer64_(value)
|
: type_(ControlTypeInteger64), integer64_(value)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ ControlValue::ControlValue(int64_t value)
|
||||||
/**
|
/**
|
||||||
* \fn ControlValue::isNone()
|
* \fn ControlValue::isNone()
|
||||||
* \brief Determine if the value is not initialised
|
* \brief Determine if the value is not initialised
|
||||||
* \return True if the value type is ControlValueNone, false otherwise
|
* \return True if the value type is ControlTypeNone, false otherwise
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,7 +95,7 @@ ControlValue::ControlValue(int64_t value)
|
||||||
*/
|
*/
|
||||||
void ControlValue::set(bool value)
|
void ControlValue::set(bool value)
|
||||||
{
|
{
|
||||||
type_ = ControlValueBool;
|
type_ = ControlTypeBool;
|
||||||
bool_ = value;
|
bool_ = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ void ControlValue::set(bool value)
|
||||||
*/
|
*/
|
||||||
void ControlValue::set(int value)
|
void ControlValue::set(int value)
|
||||||
{
|
{
|
||||||
type_ = ControlValueInteger;
|
type_ = ControlTypeInteger;
|
||||||
integer_ = value;
|
integer_ = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ void ControlValue::set(int value)
|
||||||
*/
|
*/
|
||||||
void ControlValue::set(int64_t value)
|
void ControlValue::set(int64_t value)
|
||||||
{
|
{
|
||||||
type_ = ControlValueInteger64;
|
type_ = ControlTypeInteger64;
|
||||||
integer64_ = value;
|
integer64_ = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ void ControlValue::set(int64_t value)
|
||||||
*/
|
*/
|
||||||
bool ControlValue::getBool() const
|
bool ControlValue::getBool() const
|
||||||
{
|
{
|
||||||
ASSERT(type_ == ControlValueBool);
|
ASSERT(type_ == ControlTypeBool);
|
||||||
|
|
||||||
return bool_;
|
return bool_;
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ bool ControlValue::getBool() const
|
||||||
*/
|
*/
|
||||||
int ControlValue::getInt() const
|
int ControlValue::getInt() const
|
||||||
{
|
{
|
||||||
ASSERT(type_ == ControlValueInteger || type_ == ControlValueInteger64);
|
ASSERT(type_ == ControlTypeInteger || type_ == ControlTypeInteger64);
|
||||||
|
|
||||||
return integer_;
|
return integer_;
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ int ControlValue::getInt() const
|
||||||
*/
|
*/
|
||||||
int64_t ControlValue::getInt64() const
|
int64_t ControlValue::getInt64() const
|
||||||
{
|
{
|
||||||
ASSERT(type_ == ControlValueInteger || type_ == ControlValueInteger64);
|
ASSERT(type_ == ControlTypeInteger || type_ == ControlTypeInteger64);
|
||||||
|
|
||||||
return integer64_;
|
return integer64_;
|
||||||
}
|
}
|
||||||
|
@ -168,13 +168,13 @@ int64_t ControlValue::getInt64() const
|
||||||
std::string ControlValue::toString() const
|
std::string ControlValue::toString() const
|
||||||
{
|
{
|
||||||
switch (type_) {
|
switch (type_) {
|
||||||
case ControlValueNone:
|
case ControlTypeNone:
|
||||||
return "<None>";
|
return "<None>";
|
||||||
case ControlValueBool:
|
case ControlTypeBool:
|
||||||
return bool_ ? "True" : "False";
|
return bool_ ? "True" : "False";
|
||||||
case ControlValueInteger:
|
case ControlTypeInteger:
|
||||||
return std::to_string(integer_);
|
return std::to_string(integer_);
|
||||||
case ControlValueInteger64:
|
case ControlTypeInteger64:
|
||||||
return std::to_string(integer64_);
|
return std::to_string(integer64_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ function GenerateTable(file) {
|
||||||
print "extern const std::unordered_map<ControlId, ControlIdentifier>" > file
|
print "extern const std::unordered_map<ControlId, ControlIdentifier>" > file
|
||||||
print "controlTypes {" > file
|
print "controlTypes {" > file
|
||||||
for (i=1; i <= id; ++i) {
|
for (i=1; i <= id; ++i) {
|
||||||
printf "\t{ %s, { %s, \"%s\", ControlValue%s } },\n", names[i], names[i], names[i], types[i] > file
|
printf "\t{ %s, { %s, \"%s\", ControlType%s } },\n", names[i], names[i], names[i], types[i] > file
|
||||||
}
|
}
|
||||||
print "};" > file
|
print "};" > file
|
||||||
ExitNameSpace(file)
|
ExitNameSpace(file)
|
||||||
|
|
|
@ -26,7 +26,7 @@ protected:
|
||||||
ControlInfo info(Brightness);
|
ControlInfo info(Brightness);
|
||||||
|
|
||||||
if (info.id() != Brightness ||
|
if (info.id() != Brightness ||
|
||||||
info.type() != ControlValueInteger ||
|
info.type() != ControlTypeInteger ||
|
||||||
info.name() != std::string("Brightness")) {
|
info.name() != std::string("Brightness")) {
|
||||||
cout << "Invalid control identification for Brightness" << endl;
|
cout << "Invalid control identification for Brightness" << endl;
|
||||||
return TestFail;
|
return TestFail;
|
||||||
|
@ -44,7 +44,7 @@ protected:
|
||||||
info = ControlInfo(Contrast, 10, 200);
|
info = ControlInfo(Contrast, 10, 200);
|
||||||
|
|
||||||
if (info.id() != Contrast ||
|
if (info.id() != Contrast ||
|
||||||
info.type() != ControlValueInteger ||
|
info.type() != ControlTypeInteger ||
|
||||||
info.name() != std::string("Contrast")) {
|
info.name() != std::string("Contrast")) {
|
||||||
cout << "Invalid control identification for Contrast" << endl;
|
cout << "Invalid control identification for Contrast" << endl;
|
||||||
return TestFail;
|
return TestFail;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue