// file: $isip/class/algo/Output/out_03.cc // version: $Id: out_03.cc 9236 2003-06-23 18:12:22Z gao $ // // isip include files // #include "Output.h" //------------------------------------------------------------------ // these methods have to be in the same file so they can use the same // static parser pointer //------------------------------------------------------------------ // declare a static sof parser pointer // static SofParser* parser_d = (SofParser*)NULL; // method: setParser // // arguments: // SofParser* parser: (input) sof file object // // return: a bool8 value indicating status // // this method sets the parser from the parent object to be used in // the next readData method. // bool8 Output::setParser(SofParser* parser_a) { // set the parser // parser_d = parser_a; // exit gracefully // return true; } // method: read // // arguments: // Sof& sof: (input) sof file object // int32 tag: (input) sof object instance tag // const String& name: (input) sof object instance name // // return: a bool8 value indicating status // // this method has the object read itself from an Sof file according // to the specified name and tag // bool8 Output::read(Sof& sof_a, int32 tag_a, const String& name_a) { // read the instance of the object from the Sof file // if (!sof_a.find(name_a, tag_a)) { return false; } // read the actual data from the sof file // return readData(sof_a); } // method: readData // // arguments: // Sof& sof: (input) sof file object // const String& pname: (input) parameter name // int32 size: (input) size in bytes of object (or FULL_OBJECT) // bool8 param: (input) is the parameter name in the file? // bool8 nested: (input) are we nested? // // return: a bool8 value indicating status // // this method has the object read itself from an Sof file. it assumes // that the Sof file is already positioned correctly. // bool8 Output::readData(Sof& sof_a, const String& pname_a, int32 size_a, bool8 param_a, bool8 nested_a) { // declare local variables // bool8 status = true; // we need a parser // if (parser_d == (SofParser*)NULL) { parser_d = new SofParser; if (nested_a) { parser_d->setNest(); } // load the parse // if (!parser_d->load(sof_a, size_a)) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } } // set the debug level of the parser // parser_d->setDebug(debug_level_d.getIndex()); // get the algorithm name // if (parser_d->isPresent(sof_a, PARAM_ALGORITHM)) { if (!ALGO_MAP.readElementData((int32&)algorithm_d, sof_a, PARAM_ALGORITHM, parser_d->getEntry(sof_a, PARAM_ALGORITHM))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { algorithm_d = DEF_ALGORITHM; } // get the implementation // if (parser_d->isPresent(sof_a, PARAM_IMPLEMENTATION)) { if (!IMPL_MAP.readElementData((int32&)implementation_d, sof_a, PARAM_IMPLEMENTATION, parser_d->getEntry(sof_a, PARAM_IMPLEMENTATION))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { implementation_d = DEF_IMPLEMENTATION; } // read the file output directory // if (parser_d->isPresent(sof_a, CommandLine::DEF_PARAM_DIRECTORY)) { if (!output_directory_d.readData(sof_a, CommandLine::DEF_PARAM_DIRECTORY, parser_d->getEntry(sof_a, CommandLine::DEF_PARAM_DIRECTORY))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { output_directory_d.assign(Sdb::DEF_OUT_DIR); } // read the file output base name // if (parser_d->isPresent(sof_a, PARAM_BASENAME)) { if (!output_basename_d.readData(sof_a, PARAM_BASENAME, parser_d->getEntry(sof_a, PARAM_BASENAME))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { output_basename_d.assign(String::NULL_STRING); } // read the file name extension // if (parser_d->isPresent(sof_a, CommandLine::DEF_PARAM_EXTENSION)) { if (!output_extension_d.readData(sof_a, CommandLine::DEF_PARAM_EXTENSION, parser_d->getEntry(sof_a, CommandLine::DEF_PARAM_EXTENSION))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { output_extension_d.assign(Filename::DEF_EXTENSION); } // read the directory preserve level // if (parser_d->isPresent(sof_a, CommandLine::DEF_PARAM_PRESERVE)) { if (!output_preserve_d.readData(sof_a, CommandLine::DEF_PARAM_PRESERVE, parser_d->getEntry(sof_a, CommandLine::DEF_PARAM_PRESERVE))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { output_preserve_d = Filename::DEF_DIR_PRES; } // read the file name suffix // if (parser_d->isPresent(sof_a, CommandLine::DEF_PARAM_SUFFIX)) { if (!output_suffix_d.readData(sof_a, CommandLine::DEF_PARAM_SUFFIX, parser_d->getEntry(sof_a, CommandLine::DEF_PARAM_SUFFIX))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { output_suffix_d.assign(Filename::DEF_SUFFIX); } if (implementation_d == FEATURES) { if (parser_d->isPresent(sof_a, PARAM_FEATURE_OUTPUT)) { if (!feature_output_d.readData(sof_a, PARAM_FEATURE_OUTPUT, parser_d->getEntry(sof_a, PARAM_FEATURE_OUTPUT), true, true)) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { feature_output_d.clear(); // clear initializes to default } } // implementation is SAMPLED_DATA // else { // get the data mode // if (parser_d->isPresent(sof_a, PARAM_DMODE)) { if (!DMODE_MAP.readElementData((int32&)dmode_d, sof_a, PARAM_DMODE, parser_d->getEntry(sof_a, PARAM_DMODE))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { dmode_d = DEF_DMODE; } if (parser_d->isPresent(sof_a, PARAM_AUDIO_OUTPUT)) { if (!audio_output_d.readData(sof_a, PARAM_AUDIO_OUTPUT, parser_d->getEntry(sof_a, PARAM_AUDIO_OUTPUT), true, true)) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { audio_output_d.clear(); // clear initializes to default } } // get the debug level // if (parser_d->isPresent(sof_a, PARAM_DBGL)) { if (!debug_level_d.readData(sof_a, PARAM_DBGL, parser_d->getEntry(sof_a, PARAM_DBGL))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readData", Error::IO, __FILE__, __LINE__, Error::WARNING); } } else { debug_level_d = Integral::DEF_DEBUG; } // check known algorithms: DATA // if (algorithm_d == DATA) { status = readDataData(sof_a, pname_a, size_a, param_a, nested_a); } // check unsupported algorithms // else { return Error::handle(name(), L"readData", ERR_UNKALG, __FILE__, __LINE__); } // check that all parameters are accounted for // if (!parser_d->checkParams(sof_a)) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readData", Error::IO, __FILE__, __LINE__, Error::WARNING); } // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // exit gracefully // return status; } // method: readDataData // // arguments: // Sof& sof: (input) sof file object // const String& pname: (input) parameter name // int32 size: (input) size in bytes of object (or FULL_OBJECT) // bool8 param: (input) is the parameter name in the file? // bool8 nested: (input) are we nested? // // return: a bool8 value indicating status // // this method assumes the algorithm has been read, and proceeds to read // the rest of the object for the DATA algorithm. in this particular case, // there is nothing left to read. // bool8 Output::readDataData(Sof& sof_a, const String& pname_a, int32 size_a, bool8 param_a, bool8 nested_a) { // exit gracefully // return true; }