X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=ovsdb%2Frow.h;h=45c7fb397b015e99f423d702fc77064772eabb4a;hb=c5cf10598f8c9f4428291e9df3ecd72a05fb1ccf;hp=302f61ab1712f5d316c2799590a591f88a9a28e5;hpb=fbf925e45da7100e5018bd3ad49532e407666f77;p=sliver-openvswitch.git diff --git a/ovsdb/row.h b/ovsdb/row.h index 302f61ab1..45c7fb397 100644 --- a/ovsdb/row.h +++ b/ovsdb/row.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2009, 2010 Nicira Networks +/* Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,23 +20,51 @@ #include #include "column.h" #include "hmap.h" +#include "list.h" #include "ovsdb-data.h" struct ovsdb_column_set; +/* A weak reference. + * + * When a column in row A contains a weak reference to UUID of a row B this + * constitutes a weak reference from A (the source) to B (the destination). + * + * Rows A and B may be in the same table or different tables. + * + * Weak references from a row to itself are allowed, but no "struct + * ovsdb_weak_ref" structures are created for them. + */ +struct ovsdb_weak_ref { + struct list src_node; /* In src->src_refs list. */ + struct list dst_node; /* In destination row's dst_refs list. */ + struct ovsdb_row *src; /* Source row. */ +}; + /* A row in a database table. */ struct ovsdb_row { - struct ovsdb_table *table; /* Table to which this belongs. */ - struct hmap_node hmap_node; /* Element in ovsdb_table's 'rows' hmap. */ + struct hmap_node hmap_node; /* Element in ovsdb_table's 'rows' hmap. */ + struct ovsdb_table *table; /* Table to which this belongs. */ struct ovsdb_txn_row *txn_row; /* Transaction that row is in, if any. */ - /* Number of refs to this row from other rows, in this table or other - * tables, through 'uuid' columns that have a 'refTable' constraint - * pointing to this table. A row with nonzero 'n_refs' cannot be deleted. - * Updated and checked only at transaction commit. */ + /* Weak references. */ + struct list src_refs; /* Weak references from this row. */ + struct list dst_refs; /* Weak references to this row. */ + + /* Number of strong refs to this row from other rows, in this table or + * other tables, through 'uuid' columns that have a 'refTable' constraint + * pointing to this table and a 'refType' of "strong". A row with nonzero + * 'n_refs' cannot be deleted. Updated and checked only at transaction + * commit. */ size_t n_refs; + /* One datum for each column (shash_count(&table->schema->columns) + * elements). */ struct ovsdb_datum fields[]; + + /* Followed by table->schema->n_indexes "struct hmap_node"s. In rows that + * have have been committed as part of the database, the hmap_node with + * index 'i' is contained in hmap table->indexes[i]. */ }; struct ovsdb_row *ovsdb_row_create(const struct ovsdb_table *); @@ -54,7 +82,8 @@ int ovsdb_row_compare_columns_3way(const struct ovsdb_row *, const struct ovsdb_column_set *); void ovsdb_row_update_columns(struct ovsdb_row *, const struct ovsdb_row *, const struct ovsdb_column_set *); - +void ovsdb_row_columns_to_string(const struct ovsdb_row *, + const struct ovsdb_column_set *, struct ds *); struct ovsdb_error *ovsdb_row_from_json(struct ovsdb_row *, const struct json *, struct ovsdb_symbol_table *,