⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 grapharcdiagnose.h

📁 这是一个从音频信号里提取特征参量的程序
💻 H
字号:
// file: $isip/class/dstr/GraphArc/GraphArcDiagnose.h// version: $Id: GraphArcDiagnose.h,v 1.4 2001/04/30 21:39:29 duncan Exp $//// make sure definitions are only made once//#ifndef ISIP_GRAPH_ARC_DIAGNOSE#define ISIP_GRAPH_ARC_DIAGNOSE// isip include files//#ifndef ISIP_GRAPH_ARC#include <GraphArc.h>#endif// GraphArcDiagnose: a class that contains the diagnose method of// GraphArc class.//template<class TObject>class GraphArcDiagnose : public GraphArc<TObject> {  //---------------------------------------------------------------------------  //  // public constants  //  //---------------------------------------------------------------------------public:    // define the class name  //    //----------------------------------------  //  // i/o related constants  //  //----------------------------------------      //----------------------------------------  //  // default values and arguments  //  //----------------------------------------  // default values  //      // default arguments to methods  //    //----------------------------------------  //  // error codes  //  //----------------------------------------      //---------------------------------------------------------------------------  //  // protected data  //  //---------------------------------------------------------------------------protected:  //---------------------------------------------------------------------------  //  // required public methods  //  //---------------------------------------------------------------------------public:  // method: name  //  static const String& name() {    return GraphArc<TObject>::name();  }  // other static methods  //  static boolean diagnose(Integral::DEBUG debug_level);  // debug methods  //  these methods are omitted since this class does not have data  //  members and operations    //    // destructor/constructor(s):  //  these methods are omitted since this class does not have data  //  members and operations  //  // assign methods:  //  these methods are omitted since this class does not have data  //  members and operations  //  // operator= methods:  //  these methods are omitted since this class does not have data  //  members and operations  //    // i/o methods:  //  these methods are omitted since this class does not have data  //  members and operations  //  // equality methods:  //  these methods are omitted since this class does not have data  //  members and operations  //  // memory-management methods:  //  these methods are omitted since this class does not have data  //  members and operations  //    //---------------------------------------------------------------------------  //  // class-specific public methods  //  //---------------------------------------------------------------------------  //  these methods are omitted since this class does not have data  //  members and operations  //    //---------------------------------------------------------------------------  //  // private methods  //  //---------------------------------------------------------------------------private:}; // below are all the methods for the GraphArcDiagnose template class////-----------------------------------------------------------------------------//// required static methods////-----------------------------------------------------------------------------// method: diagnose//// arguments://  Integral::DEBUG level: (input) debug level for diagnostics//// return: a boolean value indicating status//template<class TObject>boolean GraphArcDiagnose<TObject>::diagnose(Integral::DEBUG level_a) {  //----------------------------------------------------------------------  //  // 0. preliminaries  //  //----------------------------------------------------------------------  // output the class name  //  if (level_a > Integral::NONE) {    SysString output(L"diagnosing class ");    output.concat(CLASS_NAME);    output.concat(L": ");    Console::put(output);    Console::increaseIndention();  }  //---------------------------------------------------------------------  //  // 1. required public methods  //  //---------------------------------------------------------------------  // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing required public methods...\n");    Console::increaseIndention();  }  // test the debug methods  //  setDebug(debug_level_d);    if (level_a > Integral::BRIEF) {    Integral::debug(L"debug");  }  // default constructor    //  GraphArc<TObject> def_arc;	  GraphVertex<TObject> test_vert;  def_arc.setVertex(&test_vert);  // copy constructor  //  GraphArc<TObject> copy_arc(def_arc);  // all of the constructed vertices should contain the same item now  //  if (def_arc.vertex_d != copy_arc.vertex_d) {    return Error::handle(name(), L"constructors", Error::TEST, __FILE__,			 __LINE__);  }    // check the constructors and destructors for allocating on the dynamic  // memory heap  //  GraphArc<TObject>* def_dyn_arc = new GraphArc<TObject>();  def_dyn_arc->setVertex(&test_vert);  // copy constructor  //  GraphArc<TObject>* copy_dyn_arc =    new GraphArc<TObject>(*def_dyn_arc);    // all of the constructed nodes should contain the same item now  //  if (def_dyn_arc->vertex_d != copy_dyn_arc->vertex_d) {    return Error::handle(name(), L"constructors", Error::TEST, __FILE__,			 __LINE__);  }    // clear some vertices  //  def_dyn_arc->clear();  def_arc.clear();  copy_dyn_arc->clear();  copy_arc.clear();    // see if we can dynamically delete  //  delete def_dyn_arc;  delete copy_dyn_arc;    // test large allocation construction and deletion  //  if (level_a >= Integral::ALL) {    // output an informative message    //    Console::put(L"\ntesting large chunk memory allocation and deletion:\n");        // set the memory to a strange block size so we can hopefully catch any    // frame overrun errors    //    GraphArc<TObject>::setGrowSize((long)731);        // loop for a large number of times creating and deleting a large number    // of vertices at each loop. we create both self-allocating and    // non-self-allocating nodes.    //    for (long j = 1; j <= 100; j++) {      GraphArc<TObject>** arcs = new GraphArc<TObject>*[j * 100];            // create the vertices      //      for (long i = 0; i < j * 100; i++) {	arcs[i] = new GraphArc<TObject>();      }            // delete nodes      //      for (long i = (j * 100) - 1; i >= 0; i--) {	delete arcs[i];      }            delete [] arcs;    }    // perform the same test using the new[] and delete [] operators    //    for (long j = 1; j <= 100; j++) {            // allocate a large number of nodes      //      GraphArc<TObject>* arcs = new GraphArc<TObject>[j * 100]();      // clean up memory      //      delete [] arcs;    }  }  // test assign methods  //    GraphVertex<TObject> vert0;  GraphVertex<TObject> vert1;    GraphArc<TObject> tmp_arc;  GraphArc<TObject>* tmp_dyn_arc = new GraphArc<TObject>();    // set the items  //  Char ch_item(L'X');  vert1.setItem(&ch_item);  tmp_dyn_arc->setVertex(&vert1);  tmp_dyn_arc->setWeight(0.79);  tmp_dyn_arc->setEpsilon(true);  // try the copy assign  //  tmp_arc.assign(*tmp_dyn_arc);    if ((tmp_arc.vertex_d != &vert1) ||      (tmp_dyn_arc->vertex_d != &vert1) ||      !(tmp_arc.weight_d.almostEqual(0.79)) ||      !(tmp_dyn_arc->weight_d.almostEqual(0.79)) ||      !tmp_arc.is_epsilon_d ||      !tmp_dyn_arc->is_epsilon_d) {          return Error::handle(name(), L"assign", Error::TEST, __FILE__, __LINE__);  }  // testing remaining required methods  //  Char chr_item_0(L'A');  GraphArc<Char> dbg_arc;  GraphVertex<Char> char_vert;  char_vert.setItem(&chr_item_0);  dbg_arc.setVertex(&char_vert);  dbg_arc.setWeight(0.79);  dbg_arc.setEpsilon(true);  if (level_a >= Integral::ALL) {      dbg_arc.debug(L"testing debug method");  }  // use the arcs created in the assign method tests  //  if (!tmp_arc.eq(*tmp_dyn_arc)) {    return Error::handle(name(), L"eq", Error::TEST, __FILE__,			 __LINE__);  }  // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }    // --------------------------------------------------------------------  //  // 2. testing class-specific public methods  //     endpoint vertex get and set methods  //  // --------------------------------------------------------------------  // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing class-specific public methods: vertex get/set methods...\n");    Console::increaseIndention();   }    // use the arc declared in the testing of assign methods to test  // the get methods. the set methods have already been tested via the  // assign method tests  //  if (tmp_arc.getVertex() != &vert1) {    return Error::handle(name(), L"getVertex", Error::TEST, __FILE__,			 __LINE__);  }  // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }    // --------------------------------------------------------------------  //  // 3. testing class-specific public methods  //     arc weight get and set methods  //  // --------------------------------------------------------------------  // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing class-specific public methods: arc weight get/set methods...\n");    Console::increaseIndention();   }    Float temp_weight = tmp_arc.getWeight();  if (!temp_weight.almostEqual(0.79)) {    return Error::handle(name(), L"getWeight", Error::TEST, __FILE__,			 __LINE__);  }  // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }    // --------------------------------------------------------------------  //  // 4. testing class-specific public methods  //     arc epsilon flag get and set methods  //  // --------------------------------------------------------------------  // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing class-specific public methods: arc epsilon flag get/set methods...\n");    Console::increaseIndention();   }    if (!tmp_arc.getEpsilon()) {    return Error::handle(name(), L"getEpsilon", Error::TEST, __FILE__,			 __LINE__);  }  // clean up memory  //  delete tmp_dyn_arc;  // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }    //---------------------------------------------------------------------  //  // 5. print completion message  //  //---------------------------------------------------------------------  // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }    if (level_a > Integral::NONE) {    SysString output(L"diagnostics passed for class ");    output.concat(name());    output.concat(L"\n");    Console::put(output);  }  // exit gracefully  //  return true;}// end of include file//#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -