00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 #if !defined(ALIZE_Config_cpp)
00056 #define ALIZE_Config_cpp
00057
00058 #include "Config.h"
00059 #include "FeatureFlags.h"
00060 #include "ConfigFileWriter.h"
00061 #include "ConfigFileReaderXml.h"
00062 #include "ConfigFileReaderRaw.h"
00063 #include "Exception.h"
00064
00065 using namespace alize;
00066
00067
00068 Config::Config()
00069 :Object() { reset(); }
00070
00071 Config::Config(const FileName& f)
00072 :Object() { load(f); }
00073
00074 Config::Config(const Config& c)
00075 :Object() { assign(c); }
00076
00077 const Config& Config::operator=(const Config& c)
00078 {
00079 assign(c);
00080 return *this;
00081 }
00082
00083 void Config::assign(const Config& c)
00084 {
00085 #define ASSIGN(x) x = c.x
00086 ASSIGN(_param_minCov);
00087 ASSIGN(_param_vectSize);
00088 ASSIGN(_param_loadFeatureFileMemAlloc);
00089 ASSIGN(_param_featureServerMemAlloc);
00090 ASSIGN(_param_computeLLKWithTopDistribs);
00091 ASSIGN(_param_debug);
00092 ASSIGN(_param_topDistribsCount);
00093 ASSIGN(_param_featureServerBufferSize);
00094 ASSIGN(_param_featureServerMask);
00095 ASSIGN(_param_featureFlags);
00096 ASSIGN(_param_mixtureDistribCount);
00097 ASSIGN(_param_loadFeatureFileFormat);
00098 ASSIGN(_param_loadFeatureFileVectSize);
00099 ASSIGN(_param_loadAudioFileChannel);
00100 ASSIGN(_param_loadMixtureFileFormat);
00101 ASSIGN(_param_loadSegServerFileFormat);
00102 ASSIGN(_param_saveMixtureFileFormat);
00103 ASSIGN(_param_saveMixtureServerFileFormat);
00104 ASSIGN(_param_saveSegServerFileFormat);
00105 ASSIGN(_param_saveFeatureFileFormat);
00106 ASSIGN(_param_saveFeatureFileSPro3DataKind);
00107 ASSIGN(_param_loadFeatureFileExtension);
00108 ASSIGN(_param_loadAudioFileExtension);
00109 ASSIGN(_param_loadFeatureFileBigEndian);
00110 ASSIGN(_param_loadAudioFileBigEndian);
00111 ASSIGN(_param_featureServerMode);
00112 ASSIGN(_param_loadMixtureFileBigEndian);
00113 ASSIGN(_param_loadMixtureFileExtension);
00114 ASSIGN(_param_loadSegServerFileExtension);
00115 ASSIGN(_param_saveMixtureFileExtension);
00116 ASSIGN(_param_saveMixtureServerFileExtension);
00117 ASSIGN(_param_saveSegServerFileExtension);
00118 ASSIGN(_param_saveFeatureFileExtension);
00119 ASSIGN(_param_distribType);
00120 ASSIGN(_param_mixtureFilesPath);
00121 ASSIGN(_param_featureFilesPath);
00122 ASSIGN(_param_audioFilesPath);
00123 ASSIGN(_param_segServerFilesPath);
00124 ASSIGN(_param_minLLK);
00125 ASSIGN(_param_maxLLK);
00126 ASSIGN(_param_bigEndian);
00127 ASSIGN(_param_sampleRate);
00128
00129 ASSIGN(existsParam_minCov);
00130 ASSIGN(existsParam_vectSize);
00131 ASSIGN(existsParam_loadFeatureFileMemAlloc);
00132 ASSIGN(existsParam_featureServerMemAlloc);
00133 ASSIGN(existsParam_computeLLKWithTopDistribs);
00134 ASSIGN(existsParam_debug);
00135 ASSIGN(existsParam_topDistribsCount);
00136 ASSIGN(existsParam_featureServerBufferSize);
00137 ASSIGN(existsParam_featureServerMask);
00138 ASSIGN(existsParam_loadFeatureFileFormat);
00139 ASSIGN(existsParam_loadFeatureFileVectSize);
00140 ASSIGN(existsParam_loadAudioFileChannel);
00141 ASSIGN(existsParam_loadMixtureFileFormat);
00142 ASSIGN(existsParam_loadSegServerFileFormat);
00143 ASSIGN(existsParam_saveMixtureFileFormat);
00144 ASSIGN(existsParam_saveMixtureServerFileFormat);
00145 ASSIGN(existsParam_saveSegServerFileFormat);
00146 ASSIGN(existsParam_saveFeatureFileFormat);
00147 ASSIGN(existsParam_saveFeatureFileSPro3DataKind);
00148 ASSIGN(existsParam_loadFeatureFileExtension);
00149 ASSIGN(existsParam_loadAudioFileExtension);
00150 ASSIGN(existsParam_loadFeatureFileBigEndian);
00151 ASSIGN(existsParam_loadAudioFileBigEndian);
00152 ASSIGN(existsParam_featureServerMode);
00153 ASSIGN(existsParam_loadMixtureFileBigEndian);
00154 ASSIGN(existsParam_loadMixtureFileExtension);
00155 ASSIGN(existsParam_loadSegServerFileExtension);
00156 ASSIGN(existsParam_saveMixtureFileExtension);
00157 ASSIGN(existsParam_saveMixtureServerFileExtension);
00158 ASSIGN(existsParam_saveSegServerFileExtension);
00159 ASSIGN(existsParam_saveFeatureFileExtension);
00160 ASSIGN(existsParam_featureFlags);
00161 ASSIGN(existsParam_mixtureDistribCount);
00162 ASSIGN(existsParam_minLLK);
00163 ASSIGN(existsParam_maxLLK);
00164 ASSIGN(existsParam_distribType);
00165 ASSIGN(existsParam_saveMixtureFileFormat);
00166 ASSIGN(existsParam_saveMixtureServerFileFormat);
00167 ASSIGN(existsParam_saveSegServerFileFormat);
00168 ASSIGN(existsParam_saveFeatureFileFormat);
00169 ASSIGN(existsParam_saveFeatureFileSPro3DataKind);
00170 ASSIGN(existsParam_bigEndian);
00171 ASSIGN(existsParam_sampleRate);
00172 ASSIGN(existsParam_featureFilesPath);
00173 ASSIGN(existsParam_audioFilesPath);
00174 ASSIGN(existsParam_segServerFilesPath);
00175 ASSIGN(existsParam_mixtureFilesPath);
00176 ASSIGN(_set);
00177 }
00178
00179 bool Config::operator==(const Config& c) const
00180 {
00181 unsigned long i;
00182 for (i=0; i<getParamCount(); i++)
00183 {
00184 const String& name = getParamName(i);
00185 if (!c.existsParam(name))
00186 return false;
00187 if (getParamContent(i) != c.getParam(name))
00188 return false;
00189 }
00190 for (i=0; i<c.getParamCount(); i++)
00191 {
00192 const String& name = c.getParamName(i);
00193 if (!existsParam(name))
00194 return false;
00195 if (c.getParamContent(i) != getParam(name))
00196 return false;
00197 }
00198 return true;
00199 }
00200
00201 bool Config::operator!=(const Config& c) const { return !(*this == c); }
00202
00203 void Config::reset()
00204 {
00205 existsParam_minCov = false;
00206 existsParam_vectSize = false;
00207 existsParam_loadFeatureFileMemAlloc = false;
00208 existsParam_featureServerMemAlloc = false;
00209 existsParam_topDistribsCount = false;
00210 existsParam_featureServerBufferSize = false;
00211 existsParam_featureServerMask = false;
00212 existsParam_featureFlags = false;
00213 existsParam_mixtureDistribCount = false;
00214 existsParam_minLLK = false;
00215 existsParam_maxLLK = false;
00216 existsParam_distribType = false;
00217 existsParam_saveMixtureFileFormat = false;
00218 existsParam_saveMixtureServerFileFormat = false;
00219 existsParam_saveSegServerFileFormat = false;
00220 existsParam_saveFeatureFileFormat = false;
00221 existsParam_saveFeatureFileSPro3DataKind = false;
00222 existsParam_loadFeatureFileFormat = false;
00223 existsParam_loadFeatureFileVectSize = false;
00224 existsParam_loadAudioFileChannel = false;
00225 existsParam_loadMixtureFileFormat = false;
00226 existsParam_loadSegServerFileFormat = false;
00227 existsParam_saveMixtureFileExtension = false;
00228 existsParam_saveMixtureServerFileExtension = false;
00229 existsParam_saveSegServerFileExtension = false;
00230 existsParam_saveFeatureFileExtension = false;
00231 existsParam_loadFeatureFileExtension = false;
00232 existsParam_loadAudioFileExtension = false;
00233 existsParam_loadFeatureFileBigEndian = false;
00234 existsParam_loadAudioFileBigEndian = false;
00235 existsParam_featureServerMode = false;
00236 existsParam_loadMixtureFileBigEndian = false;
00237 existsParam_loadMixtureFileExtension = false;
00238 existsParam_loadSegServerFileExtension = false;
00239 existsParam_bigEndian = false;
00240 existsParam_sampleRate = false;
00241 existsParam_mixtureFilesPath = false;
00242 existsParam_featureFilesPath = false;
00243 existsParam_audioFilesPath = false;
00244 existsParam_segServerFilesPath = false;
00245 _set.reset();
00246 setParam("debug", "false");
00247 }
00248
00249 void Config::load(const FileName& f)
00250 {
00251 if (f.endsWith(".xml"))
00252 ConfigFileReaderXml(f).readConfig(*this);
00253 else
00254 ConfigFileReaderRaw(f).readConfig(*this);
00255
00256 }
00257
00258 void Config::save(const FileName& f) const
00259 { ConfigFileWriter(f).writeConfig(*this); }
00260
00261 unsigned long Config::getParamCount() const { return _set.getLineCount(); }
00262
00263 const String& Config::getParamName(unsigned long i) const
00264 { return _set.getLine(i).getElement(0); }
00265
00266 const String& Config::getParamContent(unsigned long i) const
00267 { return _set.getLine(i).getElement(1); }
00268
00269 const String& Config::getParam(const String& name) const
00270 {
00271 XLine* p =_set.findLine(name);
00272 if (p == NULL)
00273 throw ParamNotFoundInConfigException(name, __FILE__, __LINE__);
00274 return p->getElement(1);
00275 }
00276
00277 long Config::getIntegerParam(const String& name) const
00278 { return getParam(name).toLong(); }
00279
00280 double Config::getFloatParam(const String& name) const
00281 { return getParam(name).toDouble(); }
00282
00283 bool Config::getBooleanParam(const String& name) const
00284 {
00285 const String& s = getParam(name);
00286 if (s == "")
00287 return true;
00288 return s.toBool();
00289 }
00290
00291 bool Config::existsParam(const String& name) const
00292 { return _set.findLine(name) != NULL; }
00293
00294 real_t Config::getParam_minCov() const
00295 {
00296 if (!existsParam_minCov)
00297 throw ParamNotFoundInConfigException("minCov", __FILE__, __LINE__);
00298 return _param_minCov;
00299 }
00300
00301 unsigned long Config::getParam_vectSize() const
00302 {
00303 if (!existsParam_vectSize)
00304 throw ParamNotFoundInConfigException("vectSize", __FILE__, __LINE__);
00305 return _param_vectSize;
00306 }
00307
00308 unsigned long Config::getParam_loadFeatureFileMemAlloc() const
00309 {
00310 if (!existsParam_loadFeatureFileMemAlloc)
00311 throw ParamNotFoundInConfigException("loadFeatureFileMemAlloc' in the config",
00312 __FILE__, __LINE__);
00313 return _param_loadFeatureFileMemAlloc;
00314 }
00315
00316 unsigned long Config::getParam_featureServerMemAlloc() const
00317 {
00318 if (!existsParam_featureServerMemAlloc)
00319 throw ParamNotFoundInConfigException("featureServerMemAlloc' in the config",
00320 __FILE__, __LINE__);
00321 return _param_featureServerMemAlloc;
00322 }
00323
00324 bool Config::getParam_computeLLKWithTopDistribs() const
00325 {
00326 if (!existsParam_computeLLKWithTopDistribs)
00327 throw ParamNotFoundInConfigException("computeLLKWithTopDistribs' in the config",
00328 __FILE__, __LINE__);
00329 return _param_computeLLKWithTopDistribs;
00330 }
00331
00332 bool Config::getParam_debug() const { return _param_debug; }
00333
00334 unsigned long Config::getParam_topDistribsCount() const
00335 {
00336 if (!existsParam_topDistribsCount)
00337 throw ParamNotFoundInConfigException("topDistribsCount' in the config", __FILE__,
00338 __LINE__);
00339 return _param_topDistribsCount;
00340 }
00341
00342 const String& Config::getParam_featureServerBufferSize() const
00343 {
00344 if (!existsParam_featureServerBufferSize)
00345 throw ParamNotFoundInConfigException("featureServerBufferSize' in the config",
00346 __FILE__, __LINE__);
00347 return _param_featureServerBufferSize;
00348 }
00349
00350 const String& Config::getParam_featureServerMask() const
00351 {
00352 if (!existsParam_featureServerMask)
00353 throw ParamNotFoundInConfigException("featureServermask' in the config",
00354 __FILE__, __LINE__);
00355 return _param_featureServerMask;
00356 }
00357
00358 const FeatureFlags& Config::getParam_featureFlags() const
00359 {
00360 if (!existsParam_featureFlags)
00361 throw ParamNotFoundInConfigException("featureFlags' in the config", __FILE__,
00362 __LINE__);
00363 return _param_featureFlags;
00364 }
00365
00366 unsigned long Config::getParam_mixtureDistribCount() const
00367 {
00368 if (!existsParam_mixtureDistribCount)
00369 throw ParamNotFoundInConfigException("mixtureDistribCount' in the config",
00370 __FILE__, __LINE__);
00371 return _param_mixtureDistribCount;
00372 }
00373
00374 lk_t Config::getParam_minLLK() const
00375 {
00376 if (!existsParam_minLLK)
00377 throw ParamNotFoundInConfigException("minLLK", __FILE__, __LINE__);
00378 return _param_minLLK;
00379 }
00380
00381 lk_t Config::getParam_maxLLK() const
00382 {
00383 if (!existsParam_maxLLK)
00384 throw ParamNotFoundInConfigException("maxLLK' in the config", __FILE__,__LINE__);
00385 return _param_maxLLK;
00386 }
00387
00388 DistribType Config::getParam_distribType() const
00389 {
00390 if (!existsParam_distribType)
00391 throw ParamNotFoundInConfigException("distribType' in the config",
00392 __FILE__, __LINE__);
00393 return _param_distribType;
00394 }
00395
00396 MixtureFileWriterFormat Config::getParam_saveMixtureFileFormat() const
00397 {
00398 if (!existsParam_saveMixtureFileFormat)
00399 throw ParamNotFoundInConfigException("saveMixtureFileFormat' in the config",
00400 __FILE__, __LINE__);
00401 return _param_saveMixtureFileFormat;
00402 }
00403
00404 MixtureServerFileWriterFormat Config::getParam_saveMixtureServerFileFormat() const
00405 {
00406 if (!existsParam_saveMixtureServerFileFormat)
00407 throw ParamNotFoundInConfigException("saveMixtureServerFileFormat' in the config",
00408 __FILE__, __LINE__);
00409 return _param_saveMixtureServerFileFormat;
00410 }
00411
00412 SegServerFileWriterFormat Config::getParam_saveSegServerFileFormat() const
00413 {
00414 if (!existsParam_saveSegServerFileFormat)
00415 throw ParamNotFoundInConfigException("saveSegServerFileFormat' in the config",
00416 __FILE__, __LINE__);
00417 return _param_saveSegServerFileFormat;
00418 }
00419
00420 FeatureFileWriterFormat Config::getParam_saveFeatureFileFormat() const
00421 {
00422 if (!existsParam_saveFeatureFileFormat)
00423 throw ParamNotFoundInConfigException("saveFeatureFileFormat' in the config",
00424 __FILE__, __LINE__);
00425 return _param_saveFeatureFileFormat;
00426 }
00427
00428 SPRO3DataKind Config::getParam_saveFeatureFileSPro3DataKind() const
00429 {
00430 if (!existsParam_saveFeatureFileSPro3DataKind)
00431 throw ParamNotFoundInConfigException("saveFeatureFileSPro3DataKind' in the config",
00432 __FILE__, __LINE__);
00433 return _param_saveFeatureFileSPro3DataKind;
00434 }
00435
00436 FeatureFileReaderFormat Config::getParam_loadFeatureFileFormat() const
00437 {
00438 if (!existsParam_loadFeatureFileFormat)
00439 throw ParamNotFoundInConfigException("loadFeatureFileFormat' in the config",
00440 __FILE__, __LINE__);
00441 return _param_loadFeatureFileFormat;
00442 }
00443
00444 unsigned long Config::getParam_loadFeatureFileVectSize() const
00445 {
00446 if (!existsParam_loadFeatureFileVectSize)
00447 throw ParamNotFoundInConfigException("loadFeatureFileVectSize' in the config",
00448 __FILE__, __LINE__);
00449 return _param_loadFeatureFileVectSize;
00450 }
00451
00452 unsigned long Config::getParam_loadAudioFileChannel() const
00453 {
00454 if (!existsParam_loadAudioFileChannel)
00455 throw ParamNotFoundInConfigException("loadAudioFileChannel' in the config",
00456 __FILE__, __LINE__);
00457 return _param_loadAudioFileChannel;
00458 }
00459
00460 MixtureFileReaderFormat Config::getParam_loadMixtureFileFormat() const
00461 {
00462 if (!existsParam_loadMixtureFileFormat)
00463 throw ParamNotFoundInConfigException("loadMixtureFileFormat' in the config",
00464 __FILE__, __LINE__);
00465 return _param_loadMixtureFileFormat;
00466 }
00467
00468 SegServerFileReaderFormat Config::getParam_loadSegServerFileFormat() const
00469 {
00470 if (!existsParam_loadSegServerFileFormat)
00471 throw ParamNotFoundInConfigException("loadSegServerFileFormat' in the config",
00472 __FILE__, __LINE__);
00473 return _param_loadSegServerFileFormat;
00474 }
00475
00476 const String& Config::getParam_saveMixtureFileExtension() const
00477 {
00478 if (!existsParam_saveMixtureFileExtension)
00479 throw ParamNotFoundInConfigException("saveMixtureFileExtension' in the config",
00480 __FILE__, __LINE__);
00481 return _param_saveMixtureFileExtension;
00482 }
00483
00484 const String& Config::getParam_saveMixtureServerFileExtension() const
00485 {
00486 if (!existsParam_saveMixtureServerFileExtension)
00487 throw ParamNotFoundInConfigException("saveMixtureServerFileExtension' in the config",
00488 __FILE__, __LINE__);
00489 return _param_saveMixtureServerFileExtension;
00490 }
00491
00492 const String& Config::getParam_saveSegServerFileExtension() const
00493 {
00494 if (!existsParam_saveSegServerFileExtension)
00495 throw ParamNotFoundInConfigException("saveSegServerFileExtension' in the config",
00496 __FILE__, __LINE__);
00497 return _param_saveSegServerFileExtension;
00498 }
00499
00500 const String& Config::getParam_saveFeatureFileExtension() const
00501 {
00502 if (!existsParam_saveFeatureFileExtension)
00503 throw ParamNotFoundInConfigException("saveFeatureFileExtension' in the config",
00504 __FILE__, __LINE__);
00505 return _param_saveFeatureFileExtension;
00506 }
00507
00508 const String& Config::getParam_loadFeatureFileExtension() const
00509 {
00510 if (!existsParam_loadFeatureFileExtension)
00511 throw ParamNotFoundInConfigException("loadFeatureFileExtension' in the config",
00512 __FILE__, __LINE__);
00513 return _param_loadFeatureFileExtension;
00514 }
00515
00516 const String& Config::getParam_loadAudioFileExtension() const
00517 {
00518 if (!existsParam_loadAudioFileExtension)
00519 throw ParamNotFoundInConfigException("loadAudioFileExtension' in the config",
00520 __FILE__, __LINE__);
00521 return _param_loadAudioFileExtension;
00522 }
00523
00524 bool Config::getParam_loadFeatureFileBigEndian() const
00525 {
00526 if (!existsParam_loadFeatureFileBigEndian)
00527 throw ParamNotFoundInConfigException("loadFeatureFileBigEndian' in the config",
00528 __FILE__, __LINE__);
00529 return _param_loadFeatureFileBigEndian;
00530 }
00531
00532 bool Config::getParam_loadAudioFileBigEndian() const
00533 {
00534 if (!existsParam_loadAudioFileBigEndian)
00535 throw ParamNotFoundInConfigException("loadAudioFileBigEndian' in the config",
00536 __FILE__, __LINE__);
00537 return _param_loadAudioFileBigEndian;
00538 }
00539
00540 const String& Config::getParam_featureServerMode() const
00541 {
00542 if (!existsParam_featureServerMode)
00543 throw ParamNotFoundInConfigException("featureServerMode' in the config",
00544 __FILE__, __LINE__);
00545 return _param_featureServerMode;
00546 }
00547
00548 bool Config::getParam_loadMixtureFileBigEndian() const
00549 {
00550 if (!existsParam_loadMixtureFileBigEndian)
00551 throw ParamNotFoundInConfigException("loadMixtureFileBigEndian' in the config",
00552 __FILE__, __LINE__);
00553 return _param_loadMixtureFileBigEndian;
00554 }
00555
00556 const String& Config::getParam_loadMixtureFileExtension() const
00557 {
00558 if (!existsParam_loadMixtureFileExtension)
00559 throw ParamNotFoundInConfigException("loadMixtureFileExtension' in the config",
00560 __FILE__, __LINE__);
00561 return _param_loadMixtureFileExtension;
00562 }
00563
00564 const String& Config::getParam_loadSegServerFileExtension() const
00565 {
00566 if (!existsParam_loadSegServerFileExtension)
00567 throw ParamNotFoundInConfigException("loadSegServerFileExtension' in the config",
00568 __FILE__, __LINE__);
00569 return _param_loadSegServerFileExtension;
00570 }
00571
00572 const String& Config::getParam_featureFilesPath() const
00573 {
00574 if (!existsParam_featureFilesPath)
00575 throw ParamNotFoundInConfigException("featureFilesPath' in the config",
00576 __FILE__, __LINE__);
00577 return _param_featureFilesPath;
00578 }
00579
00580 const String& Config::getParam_audioFilesPath() const
00581 {
00582 if (!existsParam_audioFilesPath)
00583 throw ParamNotFoundInConfigException("audioFilesPath' in the config",
00584 __FILE__, __LINE__);
00585 return _param_audioFilesPath;
00586 }
00587
00588 const String& Config::getParam_segServerFilesPath() const
00589 {
00590 if (!existsParam_segServerFilesPath)
00591 throw ParamNotFoundInConfigException("segServerFilesPath' in the config",
00592 __FILE__, __LINE__);
00593 return _param_segServerFilesPath;
00594 }
00595
00596 const String& Config::getParam_mixtureFilesPath() const
00597 {
00598 if (!existsParam_mixtureFilesPath)
00599 throw ParamNotFoundInConfigException("mixtureFilesPath' in the config",
00600 __FILE__, __LINE__);
00601 return _param_mixtureFilesPath;
00602 }
00603
00604 bool Config::getParam_bigEndian() const
00605 {
00606 if (!existsParam_bigEndian)
00607 throw ParamNotFoundInConfigException("bigEndian' in the config",
00608 __FILE__, __LINE__);
00609 return _param_bigEndian;
00610 }
00611
00612 real_t Config::getParam_sampleRate() const
00613 {
00614 if (!existsParam_sampleRate)
00615 throw ParamNotFoundInConfigException("sampleRate' in the config",
00616 __FILE__, __LINE__);
00617 return _param_sampleRate;
00618 }
00619
00620 void Config::setParam(const String& name, const String& content)
00621 {
00622 if (name == "minCov")
00623 {
00624 _param_minCov = content.toDouble();
00625 if (_param_minCov <= 0.0)
00626 throw Exception("parameter '"+name+"' cannot be <= 0.0",
00627 __FILE__, __LINE__);
00628 existsParam_minCov = true;
00629 }
00630 else if (name == "vectSize")
00631 {
00632 _param_vectSize = content.toULong();
00633 if (_param_vectSize == 0)
00634 throw Exception("parameter '"+name+"' cannot be 0",
00635 __FILE__, __LINE__);
00636 existsParam_vectSize = true;
00637 }
00638 else if (name == "loadFeatureFileMemAlloc")
00639 {
00640 _param_loadFeatureFileMemAlloc = content.toULong();
00641 existsParam_loadFeatureFileMemAlloc = true;
00642 }
00643 else if (name == "featureServerMemAlloc")
00644 {
00645 _param_featureServerMemAlloc = content.toULong();
00646 existsParam_featureServerMemAlloc = true;
00647 }
00648 else if (name == "computeLLKWithTopDistribs")
00649 {
00650 if (content == "COMPLETE")
00651 _param_computeLLKWithTopDistribs = true;
00652 else if (content == "PARTIAL")
00653 _param_computeLLKWithTopDistribs = false;
00654 else
00655 throw Exception(
00656 "parameter '"+name+"' must be 'COMPLETE' or 'PARTIAL'",
00657 __FILE__, __LINE__);
00658 existsParam_computeLLKWithTopDistribs = true;
00659 }
00660 else if (name == "topDistribsCount")
00661 {
00662 _param_topDistribsCount = content.toULong();
00663 if (_param_topDistribsCount == 0)
00664 throw Exception("parameter '"+name+"' cannot be 0",
00665 __FILE__, __LINE__);
00666 existsParam_topDistribsCount = true;
00667 }
00668 else if (name == "featureServerBufferSize")
00669 {
00670 if (content != "ALL_FEATURES")
00671 {
00672 if (content.isEmpty())
00673 throw Exception("parameter '"+name+"' cannot be empty",
00674 __FILE__, __LINE__);
00675 for (unsigned long i=0; i<content.length(); i++)
00676 {
00677 if (content[i]<"0" || content[i]>"9")
00678 throw Exception("parameter '"+name+"' cannot be empty",
00679 __FILE__, __LINE__);
00680 }
00681 }
00682 _param_featureServerBufferSize = content;
00683 existsParam_featureServerBufferSize = true;
00684 }
00685 else if (name == "featureServerMask")
00686 {
00687 _param_featureServerMask = content;
00688 existsParam_featureServerMask = true;
00689 }
00690 else if (name == "featureFlags")
00691 {
00692 _param_featureFlags.set(content);
00693 existsParam_featureFlags = true;
00694 }
00695 else if (name == "mixtureDistribCount")
00696 {
00697 _param_mixtureDistribCount = content.toULong();
00698 existsParam_mixtureDistribCount = true;
00699 }
00700 else if (name == "minLLK")
00701 {
00702 _param_minLLK = content.toDouble();
00703 existsParam_minLLK = true;
00704 }
00705 else if (name == "maxLLK")
00706 {
00707 _param_maxLLK = content.toDouble();
00708 existsParam_maxLLK = true;
00709 }
00710 else if (name == "distribType")
00711 {
00712 _param_distribType = getDistribType(content);
00713 existsParam_distribType = true;
00714 }
00715 else if (name == "bigEndian")
00716 {
00717 _param_bigEndian = content.toBool();
00718 existsParam_bigEndian = true;
00719 }
00720 else if (name == "sampleRate")
00721 {
00722 _param_sampleRate = content.toDouble();
00723 existsParam_sampleRate = true;
00724 }
00725 else if (name == "saveMixtureFileFormat")
00726 {
00727 _param_saveMixtureFileFormat = getMixtureFileWriterFormat(content);
00728 existsParam_saveMixtureFileFormat = true;
00729 }
00730 else if (name == "saveMixtureServerFileFormat")
00731 {
00732 _param_saveMixtureServerFileFormat = getMixtureServerFileWriterFormat(content);
00733 existsParam_saveMixtureServerFileFormat = true;
00734 }
00735 else if (name == "saveSegServerFileFormat")
00736 {
00737 _param_saveSegServerFileFormat = getSegServerFileWriterFormat(content);
00738 existsParam_saveSegServerFileFormat = true;
00739 }
00740 else if (name == "saveFeatureFileFormat")
00741 {
00742 _param_saveFeatureFileFormat = getFeatureFileWriterFormat(content);
00743 existsParam_saveFeatureFileFormat = true;
00744 }
00745 else if (name == "saveFeatureFileSPro3DataKind")
00746 {
00747 _param_saveFeatureFileSPro3DataKind = getSPro3DataKind(content);
00748 existsParam_saveFeatureFileSPro3DataKind = true;
00749 }
00750 else if (name == "loadFeatureFileFormat")
00751 {
00752 _param_loadFeatureFileFormat
00753 = getFeatureFileReaderFormat(content);
00754 existsParam_loadFeatureFileFormat = true;
00755 }
00756 else if (name == "loadFeatureFileVectSize")
00757 {
00758 _param_loadFeatureFileVectSize = content.toULong();
00759 existsParam_loadFeatureFileVectSize = true;
00760 }
00761 else if (name == "loadAudioFileChannel")
00762 {
00763 _param_loadAudioFileChannel
00764 = content.toULong();
00765 existsParam_loadAudioFileChannel = true;
00766 }
00767 else if (name == "loadMixtureFileFormat")
00768 {
00769 _param_loadMixtureFileFormat = getMixtureFileReaderFormat(content);
00770 existsParam_loadMixtureFileFormat = true;
00771 }
00772 else if (name == "loadSegServerFileFormat")
00773 {
00774 _param_loadSegServerFileFormat = getSegServerFileReaderFormat(content);
00775 existsParam_loadSegServerFileFormat = true;
00776 }
00777 else if (name == "saveMixtureFileExtension")
00778 {
00779 _param_saveMixtureFileExtension = content;
00780 existsParam_saveMixtureFileExtension = true;
00781 }
00782 else if (name == "saveMixtureServerFileExtension")
00783 {
00784 _param_saveMixtureServerFileExtension = content;
00785 existsParam_saveMixtureServerFileExtension = true;
00786 }
00787 else if (name == "saveSegServerFileExtension")
00788 {
00789 _param_saveSegServerFileExtension = content;
00790 existsParam_saveSegServerFileExtension = true;
00791 }
00792 else if (name == "saveFeatureFileExtension")
00793 {
00794 _param_saveFeatureFileExtension = content;
00795 existsParam_saveFeatureFileExtension = true;
00796 }
00797 else if (name == "loadFeatureFileExtension")
00798 {
00799 _param_loadFeatureFileExtension = content;
00800 existsParam_loadFeatureFileExtension = true;
00801 }
00802 else if (name == "loadAudioFileExtension")
00803 {
00804 _param_loadAudioFileExtension = content;
00805 existsParam_loadAudioFileExtension = true;
00806 }
00807 else if (name == "loadFeatureFileBigEndian")
00808 {
00809 _param_loadFeatureFileBigEndian = content.toBool();
00810 existsParam_loadFeatureFileBigEndian = true;
00811 }
00812 else if (name == "loadAudioFileBigEndian")
00813 {
00814 _param_loadAudioFileBigEndian = content.toBool();
00815 existsParam_loadAudioFileBigEndian = true;
00816 }
00817 else if (name == "featureServerMode")
00818 {
00819 if (content != "FEATURE_UNWRITABLE" &&
00820 content != "FEATURE_WRITABLE")
00821 throw Exception("parameter '"+name+
00822 "' must be 'FEATURE_UNWRITABLE' or 'FEATURE_WRITABLE'",
00823 __FILE__, __LINE__);
00824 _param_featureServerMode = content;
00825 existsParam_featureServerMode = true;
00826 }
00827 else if (name == "loadMixtureFileBigEndian")
00828 {
00829 _param_loadMixtureFileBigEndian = content.toBool();
00830 existsParam_loadMixtureFileBigEndian = true;
00831 }
00832 else if (name == "loadMixtureFileExtension")
00833 {
00834 _param_loadMixtureFileExtension = content;
00835 existsParam_loadMixtureFileExtension = true;
00836 }
00837 else if (name == "loadSegServerFileExtension")
00838 {
00839 _param_loadSegServerFileExtension = content;
00840 existsParam_loadSegServerFileExtension = true;
00841 }
00842 else if (name == "mixtureFilesPath")
00843 {
00844 _param_mixtureFilesPath = content;
00845 existsParam_mixtureFilesPath = true;
00846 }
00847 else if (name == "featureFilesPath")
00848 {
00849 _param_featureFilesPath = content;
00850 existsParam_featureFilesPath = true;
00851 }
00852 else if (name == "audioFilesPath")
00853 {
00854 _param_audioFilesPath = content;
00855 existsParam_audioFilesPath = true;
00856 }
00857 else if (name == "segServerFilesPath")
00858 {
00859 _param_segServerFilesPath = content;
00860 existsParam_segServerFilesPath = true;
00861 }
00862 else if (name == "debug")
00863 {
00864 if (content.getToken(0).isEmpty())
00865 _param_debug = true;
00866 else
00867 _param_debug = content.toBool();
00868 existsParam_debug = true;
00869 }
00870
00871 _set.rewind();
00872 XLine* p;
00873 while( (p=_set.getLine()) != NULL && p->getElement(0) != name)
00874 ;
00875 if (p == NULL)
00876 _set.addLine().addElement(name).addElement(content);
00877 else
00878 p->getElement(1) = content;
00879 }
00880
00881 void Config::setParam(const Config& c)
00882 {
00883 for (int i = c._set.getLineCount()-1; i>=0; i--)
00884 setParam(c.getParamName(i), c.getParamContent(i));
00885 }
00886
00887 String Config::getClassName() const { return "Config"; }
00888
00889 String Config::toString() const
00890 {
00891 String s = Object::toString();
00892 _set.rewind();
00893 XLine* p;
00894 while( (p = _set.getLine()) != NULL)
00895 s += "\n <" + p->getElement(0) + "> = " + p->getElement(1);
00896 return s;
00897 }
00898
00899 Config::~Config() {}
00900
00901
00902 #endif // !defined(ALIZE_Config_cpp)