]>
Commit | Line | Data |
---|---|---|
e0edde6f | 1 | /* Copyright (c) 2009, 2010, 2011 Nicira, Inc. |
e9f8f936 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_MUTATION_H | |
17 | #define OVSDB_MUTATION_H 1 | |
18 | ||
19 | #include <stddef.h> | |
20 | #include "compiler.h" | |
21 | #include "ovsdb-data.h" | |
22 | ||
23 | struct json; | |
24 | struct ovsdb_table_schema; | |
25 | struct ovsdb_row; | |
26 | ||
27 | /* These list is ordered in ascending order of the fraction of tables row that | |
28 | * they are (heuristically) expected to leave in query results. */ | |
29 | #define OVSDB_MUTATORS \ | |
30 | OVSDB_MUTATOR(OVSDB_M_ADD, "+=") \ | |
31 | OVSDB_MUTATOR(OVSDB_M_SUB, "-=") \ | |
32 | OVSDB_MUTATOR(OVSDB_M_MUL, "*=") \ | |
33 | OVSDB_MUTATOR(OVSDB_M_DIV, "/=") \ | |
34 | OVSDB_MUTATOR(OVSDB_M_MOD, "%=") \ | |
35 | OVSDB_MUTATOR(OVSDB_M_INSERT, "insert") \ | |
36 | OVSDB_MUTATOR(OVSDB_M_DELETE, "delete") | |
37 | ||
38 | enum ovsdb_mutator { | |
39 | #define OVSDB_MUTATOR(ENUM, NAME) ENUM, | |
40 | OVSDB_MUTATORS | |
41 | #undef OVSDB_MUTATOR | |
42 | }; | |
43 | ||
44 | struct ovsdb_error *ovsdb_mutator_from_string(const char *, | |
45 | enum ovsdb_mutator *) | |
cab50449 | 46 | OVS_WARN_UNUSED_RESULT; |
e9f8f936 BP |
47 | const char *ovsdb_mutator_to_string(enum ovsdb_mutator); |
48 | ||
49 | struct ovsdb_mutation { | |
50 | enum ovsdb_mutator mutator; | |
51 | const struct ovsdb_column *column; | |
52 | struct ovsdb_datum arg; | |
53 | struct ovsdb_type type; | |
54 | }; | |
55 | ||
56 | struct ovsdb_mutation_set { | |
57 | struct ovsdb_mutation *mutations; | |
58 | size_t n_mutations; | |
59 | }; | |
60 | ||
61 | #define OVSDB_MUTATION_SET_INITIALIZER { NULL, 0 } | |
62 | ||
63 | struct ovsdb_error *ovsdb_mutation_set_from_json( | |
64 | const struct ovsdb_table_schema *, | |
fbf925e4 | 65 | const struct json *, struct ovsdb_symbol_table *, |
cab50449 | 66 | struct ovsdb_mutation_set *) OVS_WARN_UNUSED_RESULT; |
e9f8f936 BP |
67 | struct json *ovsdb_mutation_set_to_json(const struct ovsdb_mutation_set *); |
68 | void ovsdb_mutation_set_destroy(struct ovsdb_mutation_set *); | |
69 | struct ovsdb_error *ovsdb_mutation_set_execute( | |
cab50449 | 70 | struct ovsdb_row *, const struct ovsdb_mutation_set *) OVS_WARN_UNUSED_RESULT; |
e9f8f936 BP |
71 | |
72 | #endif /* ovsdb/mutation.h */ |