annotate accumulator_test.cpp @ 580:633614461994

API for retrieving a track's data. A new function, audiodb_retrieve_datum() fills a provided adb_datum_t structure with the data corresponding to a given database key; the companion audiodb_free_datum() function frees the data in a given datum appropriately. Just in case, I continue to require passing in the adb_t * as the first argument to audiodb_free_datum(), even though it's not currently used: I couldn't convince myself that _all_ possible implementations could free a datum without reference to the adb_t. This meant rewriting the internal code to use a new internal audiodb_really_free_datum() function, which audiodb_free_datum() also calls. Sanity-checked by implementing a binding in sb-alien to this function, lightly-tested. All this fixes ticket:20 in Trac.
author mas01cr
date Tue, 14 Jul 2009 15:35:36 +0000
parents 342822c2d49a
children
rev   line source
mas01cr@498 1 #include "audioDB.h"
mas01cr@498 2 extern "C" {
mas01cr@498 3 #include "audioDB_API.h"
mas01cr@498 4 }
mas01cr@498 5 #include "audioDB-internals.h"
mas01cr@498 6
mas01cr@498 7 #include "accumulators.h"
mas01cr@498 8
mas01cr@498 9 static NearestAccumulator<adb_result_dist_lt> *foo = new NearestAccumulator<adb_result_dist_lt>();
mas01cr@498 10
mas01cr@498 11 int main() {
mas01cr@498 12 adb_result_t r;
mas01cr@498 13 r.key = "hello";
mas01cr@498 14 r.ipos = 0;
mas01cr@498 15 r.qpos = 0;
mas01cr@498 16 r.dist = 3;
mas01cr@498 17 foo->add_point(&r);
mas01cr@498 18 r.ipos = 1;
mas01cr@498 19 r.dist = 2;
mas01cr@498 20 foo->add_point(&r);
mas01cr@498 21 r.qpos = 1;
mas01cr@498 22 foo->add_point(&r);
mas01cr@498 23
mas01cr@498 24 adb_query_results_t *rs;
mas01cr@498 25 rs = foo->get_points();
mas01cr@498 26 for (unsigned int k = 0; k < rs->nresults; k++) {
mas01cr@498 27 r = rs->results[k];
mas01cr@498 28 printf("%s: %f %u %u\n", r.key, r.dist, r.qpos, r.ipos);
mas01cr@498 29 }
mas01cr@498 30 free(rs->results);
mas01cr@498 31 free(rs);
mas01cr@498 32 delete foo;
mas01cr@498 33 return 1;
mas01cr@498 34 }