]> git.proxmox.com Git - ovs.git/blob - ovsdb/table.h
Initial implementation of OVSDB.
[ovs.git] / ovsdb / table.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_TABLE_H
17 #define OVSDB_TABLE_H 1
18
19 #include <stdbool.h>
20 #include "compiler.h"
21 #include "hmap.h"
22 #include "shash.h"
23
24 struct json;
25 struct uuid;
26
27 /* Schema for a database table. */
28 struct ovsdb_table_schema {
29 char *name;
30 char *comment;
31 bool mutable;
32 struct shash columns; /* Contains "struct ovsdb_column *"s. */
33 };
34
35 struct ovsdb_table_schema *ovsdb_table_schema_create(const char *name,
36 const char *comment,
37 bool mutable);
38 void ovsdb_table_schema_destroy(struct ovsdb_table_schema *);
39
40 struct ovsdb_error *ovsdb_table_schema_from_json(const struct json *,
41 const char *name,
42 struct ovsdb_table_schema **)
43 WARN_UNUSED_RESULT;
44 struct json *ovsdb_table_schema_to_json(const struct ovsdb_table_schema *);
45
46 const struct ovsdb_column *ovsdb_table_schema_get_column(
47 const struct ovsdb_table_schema *, const char *name);
48 \f
49 /* Database table. */
50
51 struct ovsdb_table {
52 struct ovsdb_table_schema *schema;
53 struct hmap rows; /* Contains "struct ovsdb_row"s. */
54 };
55
56 struct ovsdb_table *ovsdb_table_create(struct ovsdb_table_schema *);
57 void ovsdb_table_destroy(struct ovsdb_table *);
58
59 const struct ovsdb_row *ovsdb_table_get_row(const struct ovsdb_table *,
60 const struct uuid *);
61 bool ovsdb_table_put_row(struct ovsdb_table *, struct ovsdb_row *);
62
63 #endif /* ovsdb/table.h */