# HG changeset patch # User mas01cr # Date 1227525177 0 # Node ID f6aa8c5cd865a0b33762c02ec1c6eb185234afd0 # Parent 033051b7dc6fe02ca7265fc442512c0b341fa2df Preparation for more complex inversion. Add a file descriptor and a DB Header struct pointer into the audioDB structure. (The structure description that is visible in audioDB_API.h should never be exposed to code _using_ the library; for that, the adb_t structure should be completely opaque, only ever passed around to API functions. For actually _implementing_ the library, though, of course we need access to our own internals...) diff -r 033051b7dc6f -r f6aa8c5cd865 audioDB.cpp --- a/audioDB.cpp Mon Nov 24 11:12:56 2008 +0000 +++ b/audioDB.cpp Mon Nov 24 11:12:57 2008 +0000 @@ -922,7 +922,7 @@ argv[argvctr++]="audioDB"; argv[argvctr++]="-I"; argv[argvctr++]="-d"; - argv[argvctr++]=mydb->dbname; + argv[argvctr++]=mydb->path; argv[argvctr++]="-f"; argv[argvctr++]=ins->features; @@ -973,7 +973,7 @@ argv[argvctr++]="audioDB"; argv[argvctr++]="-B"; argv[argvctr++]="-d"; - argv[argvctr++]=mydb->dbname; + argv[argvctr++]=mydb->path; /* assume struct is well formed for all entries */ @@ -1100,9 +1100,9 @@ argv[argvctr++]=adbq->querytype; } - if(mydb->dbname){ + if(mydb->path){ argv[argvctr++]="-d"; - argv[argvctr++]=mydb->dbname; + argv[argvctr++]=mydb->path; } if (adbq->feature){ @@ -1201,7 +1201,7 @@ argv[0]="audioDB"; argv[1]="--STATUS"; argv[2]="-d"; - argv[3]=mydb->dbname; + argv[3]=mydb->path; argv[4]='\0'; audioDB::audioDB(4,argv,&sss ,&apierror); @@ -1229,7 +1229,7 @@ argv[argvctr++]="audioDB"; argv[argvctr++]="--DUMP"; argv[argvctr++]="-d"; - argv[argvctr++]=mydb->dbname; + argv[argvctr++]=mydb->path; argv[argvctr++]="--output"; argv[argvctr++]=(char *)outputdir; argv[argvctr]='\0'; @@ -1247,7 +1247,7 @@ argv[0]="audioDB"; argv[1]="--L2NORM"; argv[2]="-d"; - argv[3]=mydb->dbname; + argv[3]=mydb->path; argv[4]='\0'; audioDB::audioDB(4,argv,&apierror); @@ -1262,7 +1262,7 @@ argv[0]="audioDB"; argv[1]="--POWER"; argv[2]="-d"; - argv[3]=mydb->dbname; + argv[3]=mydb->path; argv[4]='\0'; audioDB::audioDB(4,argv,&apierror); @@ -1279,14 +1279,11 @@ if (open(path, O_EXCL) != -1){ mydbp=(adb_ptr)malloc(sizeof(adb)); - mydbp->dbname=(char *)malloc(1+strlen(path)); + mydbp->path=(char *)malloc(1+strlen(path)); - strcpy(mydbp->dbname,path); + strcpy(mydbp->path,path); audiodb_status(mydbp, &mystatus); - mydbp->ntracks=mystatus.numFiles; - mydbp->datadim=mystatus.dim; - return mydbp; } @@ -1297,7 +1294,7 @@ void audiodb_close(adb_ptr db){ - free(db->dbname); + free(db->path); free(db); } diff -r 033051b7dc6f -r f6aa8c5cd865 audioDB_API.h --- a/audioDB_API.h Mon Nov 24 11:12:56 2008 +0000 +++ b/audioDB_API.h Mon Nov 24 11:12:57 2008 +0000 @@ -6,16 +6,19 @@ /*******************************************************************/ /* Data types for API */ +typedef struct dbTableHeader adb_header_t; + /* The main struct that stores the name of the database, and in future will hold all * kinds of other interesting information */ /* This basically gets passed around to all of the other functions */ + struct adb { - - char * dbname; - unsigned int ntracks; /* number of tracks */ - unsigned int datadim; /* dimensionality of stored data */ - + char *path; + int fd; + adb_header_t *header; }; +/* FIXME: it might be that "adb_" isn't such a good prefix to use, and + that we should prefer "audiodb_" */ typedef struct adb adb_t, *adb_ptr; //used for both insert and batchinsert