ovsdb: Implement C bindings for IDL.
[cascardo/ovs.git] / lib / ovsdb-idl-provider.h
1 /* Copyright (c) 2009 Nicira Networks.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 #ifndef OVSDB_IDL_PROVIDER_H
17 #define OVSDB_IDL_PROVIDER_H 1
18
19 #include "hmap.h"
20 #include "list.h"
21 #include "ovsdb-idl.h"
22 #include "ovsdb-types.h"
23 #include "shash.h"
24 #include "uuid.h"
25
26 struct ovsdb_idl_row {
27     struct hmap_node hmap_node; /* In struct ovsdb_idl_table's 'rows'. */
28     struct uuid uuid;           /* Row "_uuid" field. */
29     struct list src_arcs;       /* Forward arcs (ovsdb_idl_arc.src_node). */
30     struct list dst_arcs;       /* Backward arcs (ovsdb_idl_arc.dst_node). */
31     struct ovsdb_idl_table *table; /* Containing table. */
32     struct ovsdb_datum *fields;    /* Row data, or null if orphaned. */
33 };
34
35 struct ovsdb_idl_column {
36     char *name;
37     struct ovsdb_type type;
38 };
39
40 struct ovsdb_idl_table_class {
41     char *name;
42     const struct ovsdb_idl_column *columns;
43     size_t n_columns;
44     size_t allocation_size;
45     void (*parse)(struct ovsdb_idl_row *);
46     void (*unparse)(struct ovsdb_idl_row *);
47 };
48
49 struct ovsdb_idl_table {
50     const struct ovsdb_idl_table_class *class;
51     struct shash columns;    /* Contains "const struct ovsdb_idl_column *"s. */
52     struct hmap rows;        /* Contains "struct ovsdb_idl_row"s. */
53     struct ovsdb_idl *idl;   /* Containing idl. */
54 };
55
56 struct ovsdb_idl_class {
57     const struct ovsdb_idl_table_class *tables;
58     size_t n_tables;
59 };
60
61 struct ovsdb_idl_row *ovsdb_idl_get_row_arc(
62     struct ovsdb_idl_row *src,
63     struct ovsdb_idl_table_class *dst_table,
64     const struct uuid *dst_uuid);
65
66 struct ovsdb_idl_row *ovsdb_idl_first_row(
67     const struct ovsdb_idl *, const struct ovsdb_idl_table_class *);
68
69 struct ovsdb_idl_row *ovsdb_idl_next_row(const struct ovsdb_idl_row *);
70
71 #endif /* ovsdb-idl-provider.h */