// file: $isip_ifc/class/stat/Histogram/hist_03.cc // version: $Id: hist_03.cc 10393 2006-01-25 05:20:55Z srinivas $ // // isip include files // #include "Histogram.h" // method: sofSize // // arguments: none // // return: size of object // // this method returns the size of the object as written to an Sof file // int32 Histogram::sofSize() const { int32 bytes = dim_d.sofSize(); bytes += bins_d.sofSize(); bytes += counts_d.sofSize(); bytes += min_d.sofSize(); bytes += max_d.sofSize(); bytes += num_bins_d.sofSize(); bytes += SCALE_MAP.elementSofSize(); bytes += MODE_MAP.elementSofSize(); return bytes; } // 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 // bool8 Histogram::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 // if (!readData(sof_a)) { return false; } // exit gracefully // return true; } // 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_size) // 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 Histogram::readData(Sof& sof_a, const String& pname_a, int32 size_a, bool8 param_a, bool8 nested_a) { Integral::DEBUG debug_level = Integral::NONE; SofParser parser; parser.setDebug(debug_level); // 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); } // get the scale // if (!SCALE_MAP.readElementData((int32&)scale_d, sof_a, PARAM_SCALE, parser.getEntry(sof_a, PARAM_SCALE))) { return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } // get the mode // if (!MODE_MAP.readElementData((int32&)mode_d, sof_a, PARAM_MODE, parser.getEntry(sof_a, PARAM_MODE))) { return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } // get the dimension // if (!dim_d.readData(sof_a, PARAM_DIM, parser.getEntry(sof_a, PARAM_DIM), false, false)) { return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } // get the bins // if (!bins_d.readData(sof_a, PARAM_BINS, parser.getEntry(sof_a, PARAM_BINS), false, false)) { return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } // get the minimum values // if (!min_d.readData(sof_a, PARAM_MIN, parser.getEntry(sof_a, PARAM_MIN), false, false)) { return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } // get the maximum values // if (!max_d.readData(sof_a, PARAM_MAX, parser.getEntry(sof_a, PARAM_MAX), false, false)) { return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } // get the number of bins for all dimensions // if (!num_bins_d.readData(sof_a, PARAM_NUM_BINS, parser.getEntry(sof_a, PARAM_NUM_BINS), false, false)) { return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } // get the counts // if (!counts_d.readData(sof_a, PARAM_COUNTS, parser.getEntry(sof_a, PARAM_COUNTS), false, false)) { return Error::handle(name(), L"readData", Error::READ, __FILE__, __LINE__, Error::WARNING); } // exit gracefully // return true; }