1 /* Copyright (c) 2009, 2010, 2011 Nicira, Inc.
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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef OVSDB_MUTATION_H
17 #define OVSDB_MUTATION_H 1
21 #include "ovsdb-data.h"
24 struct ovsdb_table_schema;
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")
39 #define OVSDB_MUTATOR(ENUM, NAME) ENUM,
44 struct ovsdb_error *ovsdb_mutator_from_string(const char *,
47 const char *ovsdb_mutator_to_string(enum ovsdb_mutator);
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;
56 struct ovsdb_mutation_set {
57 struct ovsdb_mutation *mutations;
61 #define OVSDB_MUTATION_SET_INITIALIZER { NULL, 0 }
63 struct ovsdb_error *ovsdb_mutation_set_from_json(
64 const struct ovsdb_table_schema *,
65 const struct json *, struct ovsdb_symbol_table *,
66 struct ovsdb_mutation_set *) WARN_UNUSED_RESULT;
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(
70 struct ovsdb_row *, const struct ovsdb_mutation_set *) WARN_UNUSED_RESULT;
72 #endif /* ovsdb/mutation.h */