// file: $isip/class/sp/Component/cmp_03.cc // version: $Id: cmp_03.cc 8236 2002-06-26 19:06:05Z gao $ // // isip include files // #include "Component.h" // 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 Component::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 Component::readData(Sof& sof_a, const String& pname_a, int32 size_a, bool8 param_a, bool8 nested_a) { // we need a parser // SofParser parser; parser.setDebug(debug_level_d); // ignore implicit parameter setting // // are we nested? // if (nested_a) { parser.setNest(); } // load the parse // if (!parser.load(sof_a, size_a)) { return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } // the input and output names have to be specified // if (!(parser.isPresent(sof_a, PARAM_INPUT_NAMES) && parser.isPresent(sof_a, PARAM_OUTPUT_NAME))) { return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } // for text mode which parameter is specified means what mode to be // in. for binary the parameter is meaningless, so read the first // one and then the mode directly. // String str; if (!str.readData(sof_a, PARAM_INPUT_NAMES, parser.getEntry(sof_a, PARAM_INPUT_NAMES), false, false)) { return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } if (!setInputName(str)) { return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } // read the output name // if (!output_name_d.readData(sof_a, PARAM_OUTPUT_NAME, parser.getEntry(sof_a, PARAM_OUTPUT_NAME), false, false)) { return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } // the algorithm is optional, if not specified the Component will just // pass data straight through // if (parser.isPresent(sof_a, PARAM_COMPONENT)) { if (!algo_d.readData(sof_a, PARAM_COMPONENT, parser.getEntry(sof_a, PARAM_COMPONENT), false, true)) { return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { algo_d.clear(); } // check that all parameters are accounted for // if (!parser.checkParams(sof_a)) { // return a warning message // return Error::handle(name(), L"readData", Error::IO, __FILE__, __LINE__, Error::WARNING); } // exit gracefully // return true; }