3df3693c03ebb240d3b42238f6e9aa21ebf2cfbf
[sim/o1-interface.git] / ntsimulator / ntsim-ng / core / datastore / populate.h
1 /*************************************************************************
2 *
3 * Copyright 2020 highstreet technologies GmbH and others
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 ***************************************************************************/
17
18 #pragma once
19
20 #include <string.h>
21 #include <stdint.h>
22 #include <stdbool.h>
23 #include <libyang/libyang.h>
24
25 typedef struct {
26     int init;
27
28     char *xpath;
29
30     const struct lys_module **modules;
31     int mod_count;
32
33     struct lyd_node *operational;
34     struct lyd_node *running;
35 } populate_instance_t;
36
37 typedef struct {
38     struct lyd_node *operational;
39     struct lyd_node *running;
40     bool late_resolving;
41
42     int late_resolve_count;
43     struct lys_node **late_resolve_schema;
44     struct lyd_node **late_resolve_parent_o;
45     struct lyd_node **late_resolve_parent_r;
46     populate_instance_t **late_resolve_instance;
47 } populate_job_t;
48
49 //populate.c
50 int schema_populate(void);                     //populate all available root nodes (taking into consideration excluded, deprecated and unimplemented)
51
52 //populate_rec.c
53 int schema_populate_recursive(populate_job_t *job, populate_instance_t *instance, struct lys_node *schema, struct lyd_node *parent_o, struct lyd_node *parent_r);
54 int schema_populate_add_leaf(populate_job_t *job, populate_instance_t *instance, struct lys_node *schema, struct lyd_node *parent_o, struct lyd_node *parent_r);