// file: $isip/class/search/SymbolGraphNode/SymbolGraphNode.h // version: $Id: SymbolGraphNode.h 9373 2003-12-22 22:07:43Z alphonso $ // // make sure definitions are only made once // #ifndef ISIP_SYMBOL_GRAPH_NODE #define ISIP_SYMBOL_GRAPH_NODE // isip include files // #ifndef ISIP_STRING #include #endif #ifndef ISIP_LONG #include #endif #ifndef ISIP_FLOAT #include #endif #ifndef ISIP_SINGLE_LINKED_LIST #include #endif // forward class definitions // class SymbolGraph; // SymbolGraphNode: a class to hold the data specific to a symbol graph // class SymbolGraphNode { //--------------------------------------------------------------------------- // // 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 int32 DEF_NODE_INDEX = 0; static const int32 DEF_FRAME_INDEX = -1; static const int32 DEF_REFERENCE_COUNT = 0; static const int32 DEF_IN_DEGREE = 0; static const int32 DEF_OUT_DEGREE = 0; static const float32 DEF_SCORE = 0.0; //--------------------------------------- // // error codes // //--------------------------------------- //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // define the symbol index // String symbol_d; // define the frame index // Long node_index_d; // define the frame index // Long frame_index_d; // define the reference count for this node // Long reference_count_d; // define the node statistics // Long num_arcs_in_d; Long num_arcs_out_d; // define the maximum path score for this node // Float score_d; // define incoming and outgoing connections // SingleLinkedList prev_nodes_d; SingleLinkedList next_nodes_d; // define the list of previous scores // SingleLinkedList prev_scores_d; SingleLinkedList prevlm_scores_d; // define the forward acoustic and language model scores // SingleLinkedList lm_scores_d; SingleLinkedList ac_scores_d; // define the pointer to the parent graph // SymbolGraph* parent_graph_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 // ~SymbolGraphNode() { clear(); } // method: default constructor // SymbolGraphNode(); // method: constructor // SymbolGraphNode(int32 index, const String& symbol); // method: copy constructor // SymbolGraphNode(const SymbolGraphNode& copy_node) { assign(copy_node); } // method: assign // bool8 assign(const SymbolGraphNode& copy_node) { return Error::handle(name(), L"assign", Error::ARG, __FILE__, __LINE__); } // method: operator= // SymbolGraphNode& operator=(const SymbolGraphNode& arg) { assign(arg); return *this; } // i/o methods // int32 sofSize() const; // read methods // bool8 read(Sof& sof, int32 tag, const String& cname = CLASS_NAME); bool8 readData(Sof& sof, const String& pname = DEF_PARAM, int32 size = SofParser::FULL_OBJECT, bool8 param = true, bool8 nested = false); // write methods // bool8 write(Sof& sof, int32 tag, const String& cname = CLASS_NAME) const; bool8 writeData(Sof& sof, const String& pname = DEF_PARAM) const; // method: eq // bool8 eq(const SymbolGraphNode& 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: getScore // float32 getScore() const { return score_d; } // method: setScore // bool8 setScore(const float32 arg) { return (score_d = arg); } // method: getFrameIndex // int32 getFrameIndex() const { return frame_index_d; } // method: setFrameIndex // bool8 setFrameIndex(const int32 arg) { return (frame_index_d = arg); } // method: getNodeIndex // int32 getNodeIndex() const { return node_index_d; } // method: setNodeIndex // bool8 setNodeIndex(const int32 arg) { return (node_index_d = arg); } // method: getSymbol // bool8 getSymbol(String& arg) { return arg.assign(symbol_d); } // method: setSymbol // bool8 setSymbol(const String& arg) { return symbol_d.assign(arg); } // method: getIncoming // int32 getIncoming() const { return num_arcs_in_d; } // method: getOutgoing // int32 getOutgoing() const { return num_arcs_out_d; } // method: getRefCount // int32 getRefCount() { return reference_count_d; } // method: incrementRefCount // bool8 incrementRefCount() { reference_count_d++; return true; } // method: decrementRefCount // bool8 decrementRefCount() { reference_count_d--; return true; } // method: getParentGraph // SymbolGraph* getParentGraph() const { return parent_graph_d; } // method: setParentGraph // bool8 setParentGraph(SymbolGraph* ptr) { parent_graph_d = ptr; return true; } // method: getPrevNodesList // SingleLinkedList& getPrevNodesList() { return prev_nodes_d; } // method: getNextNodesList // SingleLinkedList& getNextNodesList() { return next_nodes_d; } // method: getPrevScoresList // SingleLinkedList& getPrevScoresList() { return prev_scores_d; } // method: getPrevLMScoresList // SingleLinkedList& getPrevLMScoresList() { return prevlm_scores_d; } // method: getLMScoresList // SingleLinkedList& getLMScoresList() { return lm_scores_d; } // method: getScoresList // SingleLinkedList& getScoresList() { return ac_scores_d; } // get scores method // bool8 getScores(SymbolGraphNode* node, float32& lm_score, float32& ac_score); // insert methods // bool8 insertPrevNode(SymbolGraphNode*& node, float32 score, int32 max_hist, float32 lm_score); bool8 insertNextNode(SymbolGraphNode*& node, float32 lm_score, float32 ac_score); bool8 insertNode(SymbolGraphNode* node, SymbolGraphNode** lnode, int32*& map_list); bool8 insertNode(SymbolGraphNode* node, float32 lm_score, float32 ac_score, SymbolGraphNode** lnode, int32*& map_list); //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: }; // include the context class here circumvent the circular dependency // #ifndef ISIP_SYMBOL_GRAPH #include #endif // end of include file // #endif