diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-07-05 18:39:09 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-07-05 18:39:09 +0200 |
commit | 72f0237f3310a69fd566f1d2c25ca805f677199a (patch) | |
tree | dae417dd3216f20be7e2c75aacd85ccc7ba0d97f /odb/schema-catalog.cxx | |
parent | afa56605aca5021c5aab2fbe70cdfb81f863206f (diff) |
Add support for multi-pass database schema generation
Diffstat (limited to 'odb/schema-catalog.cxx')
-rw-r--r-- | odb/schema-catalog.cxx | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/odb/schema-catalog.cxx b/odb/schema-catalog.cxx index 5332cce..2d8415f 100644 --- a/odb/schema-catalog.cxx +++ b/odb/schema-catalog.cxx @@ -14,7 +14,7 @@ using namespace std; namespace odb { - typedef void (*create_function) (database&); + typedef bool (*create_function) (database&, unsigned short pass); typedef vector<create_function> create_functions; struct schema_catalog_impl: map<string, create_functions> {}; @@ -33,9 +33,23 @@ namespace odb const create_functions& fs (i->second); - for (create_functions::const_iterator j (fs.begin ()), e (fs.end ()); - j != e; ++j) - (*j) (db); + // Run the passes until we ran them all or all the functions + // return false, which means no more passes necessary. + // + for (unsigned short pass (0); pass < 3; ++pass) + { + bool done (true); + + for (create_functions::const_iterator j (fs.begin ()), e (fs.end ()); + j != e; ++j) + { + if ((*j) (db, pass)) + done = false; + } + + if (done) + break; + } } // schema_catalog_init |