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

📄 nodediagnose.h

📁 这是一个从音频信号里提取特征参量的程序
💻 H
📖 第 1 页 / 共 2 页
字号:
// file: $isip/class/dstr/Node/NodeDiagnose.h// version: $Id: NodeDiagnose.h,v 1.8 2000/12/13 22:21:00 alphonso Exp $//// make sure definitions are only made once//#ifndef ISIP_NODE_DIAGNOSE#define ISIP_NODE_DIAGNOSE// isip include files//#ifndef ISIP_NODE#include "Node.h"#endif// NodeDiagnose: a class that contains the diagnose method of Node class.//template<class TObject>class NodeDiagnose : public Node<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:  // methods: name  //  static const String& name() {    return Node<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 NodeDiagnose 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 NodeDiagnose<TObject>::diagnose(Integral::DEBUG level_a) {      //---------------------------------------------------------------------------  //  // 0. preliminaries  //  //---------------------------------------------------------------------------  // output the class name  //  if (level_a > Integral::NONE) {    SysString output(L"diagnosing class ");    output.concat(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 destructor/constructor(s):  //  Node<TObject> def_node;		// default constructor  TObject item;  def_node.assign(&item);  Node<TObject> copy_node(def_node);	// copy constructor  Node<TObject> assign_node(&item);	// assignment constructor  // all of the constructed nodes should contain the same item now  //  if ((def_node.item_d != copy_node.item_d) ||      (def_node.item_d != assign_node.item_d) ||      (copy_node.item_d != assign_node.item_d)) {    return Error::handle(name(), L"constructors", Error::TEST, __FILE__,			 __LINE__);  }  // test memory-management methods:  //  set the memory to a strange block size so we can hopefully catch any  //  frame overrun errors  //  Node<TObject>::setGrowSize((long)31);    // loop for a large number of times creating and deleting a large number  // of nodes at each loop.  //  for (long j = 1; j <= 20; j++) {    Node<TObject>** nodes = new Node<TObject>*[j * 53];        // create the nodes    //    for (long i = 0; i < j * 53; i++) {      nodes[i] = new Node<TObject>;    }        // delete nodes    //    for (long i = (j * 53) - 1; i >= 0; i--) {      delete nodes[i];    }        delete [] nodes;  }    // perform the same test using the new[] and delete [] operators  //  for (long j = 1; j <= 20; j++) {        // allocate a large number of nodes    //    Node<TObject>* nodes = new Node<TObject>[j * 53];        // clean up memory    //    delete [] nodes;  }  // test the debug method  //   Node<Char> dbg_node;  dbg_node.setDebug(Integral::ALL);  if (dbg_node.debug_level_d != Integral::ALL) {    return Error::handle(name(), L"setDebug", Error::TEST,			 __FILE__, __LINE__);  }  dbg_node.setDebug(Integral::NONE);  if (dbg_node.debug_level_d != Integral::NONE) {    return Error::handle(name(), L"setDebug", Error::TEST,			 __FILE__, __LINE__);  }  Node<TObject> debug_node;		// default constructor  TObject debug_item;  debug_node.assign(&debug_item);  if (level_a > Integral::BRIEF) {    debug_node.debug(L"debug");  }  // test assign methods:  //  create some temporary objects and items  //    TObject item0;  TObject item1;    Node<TObject>* tmp_node = new Node<TObject>();  Node<TObject>* tmp_node_2 = new Node<TObject>;    // try the item assign method  //  tmp_node->assign(&item1);  tmp_node_2->assign(&item1);    if (tmp_node->item_d->ne(item1) || tmp_node_2->item_d->ne(item1)      || (tmp_node_2->item_d != &item1)) {    return Error::handle(name(), L"assign", Error::TEST,			 __FILE__, __LINE__);  }  // clean up  //  delete tmp_node;  delete tmp_node_2;  // test i/o methods:  //  we need binary and text sof files  //  String text_filename;  Integral::makeTemp(text_filename);  String bin_filename;  Integral::makeTemp(bin_filename);    // open files in write mode  //  Sof text_file;  text_file.open(text_filename, File::WRITE_ONLY, File::TEXT);  Sof bin_file;  bin_file.open(bin_filename, File::WRITE_ONLY, File::BINARY);  // create some objects to write  //  Char write_char(L'a');  Node<Char> write_char_node(&write_char);  String write_string(L"gfedcba");    Node<String> write_str_node(&write_string);    // create embedded nodes  //  Node<Node<Char > > write_char_nn(&write_char_node);  Node<Node<Node<Char > > > write_char_nnn(&write_char_nn);  Node<Node<String > > write_str_nn(&write_str_node);  Node<Node<Node<String > > > write_str_nnn(&write_str_nn);  // print the nodes  //  if (level_a >= Integral::ALL) {    write_char_node.debug(L"write_char_node");    write_str_node.debug(L"write_str_node");    write_char_nn.debug(L"write_char_nn");    write_str_nn.debug(L"write_str_nn");    write_char_nnn.debug(L"write_char_nnn");    write_str_nnn.debug(L"write_str_nnn");  }    // write the values  //  write_char_node.write(text_file, (long)0);  write_char_node.write(bin_file, (long)0);      write_str_node.write(text_file, (long)0);  write_str_node.write(bin_file, (long)0);      write_char_nn.write(text_file, (long)0);  write_char_nn.write(bin_file, (long)0);      write_str_nn.write(text_file, (long)0);  write_str_nn.write(bin_file, (long)0);      write_char_nnn.write(text_file, (long)0);  write_char_nnn.write(bin_file, (long)0);    write_str_nnn.write(text_file, (long)0);  write_str_nnn.write(bin_file, (long)0);      // close the files  //  text_file.close();  bin_file.close();  // open the files in read mode  //  text_file.open(text_filename);  bin_file.open(bin_filename);

⌨️ 快捷键说明

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