Mercurial > hg > audiodb
comparison common.cpp @ 469:d3afc91d205d api-inversion
Move audioDB::query over to audioDB.cpp
At the same time, remove all the abstraction violations in
audioDB::query, which came in two flavours: use of dbH->numFiles, which
is dealt with by getting the database status instead (and is eventually
unnecessary, being only needed now because reporters are implemented in
terms of vectors indexed by ID), and use of fileTable in reporter's
report functions (dealt with by passing in the adb instead).
To actually implement reporting as of now, we continue to use stuff from
audioDB-internals.h; maybe someday we will be clean and shiny.
author | mas01cr |
---|---|
date | Wed, 31 Dec 2008 15:44:16 +0000 |
parents | 913a95f06998 |
children | 8fb85fbcaba6 |
comparison
equal
deleted
inserted
replaced
468:4dbd7917bf9e | 469:d3afc91d205d |
---|---|
210 // OK to prefix relative path+filename | 210 // OK to prefix relative path+filename |
211 char* prefixedName = (char*) malloc(O2_MAXFILESTR); | 211 char* prefixedName = (char*) malloc(O2_MAXFILESTR); |
212 sprintf(prefixedName, "%s/%s", prefix, *name); | 212 sprintf(prefixedName, "%s/%s", prefix, *name); |
213 *name = prefixedName; // side effect new name to old name | 213 *name = prefixedName; // side effect new name to old name |
214 } | 214 } |
215 | |
216 void audioDB::insertTimeStamps(unsigned numVectors, std::ifstream *timesFile, double *timesdata) { | |
217 assert(usingTimes); | |
218 | |
219 unsigned numtimes = 0; | |
220 | |
221 if(!timesFile->is_open()) { | |
222 error("problem opening times file on timestamped database", timesFileName); | |
223 } | |
224 | |
225 double timepoint, next; | |
226 *timesFile >> timepoint; | |
227 if (timesFile->eof()) { | |
228 error("no entries in times file", timesFileName); | |
229 } | |
230 numtimes++; | |
231 do { | |
232 *timesFile >> next; | |
233 if (timesFile->eof()) { | |
234 break; | |
235 } | |
236 numtimes++; | |
237 timesdata[0] = timepoint; | |
238 timepoint = (timesdata[1] = next); | |
239 timesdata += 2; | |
240 } while (numtimes < numVectors + 1); | |
241 | |
242 if (numtimes < numVectors + 1) { | |
243 error("too few timepoints in times file", timesFileName); | |
244 } | |
245 | |
246 *timesFile >> next; | |
247 if (!timesFile->eof()) { | |
248 error("too many timepoints in times file", timesFileName); | |
249 } | |
250 } |