changeset 422:a7d61291fbda api-inversion

Baby steps... Decorate accumulator.h with a preprocessor #define and test; then create appropriate accumulators in audioDB::query() and delete them if necessary in audioDB::cleanup().
author mas01cr
date Wed, 24 Dec 2008 10:55:03 +0000
parents 166312a124bc
children b09d2eb1a2b2
files accumulator.h audioDB.cpp query.cpp
diffstat 3 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/accumulator.h	Wed Dec 24 10:54:59 2008 +0000
+++ b/accumulator.h	Wed Dec 24 10:55:03 2008 +0000
@@ -1,6 +1,11 @@
+#ifndef ACCUMULATOR_H
+#define ACCUMULATOR_H
+
 class Accumulator {
 public:
   virtual ~Accumulator() {};
   virtual void add_point(adb_result_t *r) = 0;
   virtual adb_query_results_t *get_points() = 0;
 };
+
+#endif
--- a/audioDB.cpp	Wed Dec 24 10:54:59 2008 +0000
+++ b/audioDB.cpp	Wed Dec 24 10:55:03 2008 +0000
@@ -225,6 +225,8 @@
     delete [] trackOffsetTable;
   if(reporter)
     delete reporter;
+  if(accumulator)
+    delete accumulator;
   if(exact_evaluation_queue)
     delete exact_evaluation_queue;
   if(rng)
--- a/query.cpp	Wed Dec 24 10:54:59 2008 +0000
+++ b/query.cpp	Wed Dec 24 10:55:03 2008 +0000
@@ -1,6 +1,9 @@
 #include "audioDB.h"
 #include "reporter.h"
 
+#include "audioDB-internals.h"
+#include "accumulators.h"
+
 bool audioDB::powers_acceptable(double p1, double p2) {
   if (use_absolute_threshold) {
     if ((p1 < absolute_threshold) || (p2 < absolute_threshold)) {
@@ -31,15 +34,18 @@
     sequenceLength = 1;
     normalizedDistance = false;
     reporter = new pointQueryReporter< std::greater < NNresult > >(pointNN);
+    accumulator = new DBAccumulator<adb_result_dist_gt>(pointNN);
     break;
   case O2_TRACK_QUERY:
     sequenceLength = 1;
     normalizedDistance = false;
     reporter = new trackAveragingReporter< std::greater< NNresult > >(pointNN, trackNN, dbH->numFiles);
+    accumulator = new PerTrackAccumulator<adb_result_dist_gt>(pointNN, trackNN);
     break;
   case O2_SEQUENCE_QUERY:    
     if(no_unit_norming)
       normalizedDistance = false;
+    accumulator = new PerTrackAccumulator<adb_result_dist_lt>(pointNN, trackNN);
     if(radius == 0) {
       reporter = new trackAveragingReporter< std::less< NNresult > >(pointNN, trackNN, dbH->numFiles);
     } else {
@@ -56,6 +62,7 @@
   case O2_N_SEQUENCE_QUERY:
     if(no_unit_norming)
       normalizedDistance = false;
+    accumulator = new PerTrackAccumulator<adb_result_dist_lt>(pointNN, trackNN);
     if(radius == 0) {
       reporter = new trackSequenceQueryNNReporter< std::less < NNresult > >(pointNN, trackNN, dbH->numFiles);
     } else {
@@ -70,6 +77,7 @@
     }
     break;
   case O2_ONE_TO_ONE_N_SEQUENCE_QUERY :
+    accumulator = new NearestAccumulator<adb_result_dist_lt>();
     if(radius == 0) {
       error("query-type not yet supported");
     } else {