Classes Utilities Scripts Speech Search Up Home
ISIP IFC Index
Title Bar

/home5/piconepr/public_html/isip/projects/speech/software/documentation/class/search/Hypothesis/Hypothesis.h

// file: $isip/class/search/Hypothesis/Hypothesis.h
// version: $Id: Hypothesis.h 8862 2002-12-05 21:03:20Z alphonso $
//

// make sure definitions are only made once
//
#ifndef ISIP_HYPOTHESIS
#define ISIP_HYPOTHESIS

// isip include files
//
#ifndef ISIP_TRACE
#include <Trace.h>
#endif

// Hypothesis: a class to hold a word start hypothesis
//
class Hypothesis {

  //---------------------------------------------------------------------------
  //
  // public constants
  //
  //---------------------------------------------------------------------------
public:

  // define the class name
  //
  static const String CLASS_NAME;

  //----------------------------------------
  //
  // i/o related constants
  //
  //----------------------------------------  
  
  //----------------------------------------
  //
  // default values and arguments
  //
  //----------------------------------------  

  //---------------------------------------
  //
  // error codes
  //
  //---------------------------------------

  static const long ERR = (long)90200;
  static const long READ = (long)90201;
  
  //---------------------------------------------------------------------------
  //
  // protected data
  //
  //---------------------------------------------------------------------------
protected:

  // hypothesis score
  // estimates distance to target
  //
  float score_d;

  // pointer to word level trace
  //
  Trace* trace_d;

  // define a static memory manager
  //
  static MemoryManager mgr_d;
  
  // define a static debug level
  //
  static Integral::DEBUG debug_level_d;
  
  //---------------------------------------------------------------------------
  //
  // required public methods
  //
  //---------------------------------------------------------------------------
public:

  // method: name
  //
  static const String& name() {
    return CLASS_NAME;
  }

  // other static methods
  //
  static boolean diagnose(Integral::DEBUG debug_level);

  // debug method
  //
  boolean debug(const unichar* message) const;
  
  // method: setDebug
  //
  static boolean setDebug(Integral::DEBUG debug_level) {
    debug_level_d = debug_level;
    return true;
  }

  // method: destructor
  //
  ~Hypothesis() {}

  // method: default constructor
  //
  Hypothesis(Trace* trace = NULL, float score = 0) {
    trace_d = trace;
    score_d = score;
  }

  // method: copy constructor
  //
  Hypothesis(const Hypothesis& copy_hyp) {
    assign(copy_hyp);
  }

  // method: assign
  //
  boolean assign(const Hypothesis& hyp) {
    trace_d = hyp.trace_d;
    score_d = hyp.score_d;
    return true;
  }
  
  // method: operator =
  //
  Hypothesis& operator = (const Hypothesis& arg) {
    assign(arg);
    return *this;
  }

  // method: eq
  //
  boolean eq(const Hypothesis& arg) {
    if ((arg.trace_d == trace_d) &&
	Integral::almostEqual((double)arg.score_d, (double)score_d)) {
      return true;
    }
    return false;
  }
  
  // method: operator >
  //
  boolean operator > (const Hypothesis& arg) {
    if (score_d > arg.score_d) {
      return true;
    }
    else {
      return false;
    }
  }

  // method: operator <
  //
  boolean operator < (const Hypothesis& arg) {
    if (score_d < arg.score_d) {
      return true;
    }
    else {
      return false;
    }
  }

  // i/o methods:
  //  calling i/o methods for a Hypothesis object will cause an error
  //  since the Trace is a run-time object that should not be
  //  preserved between runs of aprogram.
  //

  // method: sofSize
  //
  long sofSize() const {
    return Error::handle(name(), L"sofSize", Hypothesis::READ,
			 __FILE__, __LINE__, Error::WARNING);
  }
  
  // method: read
  //
  boolean read(Sof& sof, long tag, const String& cname = CLASS_NAME) {
    return Error::handle(name(), L"read", Hypothesis::READ,
			 __FILE__, __LINE__, Error::WARNING);
  }

  // method: write
  //
  boolean write(Sof& sof, long tag, const String& cname = CLASS_NAME) const {
    return Error::handle(name(), L"write", Hypothesis::READ,
			 __FILE__, __LINE__, Error::WARNING);
  }

  // method: readData
  //
  boolean readData(Sof& sof, const String& pname = String::EMPTY,
		   long size = SofParser::FULL_OBJECT,
		   boolean param = true,
                   boolean nested = false) {
    return Error::handle(name(), L"readData", Hypothesis::READ,
			 __FILE__, __LINE__, Error::WARNING);
  }

  // method: writeData
  //
  boolean writeData(Sof& sof, const String& pname = String::EMPTY) const {
    return Error::handle(name(), L"writeData", Hypothesis::READ,
			 __FILE__, __LINE__, Error::WARNING);
  }

  // method: new
  //
  static void* operator new(size_t size) {
    return mgr_d.get();
  }

  // method: new[]
  //
  static void* operator new[](size_t size) {
    return mgr_d.getBlock(size);
  }

  // method: delete
  //
  static void operator delete(void* ptr) {
    mgr_d.release(ptr);
  }

  // method: delete[]
  //
  static void operator delete[](void* ptr) {
    mgr_d.releaseBlock(ptr);
  }

  // method: setGrowSize
  //
  static boolean setGrowSize(long grow_size) {
    return mgr_d.setGrow(grow_size);
  }

  // method: clear
  //
  boolean clear(Integral::CMODE cmode) {
    return true;
  }

  //---------------------------------------------------------------------------
  //
  // class-specific public methods
  //
  //---------------------------------------------------------------------------

  // method: getScore
  //
  float getScore() {
    return score_d;
  }

  // method: getTrace
  //
  Trace* getTrace() {
    return trace_d;
  }
  
  //---------------------------------------------------------------------------
  //
  // private methods
  //
  //---------------------------------------------------------------------------
private:

};

// end of include file
//
#endif

Footer

Up | Home | Courses | Projects | Proposals | Publications Please direct questions or comments to joseph.picone@isip.piconepress.com