DTNMA Reference Tools v2.0.0 - 7.g88e232c
Delay-Tolerant Networking Management Architecture (DTNMA) Tool Suite
Loading...
Searching...
No Matches
typing.h File Reference

This file contains definitions for AMM typing of ARI values. More...

#include "cace/ari.h"
#include "cace/cace_data.h"
#include <m-array.h>
+ Include dependency graph for typing.h:
+ This graph shows which files directly or indirectly include this file:

Data Structures

struct  cace_amm_typeptr_t
 A pointer to cace_amm_type_t with ownership semantics. More...
 
struct  cace_amm_type_builtin_s
 Configuration for a built-in type. More...
 
struct  cace_amm_type_t
 Descriptor for each built-in (ARI type) and semantic type within the AMM. More...
 

Macros

#define CACE_AMM_ERR_CONVERT_NULLFUNC   2
 
#define CACE_AMM_ERR_CONVERT_BADVALUE   3
 
#define CACE_AMM_ERR_CONVERT_NOCHOICE   4
 
#define CACE_AMM_ERR_CONVERT_FAILED_CONSTRAINT   5
 
#define CACE_AMM_TYPE_INIT_INVALID
 
#define M_OPL_cace_amm_type_t()    (INIT(API_2(cace_amm_type_init)), CLEAR(API_2(cace_amm_type_deinit)), RESET(API_2(cace_amm_type_reset)))
 M*LIB OPLIST for the cace_amm_type_t.
 
#define M_OPL_cace_amm_typeptr_t()   (INIT(API_2(cace_amm_typeptr_init)), CLEAR(API_2(cace_amm_typeptr_deinit)))
 OPLIST for the cace_amm_typeptr_t.
 

Typedefs

typedef void(* cace_amm_semtype_deinit_f) (void *semtype)
 

Enumerations

enum  cace_amm_type_match_res_t { CACE_AMM_TYPE_MATCH_NOINFO , CACE_AMM_TYPE_MATCH_NEGATIVE , CACE_AMM_TYPE_MATCH_POSITIVE , CACE_AMM_TYPE_MATCH_UNDEFINED }
 Result status for type matching. More...
 

Functions

void cace_amm_type_init (cace_amm_type_t *type)
 Initialize a type object to a default, invalid state.
 
void cace_amm_type_deinit (cace_amm_type_t *type)
 Free any resources associated with a semantic type.
 
void cace_amm_type_reset (cace_amm_type_t *type)
 Reset to the default invalid state.
 
void cace_amm_typeptr_init (cace_amm_typeptr_t *ptr)
 Initialize a type pointer to an allocated and initialized type object.
 
void cace_amm_typeptr_deinit (cace_amm_typeptr_t *ptr)
 Free any allocated type object.
 
void cace_amm_typeptr_take (cace_amm_typeptr_t *ptr, cace_amm_type_t *obj)
 Take ownership of a pointed-to object.
 
static cace_amm_type_match_res_t cace_amm_type_match_pos_neg (bool cond)
 Return either a positive or negative match depending on a condition.
 
const cace_amm_type_t * cace_amm_type_get_builtin (cace_ari_type_t ari_type)
 Get a built-in type object.
 
bool cace_amm_type_is_valid (const cace_amm_type_t *type)
 Determine if a type object is valid.
 
bool cace_amm_type_get_name (const cace_amm_type_t *type, cace_ari_t *name)
 Get a human-friendly name for a type object.
 
cace_amm_type_match_res_t cace_amm_type_match (const cace_amm_type_t *type, const cace_ari_t *ari)
 Determine if a type (built-in or semantic) matches a specific value.
 
int cace_amm_type_convert (const cace_amm_type_t *type, cace_ari_t *out, const cace_ari_t *in)
 Force a value to be converted to a specific type (built-in or semantic).
 
bool cace_amm_builtin_validate (const cace_ari_t *ari)
 Validate that typed literals agree with their values.
 

Detailed Description

This file contains definitions for AMM typing of ARI values.

Macro Definition Documentation

◆ CACE_AMM_TYPE_INIT_INVALID

#define CACE_AMM_TYPE_INIT_INVALID
Value:
(cace_amm_type_t) \
{ \
.match = NULL, .convert = NULL, .type_class = CACE_AMM_TYPE_INVALID \
}

Enumeration Type Documentation

◆ cace_amm_type_match_res_t

Result status for type matching.

Enumerator
CACE_AMM_TYPE_MATCH_NOINFO 

The result was not positive or negative.

CACE_AMM_TYPE_MATCH_NEGATIVE 

The result was a negative (non-match)

CACE_AMM_TYPE_MATCH_POSITIVE 

The result was a positive (match)

Function Documentation

◆ cace_amm_builtin_validate()

bool cace_amm_builtin_validate ( const cace_ari_t ari)

Validate that typed literals agree with their values.

This performs comparisons of valid cace_ari_lit_t::prim_type and valid cace_ari_lit_t::value within each ARI type.

References CHKFALSE, and cace_ari_visitor_t::visit_ari.

◆ cace_amm_type_convert()

int cace_amm_type_convert ( const cace_amm_type_t *  type,
cace_ari_t out,
const cace_ari_t in 
)

Force a value to be converted to a specific type (built-in or semantic).

Parameters
[in]typeThe type to convert to.
[out]outThe converted value (valid if the return is zero). This struct must already be initialized.
[in]inThe value to convert. This struct must be initialized.
Returns
Zero if the conversion is successful.

References CHKERR1, and CHKRET.

◆ cace_amm_type_deinit()

void cace_amm_type_deinit ( cace_amm_type_t *  type)

Free any resources associated with a semantic type.

Parameters
[in,out]typeThe object to de-initialize.

References CACE_FREE, and CHKVOID.

◆ cace_amm_type_get_builtin()

const cace_amm_type_t * cace_amm_type_get_builtin ( cace_ari_type_t  ari_type)

Get a built-in type object.

Parameters
ari_typeThe associated literal type to lookup.
Returns
A stable non-null pointer to a built-in type object or a null pointer if not found.

References CACE_LOG_WARNING.

◆ cace_amm_type_get_name()

bool cace_amm_type_get_name ( const cace_amm_type_t *  type,
cace_ari_t name 
)

Get a human-friendly name for a type object.

Parameters
[in]typeThe type to name.
[out]nameThe generated name.
Returns
True if a name was set.

References CHKFALSE.

◆ cace_amm_type_init()

void cace_amm_type_init ( cace_amm_type_t *  type)

Initialize a type object to a default, invalid state.

Parameters
[out]typeThe type to initialize.

References CHKVOID.

◆ cace_amm_type_is_valid()

bool cace_amm_type_is_valid ( const cace_amm_type_t *  type)

Determine if a type object is valid.

Returns
True if the object is valid.

References CHKFALSE.

◆ cace_amm_type_match()

cace_amm_type_match_res_t cace_amm_type_match ( const cace_amm_type_t *  type,
const cace_ari_t ari 
)

Determine if a type (built-in or semantic) matches a specific value.

Parameters
[in]typeThe type to check against.
[in]ariThe value to check. This struct must be initialized.
Returns
AMM_TYPE_MATCH_POSITIVE if the type fully matches the value.

References CACE_AMM_TYPE_MATCH_NEGATIVE, and CHKRET.

◆ cace_amm_type_reset()

void cace_amm_type_reset ( cace_amm_type_t *  type)

Reset to the default invalid state.

Parameters
[in,out]typeThe object to reset.

◆ cace_amm_typeptr_deinit()

void cace_amm_typeptr_deinit ( cace_amm_typeptr_t ptr)

Free any allocated type object.

Parameters
[in,out]ptrThe object to de-initialize.

References CACE_FREE, CHKVOID, and cace_amm_typeptr_t::obj.

◆ cace_amm_typeptr_init()

void cace_amm_typeptr_init ( cace_amm_typeptr_t ptr)

Initialize a type pointer to an allocated and initialized type object.

Parameters
[out]ptrThe type to initialize.

References CACE_MALLOC, CHKVOID, and cace_amm_typeptr_t::obj.

◆ cace_amm_typeptr_take()

void cace_amm_typeptr_take ( cace_amm_typeptr_t ptr,
cace_amm_type_t *  obj 
)

Take ownership of a pointed-to object.

Parameters
[in,out]ptrThe object to set.
[in]objThe object to own.

References CHKVOID, and cace_amm_typeptr_t::obj.