ArcadeEvaluator Class

  • ArcadeEvaluator
  • class Esri::ArcGISRuntime::ArcadeEvaluator

    This object allows you to evaluate an ArcadeExpression under a given ArcadeProfile. More...

    Header: #include <ArcadeEvaluator>
    Since: Esri::ArcGISRuntime 100.14
    Inherits: Esri::ArcGISRuntime::Object and Esri::ArcGISRuntime::Loadable

    Public Functions

    ArcadeEvaluator(Esri::ArcGISRuntime::ArcadeExpression *expression, Esri::ArcGISRuntime::ArcadeProfile profile, QObject *parent = nullptr)
    virtual ~ArcadeEvaluator() override
    QFuture<QStringList> attributesAsync(const QString &variableName, Esri::ArcGISRuntime::FeatureTable *attributeNameSource)
    QFuture<QStringList> attributesAsync(const QString &variableName, Esri::ArcGISRuntime::GeoElement *attributeNameSource)
    QFuture<Esri::ArcGISRuntime::ArcadeEvaluationResult *> evaluateAsync(const QVariantMap &profileVariables, QObject *parent = nullptr)
    Esri::ArcGISRuntime::ArcadeExpression *expression() const
    bool isStable() const
    Esri::ArcGISRuntime::ArcadeProfile profile() const
    QStringList profileVariablesUsed() const

    Reimplemented Public Functions

    virtual void cancelLoad() override
    virtual void load() override
    virtual Esri::ArcGISRuntime::Error loadError() const override
    virtual Esri::ArcGISRuntime::LoadStatus loadStatus() const override
    virtual void retryLoad() override

    Signals

    void doneLoading(const Esri::ArcGISRuntime::Error &loadError)
    void loadStatusChanged(Esri::ArcGISRuntime::LoadStatus loadStatus)

    Detailed Description

    This Object allows you to set up, execute, and query information about an Arcade script. For more general information on Arcade and its usages, see the Arcade online documentation.

    To construct the ArcadeEvaluator object you need to supply an ArcadeExpression along with an ArcadeProfile. ArcadeExpression is an object that contains the Arcade script plus some additional metadata while ArcadeProfile specifies availability of profile variables and limits what functions are available.

    The basic workflow is:

    From an ArcadeEvaluator object you can query information to determine:

    • Which profile variables are accessed by the script.
    • Which attributes are used by a particular profile variable.
    • Whether the script is considered stable.

    Not all scripts use all the profiles variables. profileVariablesUsed returns an array of the names of the profile variables used in the current script. Possible uses include:

    • Informing dependency analysis to determine which scripts need to run when a value of a profile variable changes.
    • Minimizing expensive calculation of unneeded profile variables.

    attributesAsync(const QString&, Esri::ArcGISRuntime::FeatureTable*) lets you dig deeper to determine which attributes are required on a specific profile variable. If you are querying a subset of attributes when querying a feature, use this information to ensure the profile variable will have the attributes it requires.

    isStable property indicates if the given script will return the same value for an identical set of profile variables. For this to be true a script must avoid using unstable built-in functions such as now() or random().

    isStable can be combined with the knowledge of the used profile variables to construct caches of results. This lets you avoid running scripts when repeated calls with the same profiles variables will not alter the evaluation result.

    Member Function Documentation

    ArcadeEvaluator::ArcadeEvaluator(Esri::ArcGISRuntime::ArcadeExpression *expression, Esri::ArcGISRuntime::ArcadeProfile profile, QObject *parent = nullptr)

    Creates an ArcadeEvaluator object.

    • expression - Arcade expression you want to evaluate.
    • profile - The ArcadeProfile context the expression should be evaluated under.
    • parent - The optional parent QObject.

    [override virtual] ArcadeEvaluator::~ArcadeEvaluator()

    Destructor.

    [since Esri::ArcGISRuntime 200.2] QFuture<QStringList> ArcadeEvaluator::attributesAsync(const QString &variableName, Esri::ArcGISRuntime::FeatureTable *attributeNameSource)

    An array of attributes used in the script for a given profile variable.

    • variableName - The name of the profile variable whose used attributes are required.
    • attributeNameSource - A FeatureTable from which we can obtain a list of all attribute names for the profile variable.

    To fully support the wildcard expansion in the expects statement, calculation of used attributes on a profile variable requires an object that can supply a full set of attribute names.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    [since Esri::ArcGISRuntime 200.2] QFuture<QStringList> ArcadeEvaluator::attributesAsync(const QString &variableName, Esri::ArcGISRuntime::GeoElement *attributeNameSource)

    An array of attributes used in the script for a given profile variable.

    • variableName - The name of the profile variable whose used attributes are required.
    • attributeNameSource - A GeoElement from which we can obtain a list of all attribute names for the profile variable.

    To fully support the wildcard expansion in the expects statement, calculation of used attributes on a profile variable requires an object that can supply a full set of attribute names.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    [override virtual] void ArcadeEvaluator::cancelLoad()

    Reimplements: Loadable::cancelLoad().

    Cancels loading metadata for the object.

    Cancels loading the metadata if the object is loading and calls doneLoading.

    [signal] void ArcadeEvaluator::doneLoading(const Esri::ArcGISRuntime::Error &loadError)

    Signal emitted when this object is done loading.

    • loadError - Details about any error that may have occurred

    Note: If there is a load error, it will also be emitted on the errorOccurred signal.

    See also Loadable and Object.

    [since Esri::ArcGISRuntime 200.3] QFuture<Esri::ArcGISRuntime::ArcadeEvaluationResult *> ArcadeEvaluator::evaluateAsync(const QVariantMap &profileVariables, QObject *parent = nullptr)

    Asynchronously evaluates the script using the supplied profile variables.

    • profileVariables - The profile variables for the script as key/value pairs.
    • parent - The optional parent QObject

    Each entry of the profileVariables dictionary is placed into the interpreter as a value accessible throughout the script. The name and type of these should comply with the profile the Arcade evaluator has been constructed with. Values are not persisted across evaluations, meaning all required profile variables must be supplied with each evaluation.

    Each value of a key/value pair in the dictionary is converted to a type understood by the interpreter.

    Values in the dictionary can be any of the following types

    To be explicit on the conversions of compound types.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 200.3.

    Esri::ArcGISRuntime::ArcadeExpression *ArcadeEvaluator::expression() const

    Returns the Arcade expression of the Arcade evaluator.

    bool ArcadeEvaluator::isStable() const

    Returns whether a script is considered stable.

    A script is considered stable if the script will return the same result given the same inputs. There are certain functions listed below that will return different values on each evaluation. Using these functions means the script is not considered stable.

    Arcade functions that stop a script from being considered stable:

    • Now
    • Today
    • TimeStamp
    • Random
    • Guid
    • NextSequence

    [override virtual] void ArcadeEvaluator::load()

    Reimplements: Loadable::load().

    Loads the metadata for the object asynchronously.

    Loads the metadata if the object is not loaded and calls doneLoading.

    [override virtual] Esri::ArcGISRuntime::Error ArcadeEvaluator::loadError() const

    Reimplements: Loadable::loadError() const.

    Returns the load error.

    See also Error.

    [override virtual] Esri::ArcGISRuntime::LoadStatus ArcadeEvaluator::loadStatus() const

    Reimplements: Loadable::loadStatus() const.

    Returns the load status.

    See also LoadStatus.

    [signal] void ArcadeEvaluator::loadStatusChanged(Esri::ArcGISRuntime::LoadStatus loadStatus)

    Signal emitted when the load status changes for this object.

    See also Loadable.

    Esri::ArcGISRuntime::ArcadeProfile ArcadeEvaluator::profile() const

    Returns the Arcade profile under which the script should evaluate.

    QStringList ArcadeEvaluator::profileVariablesUsed() const

    Returns a string list of the names of all profile variable used in the script.

    A collection of names of the profile variables used in the script. Each variable name should have a dictionary of profile values passed to the evaluateAsync function.

    [override virtual] void ArcadeEvaluator::retryLoad()

    Reimplements: Loadable::retryLoad().

    Loads or retries loading metadata for the object asynchronously.

    Retries loading the metadata if the object fails to load. Loads the object if it is not loaded. Will not retry to load the object if the object is loaded.

    Calls done loading.

    Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.