annotate power.cpp @ 402:58b88ab69424 api-inversion

Move the struct adb definition from the auidioDB_API.h into the audioDB-internals.h header file, leaving only the typedef behind. Thus a user of the API sees only an incomplete type, which cannot be instantiated (but /pointers/ to it can); there's then less temptation to break the abstraction barrier by using structure fields in client code. Not only that, but we can now safely put C++ stuff in the structure. Take advantage of this by putting a std::set<std::string> in there, to hold all the keys currently in the database; populate this field on audiodb_open() (and delete it on audiodb_close). This will be useful when we come to implement variants of audiodb_insert().
author mas01cr
date Wed, 03 Dec 2008 17:40:15 +0000
parents a8a5f2ca5380
children 7038f31124d1
rev   line source
mas01cr@400 1 #include "audioDB.h"
mas01cr@400 2 extern "C" {
mas01cr@400 3 #include "audioDB_API.h"
mas01cr@401 4 #include "audioDB-internals.h"
mas01cr@400 5 }
mas01cr@400 6
mas01cr@400 7 int audiodb_power(adb_t *adb) {
mas01cr@400 8 /* FIXME: we should probably include in adb_t information about
mas01cr@400 9 * which mode (O_RDONLY|O_RDWR) the database was opened, so that we
mas01cr@400 10 * can check that it's writeable. */
mas01cr@400 11 if(adb->header->length > 0) {
mas01cr@400 12 return 1;
mas01cr@400 13 }
mas01cr@400 14
mas01cr@400 15 adb->header->flags |= O2_FLAG_POWER;
mas01cr@400 16 return audiodb_sync_header(adb);
mas01cr@400 17 }