Solid::Predicate

#include <predicate.h>

Public Types

enum  ComparisonOperator { Equals, Mask }
 
enum  Type { PropertyCheck, Conjunction, Disjunction, InterfaceCheck }
 

Public Member Functions

 Predicate ()
 
 Predicate (const Predicate &other)
 
 Predicate (const DeviceInterface::Type &ifaceType, const QString &property, const QVariant &value, ComparisonOperator compOperator=Equals)
 
 Predicate (const QString &ifaceName, const QString &property, const QVariant &value, ComparisonOperator compOperator=Equals)
 
 Predicate (const DeviceInterface::Type &ifaceType)
 
 Predicate (const QString &ifaceName)
 
 ~Predicate ()
 
ComparisonOperator comparisonOperator () const
 
Predicate firstOperand () const
 
DeviceInterface::Type interfaceType () const
 
bool isValid () const
 
bool matches (const Device &device) const
 
QVariant matchingValue () const
 
Predicate operator& (const Predicate &other)
 
Predicateoperator&= (const Predicate &other)
 
Predicateoperator= (const Predicate &other)
 
Predicate operator| (const Predicate &other)
 
Predicateoperator|= (const Predicate &other)
 
QString propertyName () const
 
Predicate secondOperand () const
 
QString toString () const
 
Type type () const
 
QSet< DeviceInterface::TypeusedTypes () const
 

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 31 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

Definition at line 40 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

Definition at line 50 of file predicate.h.

Constructor & Destructor Documentation

Solid::Predicate::Predicate ( )

Constructs an invalid predicate.

Definition at line 37 of file predicate.cpp.

Solid::Predicate::Predicate ( const Predicate other)

Copy constructor.

Parameters
otherthe predicate to copy

Definition at line 42 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
ifaceTypethe device interface type the device must have
propertythe property name of the device interface
valuethe value the property must have to make the device match
compOperatorthe operator to apply between the property and the value when matching

Definition at line 48 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
ifaceNamethe name of the device interface the device must have
propertythe property name of the device interface
valuethe value the property must have to make the device match
compOperatorthe operator to apply between the property and the value when matching

Definition at line 60 of file predicate.cpp.

Solid::Predicate::Predicate ( const DeviceInterface::Type ifaceType)
explicit

Constructs a predicate matching devices being of a particular device interface.

Parameters
ifaceTypethe device interface the device must have

Definition at line 76 of file predicate.cpp.

Solid::Predicate::Predicate ( const QString ifaceName)
explicit

Constructs a predicate matching devices being of a particular device interface.

Parameters
ifaceNamethe name of the device interface the device must have

Definition at line 84 of file predicate.cpp.

Solid::Predicate::~Predicate ( )

Destroys a Predicate object.

Definition at line 96 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 333 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 338 of file predicate.cpp.

Solid::Predicate Solid::Predicate::fromString ( const QString predicate)
static

Converts a string to a predicate.

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

Definition at line 41 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 318 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 164 of file predicate.cpp.

bool Solid::Predicate::matches ( const Device device) const

Checks if a device matches the predicate.

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

Definition at line 169 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 328 of file predicate.cpp.

Solid::Predicate Solid::Predicate::operator& ( const Predicate other)

'And' operator.

Parameters
otherthe second operand
Returns
a new 'and' predicate having 'this' and 'other' as operands

Definition at line 128 of file predicate.cpp.

Solid::Predicate & Solid::Predicate::operator&= ( const Predicate other)

'AndEquals' operator.

Parameters
otherthe second operand
Returns
assigns to 'this' a new 'and' predicate having 'this' and 'other' as operands

Definition at line 140 of file predicate.cpp.

Solid::Predicate & Solid::Predicate::operator= ( const Predicate other)

Assignement operator.

Parameters
otherthe predicate to assign
Returns
this predicate after having assigned 'other' to it

Definition at line 106 of file predicate.cpp.

Solid::Predicate Solid::Predicate::operator| ( const Predicate other)

'Or' operator.

Parameters
otherthe second operand
Returns
a new 'or' predicate having 'this' and 'other' as operands

Definition at line 146 of file predicate.cpp.

Solid::Predicate & Solid::Predicate::operator|= ( const Predicate other)

'OrEquals' operator.

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

Definition at line 158 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 323 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 346 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 244 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 313 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 221 of file predicate.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed May 27 2020 22:52:28 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.