libamxo
4.3.4
Object Definition Language (ODL) parsing
|
Functions | |
int | amxo_parser_scan_mib_dir (amxo_parser_t *parser, const char *path) |
Scans a directory for MIB odl files. More... | |
int | amxo_parser_scan_mib_dirs (amxo_parser_t *parser, amxc_var_t *dirs) |
Scans multiple directories for MIB odl files. More... | |
const char * | amxo_parser_get_mib_file (amxo_parser_t *parser, const char *mib_name) |
Get full path and file name of odl file describing a mib. More... | |
int | amxo_parser_load_mib (amxo_parser_t *parser, amxd_dm_t *dm, const char *mib_name) |
Loads the mib definition. More... | |
int | amxo_parser_apply_mib (amxo_parser_t *parser, amxd_object_t *object, const char *mib_name) |
Unconditionally applies a MIB to a data model object. More... | |
int | amxo_parser_add_mibs (amxo_parser_t *parser, amxd_object_t *object, amxo_evaluate_expr_fn_t fn) |
Adds zero, one or more MIBs to a data model object. More... | |
int | amxo_parser_remove_mibs (amxo_parser_t *parser, amxd_object_t *object, amxo_evaluate_expr_fn_t fn) |
Removes zero, one or more MIBs from a data model object. More... | |
int | amxo_parser_apply_mibs (amxo_parser_t *parser, amxd_object_t *object, amxo_evaluate_expr_fn_t fn) |
Applies zero, one or more MIBs to a data model object. More... | |
Ambiorix ODL parser mibs API
MIBS are data mode extention objects, A MIB can be applied to any object in the data model. The object get extended with the parameters, functions and objects defined in the MIB.
MIBS can be defined in separate ODL files. Each MIB odl file contains exactly one MIB definition. The file must have the same name as the MIB definition.
The MIB odl files can contain on the first line a expression definition.
The MIBS are not loaded, until they are needed. Loading the MIBS and applying them on objects in the data model can be done using amxo_parser_apply_mib or amxo_parser_apply_mibs
int amxo_parser_add_mibs | ( | amxo_parser_t * | parser, |
amxd_object_t * | object, | ||
amxo_evaluate_expr_fn_t | fn | ||
) |
Adds zero, one or more MIBs to a data model object.
This function loops over all known MIB odl files, and will apply each MIB to the provided data model object if the object is matching the MIB expression.
When an expression evaluation function is provided, the MIB expression will be passed to that function together with the data model object. When the function returns true the MIB will be applied on the data model object. If the MIB does not have an expression defined, the name of the MIB is used as an expression.
No MIBs are applied to the data model object if no expression evaluation function is provided.
To unconditionally apply a single MIB to a data model object use amxo_parser_apply_mib
parser | the odl parser instance |
object | the data model object |
fn | function that evaluates the MIB expression. |
Definition at line 315 of file amxo_parser_mibs.c.
int amxo_parser_apply_mib | ( | amxo_parser_t * | parser, |
amxd_object_t * | object, | ||
const char * | mib_name | ||
) |
Unconditionally applies a MIB to a data model object.
Loads the MIB odl file, if not already loaded and applies the MIB on the provided data model object. If an expression was set in the MIB odl file, the expression is ignored. The MIB is unconditionally applied on the data model object.
parser | the odl parser instance |
object | the data model object |
mib_name | the name of the mib. |
Definition at line 291 of file amxo_parser_mibs.c.
int amxo_parser_apply_mibs | ( | amxo_parser_t * | parser, |
amxd_object_t * | object, | ||
amxo_evaluate_expr_fn_t | fn | ||
) |
Applies zero, one or more MIBs to a data model object.
This function loops over all known MIB odl files, and will add each MIB to the provided data model object if the object matches the MIB expression or removes the MIB from the data model object of the object is not matching the expression anymore.
When an expression evaluation function is provided, the MIB expression will be passed to that function together with the data model object. When the function returns true the MIB will be added on the data model object otherwise removed. If the MIB ODL files does not have an expression defined, the name of the MIB is used as an expression.
No MIBs are applied if no expression evaluation function is provided.
parser | the odl parser instance |
object | the data model object |
fn | function that evaluates the MIB expression. |
Definition at line 370 of file amxo_parser_mibs.c.
const char* amxo_parser_get_mib_file | ( | amxo_parser_t * | parser, |
const char * | mib_name | ||
) |
Get full path and file name of odl file describing a mib.
After scanning the mib directories using amxo_parser_scan_mib_dir or amxo_parser_scan_mib_dirs, this function returns the file name for a mib definition.
The mib can be loaded using amxo_parser_parse_file
parser | the odl parser instance |
mib_name | name of the mib. |
Definition at line 242 of file amxo_parser_mibs.c.
int amxo_parser_load_mib | ( | amxo_parser_t * | parser, |
amxd_dm_t * | dm, | ||
const char * | mib_name | ||
) |
Loads the mib definition.
Mibs can be loaded by mib name after amxo_parser_scan_mib_dir or amxo_parser_scan_mib_dirs was called.
This function calls:
If the mib was already loaded nothing is done.
parser | the odl parser instance |
dm | data model for which the mib must be loaded |
mib_name | name of the mib. |
Definition at line 265 of file amxo_parser_mibs.c.
int amxo_parser_remove_mibs | ( | amxo_parser_t * | parser, |
amxd_object_t * | object, | ||
amxo_evaluate_expr_fn_t | fn | ||
) |
Removes zero, one or more MIBs from a data model object.
This function loops over all known MIB odl files, and will remove each MIB from the provided data model object if the MIB was added to the object and the object is not matching the MIB expression any more.
When an expression evaluation function is provided, the MIB expression will be passed to that function together with the data model object. When the function returns false the MIB will be removed from the data model object. If the MIB does not have an expression defined, the name of the MIB is used as an expression.
No MIBs are removed from the data model object if no expression evaluation function is provided.
To unconditionally remove a single MIB from a data model object use the data model function amxd_object_remove_mib.
parser | the odl parser instance |
object | the data model object |
fn | function that evaluates the MIB expression. |
Definition at line 341 of file amxo_parser_mibs.c.
int amxo_parser_scan_mib_dir | ( | amxo_parser_t * | parser, |
const char * | path | ||
) |
Scans a directory for MIB odl files.
Each odl file found in the given path must contain exactly one MIB definition. The name of the MIB and the name of the file must be the same.
The MIB odl definition can contain at the first line an expression. The expression must be added as a comment and must start with "expr:"
parser | the odl parser instance |
path | the path that needs to be scanned |
Definition at line 186 of file amxo_parser_mibs.c.
int amxo_parser_scan_mib_dirs | ( | amxo_parser_t * | parser, |
amxc_var_t * | dirs | ||
) |
Scans multiple directories for MIB odl files.
The directories must be provided as a variant containing a list of variants, where each variant contains a path.
parser | the odl parser instance |
dirs | a variant containing a list of variants, each containing a path. |
Definition at line 209 of file amxo_parser_mibs.c.