// file: $isip_ifc/class/algo/Lyapunov/lyap_03.cc // version: $Id: lyap_03.cc 10485 2006-03-15 17:22:34Z srinivas $ // // isip include files // #include "Lyapunov.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 Lyapunov::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 Lyapunov::read(Sof& sof_a, int32 tag_a, const String& name_a) { // get 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 // 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 Lyapunov::readData(Sof& sof_a, const String& pname_a, int32 size_a, bool8 param_a, bool8 nested_a) { // 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 algorithm // 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; } // check known algorithms: LINEAR_TANGENT_MAP // if (algorithm_d == LINEAR_TANGENT_MAP) { return readDataCommon(sof_a, pname_a, param_a, nested_a); } // exit ungracefully // else { return Error::handle(name(), L"readData", ERR_UNKALG, __FILE__, __LINE__); } } // method: readDataCommon // // 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 based on the value of the algorithm // bool8 Lyapunov::readDataCommon(Sof& sof_a, const String& pname_a, int32 size_a, bool8 param_a, bool8 nested_a) { // 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"readDataCommon", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { implementation_d = DEF_IMPLEMENTATION; } // get the number of neighbors // if (parser_d->isPresent(sof_a, PARAM_NUM_NEIGHBORS)) { if (!num_neighbors_d.readData(sof_a, PARAM_NUM_NEIGHBORS, parser_d->getEntry(sof_a, PARAM_NUM_NEIGHBORS))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readDataCommon", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { num_neighbors_d = DEF_NUM_NEIGHBORS; } // get the evolve step // if (parser_d->isPresent(sof_a, PARAM_EVOLVE_STEP)) { if (!evolve_step_d.readData(sof_a, PARAM_EVOLVE_STEP, parser_d->getEntry(sof_a, PARAM_EVOLVE_STEP))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readDataCommon", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { evolve_step_d = DEF_EVOLVE_STEP; } // get the local dimension // if (parser_d->isPresent(sof_a, PARAM_LOCAL_DIM)) { if (!local_dim_d.readData(sof_a, PARAM_LOCAL_DIM, parser_d->getEntry(sof_a, PARAM_LOCAL_DIM))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readDataCommon", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { local_dim_d = DEF_LOCAL_DIM; } // get the number of evolution steps // if (parser_d->isPresent(sof_a, PARAM_NUM_STEPS)) { if (!num_steps_d.readData(sof_a, PARAM_NUM_STEPS, parser_d->getEntry(sof_a, PARAM_NUM_STEPS))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readDataCommon", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { num_steps_d = DEF_NUM_STEPS; } // get the inner radius of neighborhood // if (parser_d->isPresent(sof_a, PARAM_INNER_RADIUS)) { if (!inner_radius_d.readData(sof_a, PARAM_INNER_RADIUS, parser_d->getEntry(sof_a, PARAM_INNER_RADIUS))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readDataCommon", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { inner_radius_d = DEF_INNER_RADIUS; } // get the outer radius of neighborhood // if (parser_d->isPresent(sof_a, PARAM_OUTER_RADIUS)) { if (!outer_radius_d.readData(sof_a, PARAM_OUTER_RADIUS, parser_d->getEntry(sof_a, PARAM_OUTER_RADIUS))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readDataCommon", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { outer_radius_d = DEF_OUTER_RADIUS; } // get the number of subgroups of neighbors // if (parser_d->isPresent(sof_a, PARAM_NUM_NEIGHBOR_SUBGROUPS)) { if (!num_neighbor_subgroups_d.readData(sof_a, PARAM_NUM_NEIGHBOR_SUBGROUPS, parser_d->getEntry(sof_a, PARAM_NUM_NEIGHBOR_SUBGROUPS))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readDataCommon", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { num_neighbor_subgroups_d = DEF_NUM_NEIGHBOR_SUBGROUPS; } // get the number of points to jump in the trajectory // before recalculating LEs // if (parser_d->isPresent(sof_a, PARAM_REINIT_STEP)) { if (!reinit_step_d.readData(sof_a, PARAM_REINIT_STEP, parser_d->getEntry(sof_a, PARAM_REINIT_STEP))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readDataCommon", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { reinit_step_d = DEF_REINIT_STEP; } // get the starting position // if (parser_d->isPresent(sof_a, PARAM_START_POS)) { if (!start_pos_d.readData(sof_a, PARAM_START_POS, parser_d->getEntry(sof_a, PARAM_START_POS))) { // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // return a warning message // return Error::handle(name(), L"readDataCommon", Error::READ, __FILE__, __LINE__, Error::WARNING); } } else { start_pos_d = DEF_START_POS; } // 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"readDataCommon", Error::IO, __FILE__, __LINE__, Error::WARNING); } } else { debug_level_d = Integral::DEF_DEBUG; } // 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"readDataCommon", Error::IO, __FILE__, __LINE__, Error::WARNING); } // delete the parser // delete parser_d; parser_d = (SofParser*)NULL; // exit gracefully // return true; }