Qt 4.8
Public Functions | Properties | List of all members
QPatternist::OperandSwitcherMathematician Class Reference

Delegates an AtomicMathematician and switches its operands. More...

#include <qatomicmathematicians_p.h>

Inheritance diagram for QPatternist::OperandSwitcherMathematician:
QPatternist::AtomicMathematician QPatternist::AtomicTypeVisitorResult QSharedData

Public Functions

virtual Item calculate (const Item &o1, const Operator op, const Item &o2, const QExplicitlySharedDataPointer< DynamicContext > &context) const
 
 OperandSwitcherMathematician (const AtomicMathematician::Ptr &mathematician)
 
- Public Functions inherited from QPatternist::AtomicMathematician
virtual ~AtomicMathematician ()
 
- Public Functions inherited from QPatternist::AtomicTypeVisitorResult
 AtomicTypeVisitorResult ()
 
virtual ~AtomicTypeVisitorResult ()
 
- Public Functions inherited from QSharedData
 QSharedData ()
 Constructs a QSharedData object with a reference count of 0. More...
 
 QSharedData (const QSharedData &)
 Constructs a QSharedData object with reference count 0. More...
 

Properties

const AtomicMathematician::Ptr m_mather
 

Additional Inherited Members

- Public Types inherited from QPatternist::AtomicMathematician
enum  Operator {
  Div = 1, IDiv = 2, Substract = 4, Mod = 8,
  Multiply = 16, Add = 32
}
 
typedef QFlags< OperatorOperators
 
typedef QExplicitlySharedDataPointer< AtomicMathematicianPtr
 
- Public Types inherited from QPatternist::AtomicTypeVisitorResult
typedef QExplicitlySharedDataPointer< AtomicTypeVisitorResultPtr
 
- Static Public Functions inherited from QPatternist::AtomicMathematician
static QString displayName (const AtomicMathematician::Operator op)
 
- Public Variables inherited from QSharedData
QAtomicInt ref
 

Detailed Description

Delegates an AtomicMathematician and switches its operands.

Switches the operands of the call to a call to the calculate() on an AtomicMathematician such that the left operand becomes the right, and vice versa.

Its constructor takes an AtomicMathematician instance which this OperandSwitcherMathematician should act as as a middle-man for, having the role of switching the two operands. Thus, OperandSwitcherMathematician can be described as a proxy or delegator class.

This class is used for implementing operator combinations such as numeric * xs:yearMonthDuration and xs:yearMonthDuration * numeric.

Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 180 of file qatomicmathematicians_p.h.

Constructors and Destructors

◆ OperandSwitcherMathematician()

OperandSwitcherMathematician::OperandSwitcherMathematician ( const AtomicMathematician::Ptr mathematician)

Creates an OperandSwitcherMathematician.

Parameters
mathematicianthe AtomicMathematician this OperandSwitcherMathematician should switch the operands for. Must be a non null, valid pointer.

Definition at line 292 of file qatomicmathematicians.cpp.

Referenced by QPatternist::DurationDurationMathematician::calculate().

292  : m_mather(mathematician)
293 {
294  Q_ASSERT(mathematician);
295 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

Functions

◆ calculate()

Item OperandSwitcherMathematician::calculate ( const Item o1,
const Operator  op,
const Item o2,
const QExplicitlySharedDataPointer< DynamicContext > &  context 
) const
virtual

Switch o1 and o2, and returns the value from the AtomicMathematician this OperandSwitcherMathematician represents.

Implements QPatternist::AtomicMathematician.

Definition at line 297 of file qatomicmathematicians.cpp.

301 {
302  return m_mather->calculate(o2, op, o1, context);
303 }
virtual Item calculate(const Item &operand1, const Operator op, const Item &operand2, const QExplicitlySharedDataPointer< DynamicContext > &context) const =0

Properties

◆ m_mather

const AtomicMathematician::Ptr QPatternist::OperandSwitcherMathematician::m_mather
private

Definition at line 200 of file qatomicmathematicians_p.h.

Referenced by calculate().


The documentation for this class was generated from the following files: