Mercurial > hg > audiodb
diff audioDB.h @ 204:2ea1908707c7 refactoring
Filewise refactor.
Break apart huge monolithic audioDB.cpp file into seven broadly
independent portions:
* SOAP
* DB creation
* insertion
* query
* dump
* common functionality
* constructor functions
Remove the "using namespace std" from the header file, though that
wasn't actually a problem: the problem in question is solved by
including adb.nsmap in only soap.cpp.
Makefile improvements.
author | mas01cr |
---|---|
date | Wed, 28 Nov 2007 15:10:28 +0000 |
parents | 72a037f2b1e4 |
children | 3c7c8b84e4f3 |
line wrap: on
line diff
--- a/audioDB.h Wed Nov 28 12:35:09 2007 +0000 +++ b/audioDB.h Wed Nov 28 15:10:28 2007 +0000 @@ -15,7 +15,6 @@ // includes for web services #include "soapH.h" -#include "adb.nsmap" #include "cmdline.h" #define MAXSTR 512 @@ -93,7 +92,13 @@ #define ENSURE_STRING(x) ((x) ? (x) : "") -using namespace std; +#define CHECKED_MMAP(type, var, start, length) \ + { void *tmp = mmap(0, length, (PROT_READ | (forWrite ? PROT_WRITE : 0)), MAP_SHARED, dbfid, (start)); \ + if(tmp == (void *) -1) { \ + error("mmap error for db table", #var, "mmap"); \ + } \ + var = (type) tmp; \ + } typedef struct dbTableHeader{ uint32_t magic; @@ -122,13 +127,13 @@ const char *hostport; const char *key; const char* trackFileName; - ifstream *trackFile; + std::ifstream *trackFile; const char *command; const char *output; const char *timesFileName; - ifstream *timesFile; + std::ifstream *timesFile; const char *powerFileName; - ifstream *powerFile; + std::ifstream *powerFile; int powerfd; int dbfid; @@ -200,7 +205,7 @@ void initTables(const char* dbName, const char* inFile); void unitNorm(double* X, unsigned d, unsigned n, double* qNorm); void unitNormAndInsertL2(double* X, unsigned dim, unsigned n, unsigned append); - void insertTimeStamps(unsigned n, ifstream* timesFile, double* timesdata); + void insertTimeStamps(unsigned n, std::ifstream* timesFile, double* timesdata); void insertPowerData(unsigned n, int powerfd, double *powerdata); unsigned getKeyPos(char* key); public: