changeset 171:bb934f91d85c powertable

Web services interface to the powertable functionality. * Implemented as a completely new SOAP method, called sequenceQuery * lightly tested with http://doc.gold.ac.uk/~mas01cr/poweradb.php (lacuna: need to pass relative-threshold and absolute-threshold always, even when they don't make sense.) Several uglinesses in the code, some of which will be resolved once all the various branches are merged into the trunk.
author mas01cr
date Wed, 14 Nov 2007 14:00:53 +0000
parents 9dbff8fea81d
children
files audioDB.cpp audioDB.h audioDBws.h
diffstat 3 files changed, 87 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/audioDB.cpp	Thu Nov 01 17:18:45 2007 +0000
+++ b/audioDB.cpp	Wed Nov 14 14:00:53 2007 +0000
@@ -2783,7 +2783,73 @@
   }
 }
 
+int adb__sequenceQuery(struct soap* soap, xsd__string dbName, xsd__string qKey,
+		       adb__sequenceQueryParms *parms,
+		       adb__queryResponse &adbQueryResponse) {
+
+  char qPosStr[256];
+  char pointNNStr[256];
+  char trackNNStr[256];
+  char seqLenStr[256];
+  char relative_thresholdStr[256];
+  char absolute_thresholdStr[256];
+
+  /* When the branch is merged, move this to a header and use it
+     elsewhere */
+#define INTSTRINGIFY(val, str) \
+  snprintf(str, 256, "%d", val);
+#define DOUBLESTRINGIFY(val, str) \
+  snprintf(str, 256, "%f", val);
+
+  INTSTRINGIFY(parms->qPos, qPosStr);
+  INTSTRINGIFY(parms->pointNN, pointNNStr);
+  INTSTRINGIFY(parms->segNN, trackNNStr);
+  /* FIXME: decide which of segLen and seqLen should live */
+  INTSTRINGIFY(parms->segLen, seqLenStr);
+
+  DOUBLESTRINGIFY(parms->relative_threshold, relative_thresholdStr);
+  DOUBLESTRINGIFY(parms->absolute_threshold, absolute_thresholdStr);
+  
+  const char *argv[] = {
+    "./audioDB",
+    COM_QUERY,
+    "sequence",
+    COM_DATABASE,
+    dbName, 
+    COM_FEATURES,
+    qKey,
+    COM_KEYLIST,
+    /* FIXME: when this branch is merged, use ENSURE_STRING */
+    parms->keyList==0?"":parms->keyList,
+    COM_TIMES,
+    parms->timesFileName==0?"":parms->timesFileName,
+    COM_QUERYPOWER,
+    parms->powerFileName==0?"":parms->powerFileName,
+    COM_QPOINT, 
+    qPosStr,
+    COM_POINTNN,
+    pointNNStr,
+    COM_TRACKNN,
+    trackNNStr,
+    COM_SEQLEN,
+    seqLenStr,
+    COM_RELATIVE_THRESH,
+    relative_thresholdStr,
+    COM_ABSOLUTE_THRESH,
+    absolute_thresholdStr
+  };
+
+  const unsigned argc = 25;
+
+  try {
+    audioDB(argc, (char* const*)argv, &adbQueryResponse);
+    return SOAP_OK;
+  } catch (char *err) {
+    soap_receiver_fault(soap, err, "");
+    return SOAP_FAULT;
+  }
+}
+
 int main(const unsigned argc, char* const argv[]){
   audioDB(argc, argv);
 }
-
--- a/audioDB.h	Thu Nov 01 17:18:45 2007 +0000
+++ b/audioDB.h	Wed Nov 14 14:00:53 2007 +0000
@@ -44,6 +44,9 @@
 #define COM_QUERYKEY "--key"
 #define COM_KEYLIST "--keyList"
 #define COM_TIMES "--times"
+#define COM_QUERYPOWER "--power"
+#define COM_RELATIVE_THRESH "--relative-threshold"
+#define COM_ABSOLUTE_THRESH "--absolute-threshold"
 
 #define O2_OLD_MAGIC ('O'|'2'<<8|'D'<<16|'B'<<24)
 #define O2_MAGIC ('o'|'2'<<8|'d'<<16|'b'<<24)
--- a/audioDBws.h	Thu Nov 01 17:18:45 2007 +0000
+++ b/audioDBws.h	Wed Nov 14 14:00:53 2007 +0000
@@ -45,3 +45,20 @@
 
 // Query an existing adb database
 int adb__query(xsd__string dbName, xsd__string qKey, xsd__string keyList, xsd__string timesFileName, xsd__int qType, xsd__int qPos, xsd__int pointNN, xsd__int segNN, xsd__int segLen, struct adb__queryResponse &adbQueryResponse);
+
+struct adb__sequenceQueryParms {
+  xsd__string keyList;
+  xsd__string timesFileName;
+  xsd__string powerFileName;
+  xsd__int qPos;
+  xsd__int pointNN;
+  xsd__int segNN;
+  xsd__int segLen;
+  xsd__double relative_threshold;
+  xsd__double absolute_threshold;
+};
+
+// Perform a sequence query
+int adb__sequenceQuery(xsd__string dbName, xsd__string qKey, 
+		       struct adb__sequenceQueryParms *parms, 
+		       struct adb__queryResponse &adbQueryResponse);