ovsdb: Rename ovsdb_file to ovsdb_log.
[cascardo/ovs.git] / ovsdb / ovsdb.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_OVSDB_H
17 #define OVSDB_OVSDB_H 1
18
19 #include "compiler.h"
20 #include "hmap.h"
21 #include "list.h"
22 #include "shash.h"
23
24 struct json;
25 struct uuid;
26
27 /* Database schema. */
28 struct ovsdb_schema {
29     char *name;
30     char *comment;
31     struct shash tables;        /* Contains "struct ovsdb_table_schema *"s. */
32 };
33
34 struct ovsdb_schema *ovsdb_schema_create(const char *name,
35                                          const char *comment);
36 void ovsdb_schema_destroy(struct ovsdb_schema *);
37
38 struct ovsdb_error *ovsdb_schema_from_file(const char *file_name,
39                                            struct ovsdb_schema **)
40     WARN_UNUSED_RESULT;
41 struct ovsdb_error *ovsdb_schema_from_json(struct json *,
42                                            struct ovsdb_schema **)
43     WARN_UNUSED_RESULT;
44 struct json *ovsdb_schema_to_json(const struct ovsdb_schema *);
45 \f
46 /* Database. */
47 struct ovsdb {
48     struct ovsdb_schema *schema;
49     struct ovsdb_log *log;      /* Disk log (null for in-memory db). */
50     struct shash tables;        /* Contains "struct ovsdb_table *"s. */
51
52     /* Triggers. */
53     struct list triggers;       /* Contains "struct ovsdb_trigger"s. */
54     bool run_triggers;
55 };
56
57 struct ovsdb *ovsdb_create(struct ovsdb_log *, struct ovsdb_schema *);
58 struct ovsdb_error *ovsdb_open(const char *file_name, bool read_only,
59                                struct ovsdb **)
60     WARN_UNUSED_RESULT;
61 void ovsdb_destroy(struct ovsdb *);
62
63 struct ovsdb_error *ovsdb_from_json(const struct json *, struct ovsdb **)
64     WARN_UNUSED_RESULT;
65 struct json *ovsdb_to_json(const struct ovsdb *);
66
67 struct ovsdb_table *ovsdb_get_table(const struct ovsdb *, const char *);
68
69 struct json *ovsdb_execute(struct ovsdb *, const struct json *params,
70                            long long int elapsed_msec,
71                            long long int *timeout_msec);
72
73 #endif /* ovsdb/ovsdb.h */