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:
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:
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.
Relevant samples:
Creates an ArcadeEvaluator object.
[override virtual noexcept]
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.
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.
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.
Note: If there is a load error, it will also be emitted on the errorOccurred
signal.
[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.
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() constReturns the Arcade expression of the Arcade evaluator.
bool ArcadeEvaluator::isStable() constReturns 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:
[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() constReturns the Arcade profile under which the script should evaluate.
QStringList ArcadeEvaluator::profileVariablesUsed() constReturns 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.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4