// file: $isip/class/search/NBestPath/NBestPath.h // version: $Id: NBestPath.h 9332 2003-11-03 14:27:14Z alphonso $ // // make sure definitions are only made once // #ifndef ISIP_NBEST_PATH #define ISIP_NBEST_PATH #ifndef ISIP_FLOAT #include #endif #ifndef ISIP_LONG #include #endif #ifndef ISIP_SINGLE_LINKED_LIST #include #endif #ifndef ISIP_NBEST_NODE #include #endif // NBestPath: a class that is used as the list of partial paths // class NBestPath { //--------------------------------------------------------------------------- // // public constants // //--------------------------------------------------------------------------- public: // define the class name // static const String CLASS_NAME; //---------------------------------------- // // i/o related constants // //---------------------------------------- static const String DEF_PARAM; //---------------------------------------- // // default values and arguments // //---------------------------------------- // default values // static const float32 DEF_MAX_SCORE = -1.0e10; static const int32 DEF_FRAME_INDEX = 0; //--------------------------------------- // // error codes // //--------------------------------------- //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // define the linked list of partial paths // SingleLinkedList paths_d; // define the frame at which this path list was created // Long frame_index_d; // define the score of the best partial path in this list // Float max_score_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); // method: setDebug // static bool8 setDebug(Integral::DEBUG debug_level) { debug_level_d = debug_level; return true; } // method: destructor // ~NBestPath() { clear(); } // method: default constructor // NBestPath() { // set the member data // frame_index_d = DEF_FRAME_INDEX; max_score_d = DEF_MAX_SCORE; // set the allocation mode // paths_d.setAllocationMode(DstrBase::USER); } // method: copy constructor // NBestPath(const NBestPath& copy_sym) { assign(copy_sym); } // method: assign // bool8 assign(const NBestPath& copy_node) { return Error::handle(name(), L"assign", Error::ARG, __FILE__, __LINE__); } // method: operator= // NBestPath& operator=(const NBestPath& arg) { assign(arg); return *this; } // method: sofSize // int32 sofSize() const { return Error::handle(name(), L"sofSize", Error::ARG, __FILE__, __LINE__); } // method: read // bool8 read(Sof& sof, int32 tag, const String& cname = CLASS_NAME) { return Error::handle(name(), L"read", Error::ARG, __FILE__, __LINE__); } // method: readData // bool8 readData(Sof& sof, const String& pname = DEF_PARAM, int32 size = SofParser::FULL_OBJECT, bool8 param = true, bool8 nested = false) { return Error::handle(name(), L"readData", Error::ARG, __FILE__, __LINE__); } // method: write // bool8 write(Sof& sof, int32 tag, const String& cname = CLASS_NAME) const { return Error::handle(name(), L"write", Error::ARG, __FILE__, __LINE__); } // method: writeData // bool8 writeData(Sof& sof, const String& pname = DEF_PARAM) const { return Error::handle(name(), L"writeData", Error::ARG, __FILE__, __LINE__); } // method: eq // bool8 eq(const NBestPath& obj) const { return (this == &obj); } // 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); } // clear method // bool8 clear(Integral::CMODE ctype = Integral::DEF_CMODE); //--------------------------------------------------------------------------- // // class-specific public methods // //--------------------------------------------------------------------------- // method: getNumPaths // int32 getNumPaths() const { return paths_d.length(); } // method: setPaths // bool8 setPaths(SingleLinkedList& arg) { return paths_d.assign(arg); } // method: getPaths // SingleLinkedList& getPaths() { return paths_d; } // method: setFrameIndex // bool8 setFrameIndex(int32 arg) { return (frame_index_d = arg); } // method: getFrameIndex // int32 getFrameIndex() { return frame_index_d; } // method: setMaxScore // bool8 setMaxScore(float32 arg) { return (max_score_d = arg); } // method: getMaxScore // float32 getMaxScore() { return max_score_d; } // method to add a partial paths // bool8 insertPath(NBestNode* path); // method to extend partial paths // bool8 growPaths(NBestPath**& path_list, float32 scale, float32 penalty, int32 max_paths, float32 beam); // method to prune partial paths // bool8 prune(float32 beam, int32 max_paths); //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: }; // end of include file // #endif