DTNMA Reference Tools v2.1.0 - 27.ge2c7586
Delay-Tolerant Networking Management Architecture (DTNMA) Tool Suite
Loading...
Searching...
No Matches
eval.h File Reference
#include "agent.h"
#include "runctx.h"
#include "eval_ctx.h"
#include <cace/ari.h>
+ Include dependency graph for eval.h:
+ This graph shows which files directly or indirectly include this file:

Macros

#define REFDA_EVAL_ERR_BAD_TYPE   3
 Error result when an invalid type is present.
 
#define REFDA_EVAL_ERR_DEREF_FAILED   4
 Error result when dereferencing fails.
 
#define REFDA_EVAL_ERR_PROD_FAILED   5
 Error result when value production fails.
 
#define REFDA_EVAL_ERR_NON_SINGLE   6
 Error result when the evaluation does not resolve to a single value.
 

Functions

int refda_eval_expand_target (refda_eval_ctx_t *ctx, const cace_ari_t *target)
 Perform the expansion portion of the evaluation procedure from either an inline expression (literal value) or produced expression (from reference value).
 
int refda_eval_expand_expr (refda_eval_ctx_t *ctx, const cace_ari_t *expr)
 Perform the expansion portion of the evaluation procedure from a literal value expression.
 
int refda_eval_reduce (refda_eval_ctx_t *ctx, cace_ari_t *result)
 Implement the reduction portion of the evaluation procedure.
 
int refda_eval_target (refda_runctx_t *runctx, cace_ari_t *result, const cace_ari_t *target)
 A shortcut to fully evaluate an expression.
 
int refda_eval_oper (refda_eval_ctx_t *ctx, const cace_amm_lookup_t *deref)
 This is a semi-internal function for evaluating a single operator in an existing evaluation context.
 

Macro Definition Documentation

◆ REFDA_EVAL_ERR_BAD_TYPE

#define REFDA_EVAL_ERR_BAD_TYPE   3

Error result when an invalid type is present.

◆ REFDA_EVAL_ERR_DEREF_FAILED

#define REFDA_EVAL_ERR_DEREF_FAILED   4

Error result when dereferencing fails.

◆ REFDA_EVAL_ERR_NON_SINGLE

#define REFDA_EVAL_ERR_NON_SINGLE   6

Error result when the evaluation does not resolve to a single value.

◆ REFDA_EVAL_ERR_PROD_FAILED

#define REFDA_EVAL_ERR_PROD_FAILED   5

Error result when value production fails.

Function Documentation

◆ refda_eval_expand_expr()

int refda_eval_expand_expr ( refda_eval_ctx_t ctx,
const cace_ari_t expr 
)

Perform the expansion portion of the evaluation procedure from a literal value expression.

Precondition
The refda_agent_s::objs_mutex must already be locked.
Parameters
[in]ctxThe evaluation context, which must already be initialized.
[in]exprThe literal-value EXPR to evaluate.
Returns
Zero if successful.

References cace_ari_cget_ac(), CACE_ARI_TEXT_ENC_OPTS_DEFAULT, cace_ari_text_encode(), CACE_LOG_DEBUG, cace_log_is_enabled_for(), CACE_LOG_WARNING, CHKERR1, refda_eval_ctx_t::input, cace_ari_ac_t::items, REFDA_EVAL_ERR_BAD_TYPE, refda_eval_expand_item(), and refda_eval_ctx_t::runctx.

Referenced by refda_acl_search_endpoint(), refda_alarms_purge(), refda_eval_expand_target(), refda_exec_check_sbr_condition(), and refda_reporting_item_lit().

◆ refda_eval_expand_target()

int refda_eval_expand_target ( refda_eval_ctx_t ctx,
const cace_ari_t target 
)

Perform the expansion portion of the evaluation procedure from either an inline expression (literal value) or produced expression (from reference value).

Precondition
The refda_agent_s::objs_mutex must already be locked.
Parameters
[in]ctxThe evaluation context, which must already be initialized.
[in]targetThe literal-value EXPR to evaluate or reference-value to produce and evaluate.
Returns
Zero if successful.

References refda_runctx_t::agent, cace_amm_lookup_deinit(), cace_amm_lookup_deref(), cace_amm_lookup_init(), CACE_LOG_DEBUG, CHKERR1, cace_ari_t::is_ref, refda_agent_t::objs, refda_eval_expand_expr(), refda_valprod_ctx_deinit(), refda_valprod_ctx_init(), refda_valprod_run(), refda_eval_ctx_t::runctx, and refda_valprod_ctx_t::value.

Referenced by refda_adm_ietf_dtnma_agent_oper_eval(), refda_adm_ietf_dtnma_agent_oper_unary_eval(), and refda_eval_target().

◆ refda_eval_oper()

int refda_eval_oper ( refda_eval_ctx_t ctx,
const cace_amm_lookup_t deref 
)

This is a semi-internal function for evaluating a single operator in an existing evaluation context.

Parameters
[in,out]ctxThe evaluation context already populated with refda_eval_ctx_t::stack values. At the start of evaluation any named operands are popped from the stack At the completion of evaluation the result value is pushed onto the stack. This function does not use the refda_eval_ctx_t::input value.
[in]derefThe dereferenced operator with any needed actual parameters.
Returns
Zero if successful.

References cace_amm_obj_desc_t::app_data, cace_amm_type_convert(), cace_amm_type_is_valid(), cace_ari_deinit(), cace_ari_init(), CACE_ARI_TEXT_ENC_OPTS_DEFAULT, cace_ari_text_encode(), CACE_LOG_DEBUG, cace_log_is_enabled_for(), CACE_LOG_WARNING, CHKRET, refda_amm_oper_desc_t::evaluate, cace_amm_idseg_val_t::name, cace_amm_lookup_t::obj, cace_amm_obj_desc_t::obj_id, refda_oper_eval_ctx_t::operands, cace_ari_itemized_t::ordered, cace_amm_user_data_t::ptr, refda_oper_eval_ctx_deinit(), refda_oper_eval_ctx_init(), refda_oper_eval_ctx_populate(), refda_amm_oper_desc_t::res_type, refda_oper_eval_ctx_t::result, and refda_eval_ctx_t::stack.

Referenced by predicate_compose(), and refda_eval_reduce().

◆ refda_eval_reduce()

int refda_eval_reduce ( refda_eval_ctx_t ctx,
cace_ari_t result 
)

Implement the reduction portion of the evaluation procedure.

Parameters
[in]ctxThe evaluation context, which must already be expanded into.
[out]resultThe single result value from the evaluation. This ARI must be initialized before the call and will be valid if the return code is zero but must be deinitialized regardless.
Returns
Zero if successful.

References cace_ari_set_copy(), CACE_ARI_TEXT_ENC_OPTS_DEFAULT, cace_ari_text_encode(), CACE_ARI_TYPE_OPER, CACE_LOG_DEBUG, cace_log_is_enabled_for(), CACE_LOG_WARNING, refda_eval_ctx_t::input, cace_amm_lookup_t::obj_type, REFDA_EVAL_ERR_NON_SINGLE, refda_eval_oper(), and refda_eval_ctx_t::stack.

Referenced by refda_acl_search_endpoint(), refda_adm_ietf_dtnma_agent_oper_eval(), refda_adm_ietf_dtnma_agent_oper_unary_eval(), refda_alarms_purge(), refda_eval_target(), refda_exec_check_sbr_condition(), and refda_reporting_item_lit().

◆ refda_eval_target()

int refda_eval_target ( refda_runctx_t runctx,
cace_ari_t result,
const cace_ari_t target 
)

A shortcut to fully evaluate an expression.

Precondition
The refda_agent_s::objs_mutex must already be locked.
Parameters
[in]runctxThe running context for evaluation.
[out]resultThe single result value from the evaluation. This ARI must be initialized before the call and will be valid if the return code is zero but must be deinitialized regardless.
[in]targetThe literal-value EXPR to evaluate or reference-value to produce and evaluate.
Returns
Zero if successful.

References refda_eval_ctx_deinit(), refda_eval_ctx_init(), refda_eval_expand_target(), and refda_eval_reduce().

Referenced by refda_adm_ietf_dtnma_agent_ctrl_if_then_else(), refda_adm_ietf_dtnma_agent_ctrl_wait_cond_check(), refda_adm_ietf_dtnma_agent_oper_tbl_filter(), refda_alarms_compress(), refda_alarms_mgr_state(), TEST_CASE(), and test_refda_eval_target_failure().