Policies#

Algorithm policies#

Policies are used to configure part of the behaviour of operations at compile-time. Algorithms are implemented in terms of policies that are passed in as template arguments. Algorithms can be instantiated with different policies, which makes their behaviour at runtime different. Which policies to use depends on the use-case. For example, if it is guaranteed that no-data will never occur in the algorithm’s arguments, then it is not needed to check for them.

Currently there are several kinds of policies used by the algorithms:

Table 5 Kinds of policies#

Policy

Responsibility

Input no-data policy

Determine whether an input element is marked as no-data value

Domain policy

Determine whether an input element value is part of the algorithm’s valid domain

Output range policy

Determine whether an output element value can be represented by the output element’s type

Output no-data policy

Mark an output element value as no-data

How the various policies perform their responsibility is up to the implementation. This way, the same algorithm can support multiple conventions, like for representing no-data values.

In general, the various policies are aggregated into a single lue::policy::Policies instance, which is passed as an argument to an algorithm.

LUE provides two sets of algorithm policies: “default” policies and “value” policies. They may not be correct for all use-cases. Different policies can be created and used by 3rd-party users of the LUE C++ API.

Default policies#

  • Perform the minimum number of checks

  • Execute as fast as possible

  • Optimizer should remove all checks

These policies are typically used as default policies:

Value policies#

  • Check input domain, if relevant

  • Check output range, if relevant

  • Check input no-data, if relevant

  • Write output no-data, if relevant

  • Use LUE’s default no-data policies

These policies are typically used as value policies:

Algorithms that require a domain check typically use an custom, algorithm-specific domain policy.

Policies#

template<typename DomainPolicy_, typename OutputsPolicies_, typename InputsPolicies_>
class Policies#

Primary class template for a class aggregating all algorithm policies.

Template Parameters:
  • DomainPolicy_ – Domain policy class

  • OutputsPolicies_ – Policies related to zero or more outputs

  • InputsPolicies_ – Policies related to zero or more inputs

Subclassed by lue::policy::accu_fraction::DefaultPolicies< FlowDirectionElement, MaterialElement, FractionElement >, lue::policy::accu_fraction::DefaultValuePolicies< FlowDirectionElement, MaterialElement, FractionElement >, lue::policy::accu_info::DefaultPolicies< FlowDirectionElement >, lue::policy::accu_info::DefaultValuePolicies< FlowDirectionElement >, lue::policy::accu_threshold::DefaultPolicies< FlowDirectionElement, MaterialElement >, lue::policy::accu_threshold::DefaultValuePolicies< FlowDirectionElement, MaterialElement >, lue::policy::d8_flow_direction::DefaultPolicies< FlowDirectionElement, ElevationElement >, lue::policy::d8_flow_direction::DefaultValuePolicies< FlowDirectionElement, ElevationElement >, lue::policy::flow_accumulation::DefaultPolicies< FlowDirectionElement, MaterialElement >, lue::policy::flow_accumulation::DefaultValuePolicies< FlowDirectionElement, MaterialElement >, lue::policy::valid::DefaultValuePolicies< BooleanElement, ExpressionElement >

Public Functions

auto domain_policy() const -> DomainPolicy const&#

Return the domain policy.

auto inputs_policies() const -> InputsPolicies const&#

Return the inputs policies.

auto outputs_policies() const -> OutputsPolicies const&#

Return the outputs policies.