Mercurial > hg > audiodb
comparison audioDB.cpp @ 322:634959ef98f2 large_adb
Added --adb_root and --adb_feature_root support to server-side Web Services instance. Client does not have to know location of database and features on the server when server performs path substitutions with these arguments.
author | mas01mc |
---|---|
date | Thu, 21 Aug 2008 19:58:55 +0000 |
parents | da2272e029b3 |
children |
comparison
equal
deleted
inserted
replaced
321:da2272e029b3 | 322:634959ef98f2 |
---|---|
1 #include "audioDB.h" | 1 #include "audioDB.h" |
2 | 2 |
3 LSH* SERVER_LSH_INDEX_SINGLETON; | 3 LSH* SERVER_LSH_INDEX_SINGLETON; |
4 char* SERVER_ADB_ROOT; | |
5 char* SERVER_ADB_FEATURE_ROOT; | |
4 | 6 |
5 PointPair::PointPair(Uns32T a, Uns32T b, Uns32T c):trackID(a),qpos(b),spos(c){}; | 7 PointPair::PointPair(Uns32T a, Uns32T b, Uns32T c):trackID(a),qpos(b),spos(c){}; |
6 | 8 |
7 bool operator<(const PointPair& a, const PointPair& b){ | 9 bool operator<(const PointPair& a, const PointPair& b){ |
8 return ( (a.trackID<b.trackID) || | 10 return ( (a.trackID<b.trackID) || |
32 printf("%s\n", gengetopt_args_info_help[2]); | 34 printf("%s\n", gengetopt_args_info_help[2]); |
33 printf("%s\n", gengetopt_args_info_help[0]); | 35 printf("%s\n", gengetopt_args_info_help[0]); |
34 error("No command found"); | 36 error("No command found"); |
35 } | 37 } |
36 | 38 |
37 // perform dbName path prefix subbsitution | 39 // Perform database prefix substitution |
38 if(adb_root) | 40 if(adb_root) |
39 prefix_name((char** const)&dbName, adb_root); | 41 prefix_name((char** const)&dbName, adb_root); |
40 | 42 |
41 if(O2_ACTION(COM_SERVER)) | 43 if(O2_ACTION(COM_SERVER)) |
42 startServer(); | 44 startServer(); |
88 audioDB::audioDB(const unsigned argc, char* const argv[], adb__queryResponse *adbQueryResponse): O2_AUDIODB_INITIALIZERS | 90 audioDB::audioDB(const unsigned argc, char* const argv[], adb__queryResponse *adbQueryResponse): O2_AUDIODB_INITIALIZERS |
89 { | 91 { |
90 try { | 92 try { |
91 isServer = 1; // FIXME: Hack | 93 isServer = 1; // FIXME: Hack |
92 processArgs(argc, argv); | 94 processArgs(argc, argv); |
95 // Perform database prefix substitution | |
96 if(adb_root) | |
97 prefix_name((char** const)&dbName, adb_root); | |
93 assert(O2_ACTION(COM_QUERY)); | 98 assert(O2_ACTION(COM_QUERY)); |
94 query(dbName, inFile, adbQueryResponse); | 99 query(dbName, inFile, adbQueryResponse); |
95 } catch(char *err) { | 100 } catch(char *err) { |
96 cleanup(); | 101 cleanup(); |
97 throw(err); | 102 throw(err); |
101 audioDB::audioDB(const unsigned argc, char* const argv[], adb__statusResponse *adbStatusResponse): O2_AUDIODB_INITIALIZERS | 106 audioDB::audioDB(const unsigned argc, char* const argv[], adb__statusResponse *adbStatusResponse): O2_AUDIODB_INITIALIZERS |
102 { | 107 { |
103 try { | 108 try { |
104 isServer = 1; // FIXME: Hack | 109 isServer = 1; // FIXME: Hack |
105 processArgs(argc, argv); | 110 processArgs(argc, argv); |
111 // Perform database prefix substitution | |
112 if(adb_root) | |
113 prefix_name((char** const)&dbName, adb_root); | |
106 assert(O2_ACTION(COM_STATUS)); | 114 assert(O2_ACTION(COM_STATUS)); |
107 status(dbName, adbStatusResponse); | 115 status(dbName, adbStatusResponse); |
108 } catch(char *err) { | 116 } catch(char *err) { |
109 cleanup(); | 117 cleanup(); |
110 throw(err); | 118 throw(err); |
252 } | 260 } |
253 | 261 |
254 if (args_info.adb_feature_root_given){ | 262 if (args_info.adb_feature_root_given){ |
255 adb_feature_root = args_info.adb_feature_root_arg; | 263 adb_feature_root = args_info.adb_feature_root_arg; |
256 } | 264 } |
257 | 265 |
266 // perform dbName path prefix SERVER-side subsitution | |
267 if(SERVER_ADB_ROOT && !adb_root) | |
268 adb_root = SERVER_ADB_ROOT; | |
269 if(SERVER_ADB_FEATURE_ROOT && !adb_feature_root) | |
270 adb_feature_root = SERVER_ADB_FEATURE_ROOT; | |
271 | |
258 if(args_info.SERVER_given){ | 272 if(args_info.SERVER_given){ |
259 command=COM_SERVER; | 273 command=COM_SERVER; |
260 port=args_info.SERVER_arg; | 274 port=args_info.SERVER_arg; |
261 if(port<100 || port > 100000) | 275 if(port<100 || port > 100000) |
262 error("port out of range"); | 276 error("port out of range"); |
648 | 662 |
649 // This entry point is visited once per instance | 663 // This entry point is visited once per instance |
650 // so it is a good place to set any global state variables | 664 // so it is a good place to set any global state variables |
651 int main(const unsigned argc, char* const argv[]){ | 665 int main(const unsigned argc, char* const argv[]){ |
652 SERVER_LSH_INDEX_SINGLETON = 0; // Initialize global variables | 666 SERVER_LSH_INDEX_SINGLETON = 0; // Initialize global variables |
667 SERVER_ADB_ROOT = 0; // Server-side database root prefix | |
668 SERVER_ADB_FEATURE_ROOT = 0; // Server-side features root prefix | |
653 audioDB(argc, argv); | 669 audioDB(argc, argv); |
654 } | 670 } |