# class Predicate

###

Module | solid
Namespace | Solid
Class | Predicate
Inherits |

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.

### enums

- ComparisonOperator { Equals, Mask }

enum details

### methods

- Predicate ( )

  returns ctor

  Constructs an invalid predicate.

- Predicate (other)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  other | Solid.Predicate |

  Copy constructor.

  other - the predicate to copy

- Predicate (ifaceType, property, value, compOperator)

  returns ctor
  Not implemented

  Argument | Type | Default
  --- | --- | ---
  ifaceType | Solid::DeviceInterface.Type |
  property | QString |
  value | QVariant |
  compOperator | Solid::Predicate.ComparisonOperator | Solid.Predicate.Equals

  Constructs a predicate matching the value of a property in a given device interface.

  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

- Predicate (ifaceName, property, value, compOperator)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  ifaceName | QString |
  property | QString |
  value | QVariant |
  compOperator | Solid::Predicate.ComparisonOperator | Solid.Predicate.Equals

  Constructs a predicate matching the value of a property in a given device interface.

  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

- Predicate (ifaceType)

  returns ctor
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  ifaceType | Solid::DeviceInterface.Type |

  Constructs a predicate matching devices being of a particular device interface

  ifaceType - the device interface the device must have

- Predicate (ifaceName)

  returns ctor
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  ifaceName | QString |

  Constructs a predicate matching devices being of a particular device interface

  ifaceName - the name of the device interface the device must have

- Predicate (a0)

  returns ctor
  before KDE 4.1.0 only

  Argument | Type | Default
  --- | --- | ---
  a0 | Solid::DeviceInterface.Type |

- Predicate (a0)

  returns ctor
  before KDE 4.1.0 only

  Argument | Type | Default
  --- | --- | ---
  a0 | QString |

- fromString (predicate)

  returns Solid.Predicate
  static

  Argument | Type | Default
  --- | --- | ---
  predicate | QString |

  Converts a string to a predicate.

  predicate - the string to convert Returns a new valid predicate if the given string is syntactically correct, Predicate() otherwise

- isValid ( )

  returns bool

  Indicates if the predicate is valid.

  Predicate() is the only invalid predicate.

  Returns true if the predicate is valid, false otherwise

- matches (device)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  device | Solid.Device |

  Checks if a device matches the predicate.

  device - the device to match against the predicate Returns true if the given device matches the predicate, false otherwise

- operator & (other)

  returns Solid.Predicate

  Argument | Type | Default
  --- | --- | ---
  other | Solid.Predicate |

  'And' operator.

  other - the second operand Returns a new 'and' predicate having 'this' and 'other' as operands

- operator &= (other)

  returns Solid.Predicate
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  other | Solid.Predicate |

  'AndEquals' operator.

  other - the second operand Returns assigns to 'this' a new 'and' predicate having 'this' and 'other' as operands

- operator | (other)

  returns Solid.Predicate

  Argument | Type | Default
  --- | --- | ---
  other | Solid.Predicate |

  'Or' operator.

  other - the second operand Returns a new 'or' predicate having 'this' and 'other' as operands

- operator |= (other)

  returns Solid.Predicate
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  other | Solid.Predicate |

  'OrEquals' operator.

  other - the second operand Returns assigns to 'this' a new 'or' predicate having 'this' and 'other' as operands

- toString ( )

  returns QString

  Converts the predicate to its string form.

  Returns a string representation of the predicate

- usedTypes ( )

  returns QSet<Solid::DeviceInterface::Type>

  Retrieves the device interface types used in this predicate.

  Returns all the device interface types used in this predicate

### enums - detail

- ComparisonOperator { Equals, Mask }

  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

  | Equals | - | - |
  | Mask | - | - |