diff audioDB.h @ 279:dee55886eca0 sampling

make the RNG a part of the audioDB object. Easier to deal with memory discipline and initialization (though note the FIXME comment in audioDB::initTables()). Also initialize the RNG from the current time. A mature implementation would use a proper source of entropy...
author mas01cr
date Wed, 02 Jul 2008 13:53:23 +0000
parents d9dba57becd4
children
line wrap: on
line diff
--- a/audioDB.h	Tue Jul 01 22:17:33 2008 +0000
+++ b/audioDB.h	Wed Jul 02 13:53:23 2008 +0000
@@ -159,6 +159,8 @@
   char* indata;
   struct stat statbuf;  
   dbTableHeaderPtr dbH;
+
+  gsl_rng *rng;
   
   char *fileTable;
   unsigned* trackTable;
@@ -224,6 +226,7 @@
   void set_up_db(double **snp, double **vsnp, double **spp, double **vspp, double **mddp, unsigned int *dvp);
   void query_loop(const char* dbName, const char* inFile, Reporter *reporter);
 
+  void initRNG();
   void initDBHeader(const char *dbName);
   void initInputFile(const char *inFile);
   void initTables(const char* dbName, const char* inFile);
@@ -251,7 +254,7 @@
   void batchinsert(const char* dbName, const char* inFile);
   void query(const char* dbName, const char* inFile, adb__queryResponse *adbQueryResponse=0);
   void status(const char* dbName, adb__statusResponse *adbStatusResponse=0);
-  unsigned random_track(unsigned *propTable, unsigned total, gsl_rng *);
+  unsigned random_track(unsigned *propTable, unsigned total);
   void sample(const char *dbName);
   void ws_status(const char*dbName, char* hostport);
   void ws_query(const char*dbName, const char *trackKey, const char* hostport);
@@ -285,6 +288,7 @@
   db(0), \
   indata(0), \
   dbH(0), \
+  rng(0), \
   fileTable(0), \
   trackTable(0), \
   dataBuf(0), \