]>
Commit | Line | Data |
---|---|---|
e0edde6f | 1 | /* Copyright (c) 2009, 2010, 2011 Nicira, Inc. |
f85f8ebb BP |
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; | |
f85f8ebb BP |
30 | bool mutable; |
31 | struct shash columns; /* Contains "struct ovsdb_column *"s. */ | |
87ab878c | 32 | unsigned int max_rows; /* Maximum number of rows. */ |
c5f341ab | 33 | bool is_root; /* Part of garbage collection root set? */ |
6910a6e6 BP |
34 | struct ovsdb_column_set *indexes; |
35 | size_t n_indexes; | |
f85f8ebb BP |
36 | }; |
37 | ||
c5f341ab BP |
38 | struct ovsdb_table_schema *ovsdb_table_schema_create( |
39 | const char *name, bool mutable, unsigned int max_rows, bool is_root); | |
58985e09 BP |
40 | struct ovsdb_table_schema *ovsdb_table_schema_clone( |
41 | const struct ovsdb_table_schema *); | |
f85f8ebb BP |
42 | void ovsdb_table_schema_destroy(struct ovsdb_table_schema *); |
43 | ||
44 | struct ovsdb_error *ovsdb_table_schema_from_json(const struct json *, | |
45 | const char *name, | |
46 | struct ovsdb_table_schema **) | |
cab50449 | 47 | OVS_WARN_UNUSED_RESULT; |
c5f341ab BP |
48 | struct json *ovsdb_table_schema_to_json(const struct ovsdb_table_schema *, |
49 | bool default_is_root); | |
f85f8ebb BP |
50 | |
51 | const struct ovsdb_column *ovsdb_table_schema_get_column( | |
52 | const struct ovsdb_table_schema *, const char *name); | |
53 | \f | |
54 | /* Database table. */ | |
55 | ||
56 | struct ovsdb_table { | |
57 | struct ovsdb_table_schema *schema; | |
71c93bd4 | 58 | struct ovsdb_txn_table *txn_table; /* Only if table is in a transaction. */ |
f85f8ebb | 59 | struct hmap rows; /* Contains "struct ovsdb_row"s. */ |
6910a6e6 BP |
60 | |
61 | /* An array of schema->n_indexes hmaps, each of which contains "struct | |
62 | * ovsdb_row"s. Each of the hmap_nodes in indexes[i] are at index 'i' at | |
63 | * the end of struct ovsdb_row, following the 'fields' member. */ | |
64 | struct hmap *indexes; | |
f85f8ebb BP |
65 | }; |
66 | ||
67 | struct ovsdb_table *ovsdb_table_create(struct ovsdb_table_schema *); | |
68 | void ovsdb_table_destroy(struct ovsdb_table *); | |
69 | ||
70 | const struct ovsdb_row *ovsdb_table_get_row(const struct ovsdb_table *, | |
71 | const struct uuid *); | |
f85f8ebb BP |
72 | |
73 | #endif /* ovsdb/table.h */ |