Skip to content
Permalink
Browse files
Specify for expression functions if they are static
... and prepare them whenever possible
  • Loading branch information
m-kuhn committed May 1, 2017
1 parent e137581 commit d70bb9c348a0759c0a4e9cf6427872537740532e
Showing with 338 additions and 81 deletions.
  1. +30 −3 python/core/qgsexpression.sip
  2. +238 −48 src/core/qgsexpression.cpp
  3. +70 −30 src/core/qgsexpression.h
@@ -570,12 +570,31 @@ Does this function use a geometry object.
%Docstring
True if this function should use lazy evaluation. Lazy evaluation functions take QgsExpression.Node objects
rather than the node results when called. You can use node->eval(parent, feature) to evaluate the node and return the result
Functions are non lazy default and will be given the node return value when called **
Functions are non lazy default and will be given the node return value when called.
:rtype: bool
%End

virtual bool isStatic( const QgsExpression::NodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context ) const;
%Docstring
Will be called during prepare to determine if the function is static.
A function is static if it will return the same value for every feature with different
attributes and/or geometry.

By default this will return true, if all arguments that have been passed to the function
are also static.

.. versionadded:: 3.0
:rtype: bool
%End

virtual bool prepare( const QgsExpression::NodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context ) const;
%Docstring
This will be called during the prepare step() of an expression if it is not static.

This can be used by functions to do any preparation steps that might help to speedup the upcoming
evaluation.

.. versionadded:: 3.0
:rtype: bool
%End

@@ -828,8 +847,6 @@ return index of the function in Functions array
virtual QgsExpression::Node *clone() const = 0;
%Docstring
Generate a clone of this node.
Make sure that the clone does not contain any information which is
generated in prepare and context related.
Ownership is transferred to the caller.

:return: a deep copy of this node.
@@ -888,6 +905,16 @@ return index of the function in Functions array
:rtype: bool
%End


protected:

void cloneTo( QgsExpression::Node *target ) const;
%Docstring
Needs to be called by all subclasses as part of their clone() implementation.

.. versionadded:: 3.0
%End

private:
virtual bool prepareNode( QgsExpression *parent, const QgsExpressionContext *context ) = 0 ;
%Docstring

0 comments on commit d70bb9c

Please sign in to comment.