herr_t
ss_scope_synchronize(ss_scope_t *scope, /* A link to an open scope that should be synchronized. */
unsigned tableidx, /* Magic number to define which table to synchronize. If TABLEIDX is
* SS_TABLE_ALL then all tables of the scope will be synchronized. */
ss_prop_t *props /* See [Synchronization Properties] */
)
{
SS_ENTER(ss_scope_synchronize, herr_t);
ss_table_t *table=NULL;
const char *scopename=NULL;
SS_ASSERT_MEM(scope, ss_scope_t);
tableidx = SS_MAGIC_SEQUENCE(tableidx);
/* If the scope is open for read-only access then there should be nothing to do. However, if SSlib was compiled with
* debugging support then we should descend into the table synchronization anyway in order to check that the client didn't
* accidently modify an object. */
#ifdef NDEBUG
if (!ss_scope_iswritable(scope)) goto done;
#endif
if (NULL==(scopename = ss_string_ptr(SS_SCOPE_P(scope,name)))) SS_ERROR(FAILED);
if (SS_TABLE_ALL==tableidx) {
for (tableidx=0; tableidx<SS_PERS_NCLASSES; tableidx++) {
if (!SS_PERS_CLASS(tableidx)) continue;
if (NULL==(table=ss_scope_table(scope, tableidx, NULL))) SS_ERROR(FAILED);
if (ss_table_synchronize(table, scope, props)<0)
SS_ERROR_FMT(FAILED, ("table %u of scope \"%s\"", tableidx, scopename));
}
} else {
if (!SS_PERS_CLASS(tableidx)) SS_ERROR(NOTFOUND);
if (NULL==(table=ss_scope_table(scope, tableidx, NULL))) SS_ERROR(FAILED);
if (ss_table_synchronize(table, scope, props)<0)
SS_ERROR_FMT(FAILED, ("%s table(%u) of scope \"%s\"", SS_PERS_CLASS(tableidx)->name, tableidx, scopename));
}
#ifdef NDEBUG
done:
#endif
SS_CLEANUP:
SS_LEAVE(0);
}