Solid
#include <predicate.h>
Public Types | |
enum | ComparisonOperator { Equals, Mask } |
enum | Type { PropertyCheck, Conjunction, Disjunction, InterfaceCheck } |
Static Public Member Functions | |
static Predicate | fromString (const QString &predicate) |
Detailed Description
This class implements predicates for devices.
A predicate is a logical condition that a given device can match or not. It's a constraint about the value a property must have in a given device interface, or any combination (conjunction, disjunction) of such constraints.
FIXME: Add an example.
Definition at line 45 of file predicate.h.
Member Enumeration Documentation
The comparison operator which can be used for matching within the predicate.
- Equals, the property and the value will match for strict equality
- Mask, the property and the value will match if the bitmasking is not null
Enumerator | |
---|---|
Equals | |
Mask |
Definition at line 54 of file predicate.h.
The predicate type which controls how the predicate is handled.
- PropertyCheck, the predicate contains a comparison that needs to be matched using a ComparisonOperator
- Conjunction, the two contained predicates need to be true for this predicate to be true
- Disjunction, either of the two contained predicates may be true for this predicate to be true
- InterfaceCheck, the device type is compared
Enumerator | |
---|---|
PropertyCheck | |
Conjunction | |
Disjunction | |
InterfaceCheck |
Definition at line 64 of file predicate.h.
Constructor & Destructor Documentation
Solid::Predicate::Predicate | ( | ) |
Constructs an invalid predicate.
Definition at line 52 of file predicate.cpp.
Solid::Predicate::Predicate | ( | const Predicate & | other | ) |
Copy constructor.
- Parameters
-
other the predicate to copy
Definition at line 57 of file predicate.cpp.
Solid::Predicate::Predicate | ( | const DeviceInterface::Type & | ifaceType, |
const QString & | property, | ||
const QVariant & | value, | ||
ComparisonOperator | compOperator = Equals |
||
) |
Constructs a predicate matching the value of a property in a given device interface.
- Parameters
-
ifaceType the device interface type the device must have property the property name of the device interface value the value the property must have to make the device match compOperator the operator to apply between the property and the value when matching
Definition at line 63 of file predicate.cpp.
Solid::Predicate::Predicate | ( | const QString & | ifaceName, |
const QString & | property, | ||
const QVariant & | value, | ||
ComparisonOperator | compOperator = Equals |
||
) |
Constructs a predicate matching the value of a property in a given device interface.
- Parameters
-
ifaceName the name of the device interface the device must have property the property name of the device interface value the value the property must have to make the device match compOperator the operator to apply between the property and the value when matching
Definition at line 75 of file predicate.cpp.
|
explicit |
Constructs a predicate matching devices being of a particular device interface.
- Parameters
-
ifaceType the device interface the device must have
Definition at line 92 of file predicate.cpp.
|
explicit |
Constructs a predicate matching devices being of a particular device interface.
- Parameters
-
ifaceName the name of the device interface the device must have
Definition at line 100 of file predicate.cpp.
Solid::Predicate::~Predicate | ( | ) |
Destroys a Predicate object.
Definition at line 113 of file predicate.cpp.
Member Function Documentation
Solid::Predicate::ComparisonOperator Solid::Predicate::comparisonOperator | ( | ) | const |
Retrieves the comparison operator used to compare a property's value.
- Since
- 4.4
- Note
- This is only valid for Conjunction and Disjunction types
- Returns
- the comparison operator used
Definition at line 356 of file predicate.cpp.
Solid::Predicate Solid::Predicate::firstOperand | ( | ) | const |
A smaller, inner predicate which is the first to appear and is compared with the second one.
- Since
- 4.4
- Note
- This is only valid for Conjunction and Disjunction types
- Returns
- The predicate used for the first operand
Definition at line 361 of file predicate.cpp.
|
static |
Converts a string to a predicate.
- Parameters
-
predicate the string to convert
- Returns
- a new valid predicate if the given string is syntactically correct, Predicate() otherwise
Definition at line 56 of file predicateparse.cpp.
Solid::DeviceInterface::Type Solid::Predicate::interfaceType | ( | ) | const |
Retrieves the interface type.
- Note
- This is only valid for InterfaceCheck and PropertyCheck types
- Since
- 4.4
- Returns
- a device interface type used by the predicate
Definition at line 341 of file predicate.cpp.
bool Solid::Predicate::isValid | ( | ) | const |
Indicates if the predicate is valid.
Predicate() is the only invalid predicate.
- Returns
- true if the predicate is valid, false otherwise
Definition at line 184 of file predicate.cpp.
bool Solid::Predicate::matches | ( | const Device & | device | ) | const |
Checks if a device matches the predicate.
- Parameters
-
device the device to match against the predicate
- Returns
- true if the given device matches the predicate, false otherwise
Definition at line 189 of file predicate.cpp.
QVariant Solid::Predicate::matchingValue | ( | ) | const |
Retrieves the value used when comparing a devices property to see if it matches the predicate.
- Note
- This is only valid for the PropertyCheck type
- Since
- 4.4
- Returns
- the value used
Definition at line 351 of file predicate.cpp.
Solid::Predicate Solid::Predicate::operator& | ( | const Predicate & | other | ) |
'And' operator.
- Parameters
-
other the second operand
- Returns
- a new 'and' predicate having 'this' and 'other' as operands
Definition at line 148 of file predicate.cpp.
Solid::Predicate & Solid::Predicate::operator&= | ( | const Predicate & | other | ) |
'AndEquals' operator.
- Parameters
-
other the second operand
- Returns
- assigns to 'this' a new 'and' predicate having 'this' and 'other' as operands
Definition at line 160 of file predicate.cpp.
Solid::Predicate & Solid::Predicate::operator= | ( | const Predicate & | other | ) |
Assignement operator.
- Parameters
-
other the predicate to assign
- Returns
- this predicate after having assigned 'other' to it
Definition at line 123 of file predicate.cpp.
Solid::Predicate Solid::Predicate::operator| | ( | const Predicate & | other | ) |
'Or' operator.
- Parameters
-
other the second operand
- Returns
- a new 'or' predicate having 'this' and 'other' as operands
Definition at line 166 of file predicate.cpp.
Solid::Predicate & Solid::Predicate::operator|= | ( | const Predicate & | other | ) |
'OrEquals' operator.
- Parameters
-
other the second operand
- Returns
- assigns to 'this' a new 'or' predicate having 'this' and 'other' as operands
Definition at line 178 of file predicate.cpp.
QString Solid::Predicate::propertyName | ( | ) | const |
Retrieves the property name used when retrieving the value to compare against.
- Note
- This is only valid for the PropertyCheck type
- Since
- 4.4
- Returns
- a property name
Definition at line 346 of file predicate.cpp.
Solid::Predicate Solid::Predicate::secondOperand | ( | ) | const |
A smaller, inner predicate which is the second to appear and is compared with the first one.
- Since
- 4.4
- Note
- This is only valid for Conjunction and Disjunction types
- Returns
- The predicate used for the second operand
Definition at line 369 of file predicate.cpp.
QString Solid::Predicate::toString | ( | ) | const |
Converts the predicate to its string form.
- Returns
- a string representation of the predicate
Definition at line 267 of file predicate.cpp.
Solid::Predicate::Type Solid::Predicate::type | ( | ) | const |
Retrieves the predicate type, used to determine how to handle the predicate.
- Since
- 4.4
- Returns
- the predicate type
Definition at line 336 of file predicate.cpp.
QSet< Solid::DeviceInterface::Type > Solid::Predicate::usedTypes | ( | ) | const |
Retrieves the device interface types used in this predicate.
- Returns
- all the device interface types used in this predicate
Definition at line 242 of file predicate.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:23:26 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.