// 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 #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 int32 ERR = (int32)90200; static const int32 READ = (int32)90201; //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // hypothesis score // estimates distance to target // float32 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 bool8 diagnose(Integral::DEBUG debug_level); // debug method // bool8 debug(const unichar* message) const; // method: setDebug // static bool8 setDebug(Integral::DEBUG debug_level) { debug_level_d = debug_level; return true; } // method: destructor // ~Hypothesis() {} // method: default constructor // Hypothesis(Trace* trace = NULL, float32 score = 0) { trace_d = trace; score_d = score; } // method: copy constructor // Hypothesis(const Hypothesis& copy_hyp) { assign(copy_hyp); } // method: assign // bool8 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 // bool8 eq(const Hypothesis& arg) { if ((arg.trace_d == trace_d) && Integral::almostEqual((float64)arg.score_d, (float64)score_d)) { return true; } return false; } // method: operator > // bool8 operator > (const Hypothesis& arg) { if (score_d > arg.score_d) { return true; } else { return false; } } // method: operator < // bool8 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 // int32 sofSize() const { return Error::handle(name(), L"sofSize", Hypothesis::READ, __FILE__, __LINE__, Error::WARNING); } // method: read // bool8 read(Sof& sof, int32 tag, const String& cname = CLASS_NAME) { return Error::handle(name(), L"read", Hypothesis::READ, __FILE__, __LINE__, Error::WARNING); } // method: write // bool8 write(Sof& sof, int32 tag, const String& cname = CLASS_NAME) const { return Error::handle(name(), L"write", Hypothesis::READ, __FILE__, __LINE__, Error::WARNING); } // method: readData // bool8 readData(Sof& sof, const String& pname = String::EMPTY, int32 size = SofParser::FULL_OBJECT, bool8 param = true, bool8 nested = false) { return Error::handle(name(), L"readData", Hypothesis::READ, __FILE__, __LINE__, Error::WARNING); } // method: writeData // bool8 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 bool8 setGrowSize(int32 grow_size) { return mgr_d.setGrow(grow_size); } // method: clear // bool8 clear(Integral::CMODE cmode) { return true; } //--------------------------------------------------------------------------- // // class-specific public methods // //--------------------------------------------------------------------------- // method: getScore // float32 getScore() { return score_d; } // method: getTrace // Trace* getTrace() { return trace_d; } //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: }; // end of include file // #endif