]>
git.proxmox.com Git - mirror_ovs.git/blob - ovsdb/condition.h
1 /* Copyright (c) 2009, 2010 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_CONDITION_H
17 #define OVSDB_CONDITION_H 1
21 #include "ovsdb-data.h"
23 #include "ovsdb-condition.h"
26 struct ovsdb_table_schema
;
30 enum ovsdb_function function
;
31 const struct ovsdb_column
*column
;
33 struct ovsdb_datum arg
;
36 struct ovsdb_condition
{
37 struct ovsdb_clause
*clauses
;
40 struct shash o_columns
;
43 #define OVSDB_CONDITION_INITIALIZER(COND) \
44 { NULL, 0, true, SHASH_INITIALIZER(&(COND)->o_columns)}
46 void ovsdb_condition_init(struct ovsdb_condition
*);
47 bool ovsdb_condition_empty(const struct ovsdb_condition
*);
48 struct ovsdb_error
*ovsdb_condition_from_json(
49 const struct ovsdb_table_schema
*,
50 const struct json
*, struct ovsdb_symbol_table
*,
51 struct ovsdb_condition
*) OVS_WARN_UNUSED_RESULT
;
52 struct json
*ovsdb_condition_to_json(const struct ovsdb_condition
*);
53 void ovsdb_condition_destroy(struct ovsdb_condition
*);
54 bool ovsdb_condition_match_every_clause(const struct ovsdb_row
*,
55 const struct ovsdb_condition
*);
56 bool ovsdb_condition_match_any_clause(const struct ovsdb_datum
*,
57 const struct ovsdb_condition
*,
58 unsigned int index_map
[]);
59 int ovsdb_condition_cmp_3way(const struct ovsdb_condition
*a
,
60 const struct ovsdb_condition
*b
);
61 void ovsdb_condition_clone(struct ovsdb_condition
*to
,
62 const struct ovsdb_condition
*from
);
63 bool ovsdb_condition_is_true(const struct ovsdb_condition
*cond
);
64 bool ovsdb_condition_is_false(const struct ovsdb_condition
*cond
);
65 const struct ovsdb_column
**
66 ovsdb_condition_get_columns(const struct ovsdb_condition
*cond
,
70 ovsdb_condition_empty_or_match_any(const struct ovsdb_datum
*row_datum
,
71 const struct ovsdb_condition
*cnd
,
72 unsigned int index_map
[])
74 return (ovsdb_condition_empty(cnd
) ||
75 ovsdb_condition_match_any_clause(row_datum
, cnd
, index_map
));
78 #endif /* ovsdb/condition.h */