// file: lex_node.h
//
// this is the header file for the lexical tree node class
//

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

// isip include files
//
#ifndef __ISIP_INTEGRAL
#include <integral.h>
#endif

#ifndef __ISIP_INTEGRAL_CONSTANTS
#include <integral_constants.h>
#endif

#ifndef __ISIP_LINK_LIST
#include <link_list.h>
#endif

// Lex_node: a class that holds a lexical tree node
//
class Lex_node {

  //---------------------------------------------------------------------------
  //
  // protected data
  //
  //---------------------------------------------------------------------------
protected:

  // lexical tree node data
  //
  int_4 phone_d;               // the monophone at this node
  float_4 score_d;             // the lm score at this node
  logical_1 word_end_d;        // flag to indicate possible word end
  Link_list* words_d;          // link list of words covered here
  Link_list* child_d;          // link list of children of this node
  logical_1 type_d;            // the type of word nodes stored here
  
  //---------------------------------------------------------------------------
  //
  // public methods
  //
  //---------------------------------------------------------------------------
public:
  
  // required methods
  //
  char_1* name_cc();
  volatile void error_handler_cc(char_1* method_name, char_1* message);
  logical_1 debug_cc(FILE *fp, char_1* message);
  int_4 size_cc();
  
  // destructors/constructors
  //
  ~Lex_node();                                         // destructor
  Lex_node();                                          // default
  Lex_node(int_4 phone);                               // overloaded
  Lex_node(Lex_node& node);                            // copy

  // set data access methods
  //
  logical_1 set_phone_cc(int_4 phone) {
    phone_d = phone;
    return ISIP_TRUE;
  }
  
  logical_1 set_child_cc(Link_list* child) {
    child_d = child;
    return ISIP_TRUE;
  }
  
  logical_1 set_words_cc(Link_list* words) {
    words_d = words;
    return ISIP_TRUE;
  }
  
  logical_1 set_score_cc(float_4 score) {
    score_d = score;
    return ISIP_TRUE;
  }
  
  logical_1 set_word_end_cc(logical_1 val) {
    word_end_d = val;
    return ISIP_TRUE;
  }
  
  logical_1 set_type_cc(logical_1 val) {
    type_d = val;
    return ISIP_TRUE;
  }
  
  // get data access methods
  //
  int_4 get_phone_cc() {
    return phone_d;
  }
  
  Link_list* get_child_cc() {
    return child_d;
  }
  
  Link_list* get_words_cc() {
    return words_d;
  }
  
  float_4 get_score_cc() {
    return score_d;
  }
  
  logical_1 get_word_end_cc() {
    return word_end_d;
  }
  
  logical_1 get_type_cc() {
    return type_d;
  }
  
  // get the child lex-node with the specified phone
  //
  Lex_node* make_node_cc(int_4 phone);
  Lex_node* get_node_cc(int_4 phone);

  // add the specified word to the current node
  //
  logical_1 add_word_cc(void_p word);
  logical_1 add_word_cc(void_p word, float_4 score);

  // add a child node to the list of child nodes
  //
  logical_1 add_child_cc(Lex_node* node);

  // clear the contents of the lex node recursively
  //
  logical_1 clear_cc();
  
  // get the number of nodes starting from this node
  //
  int_4 num_nodes_cc();

  //---------------------------------------------------------------------------
  //
  // private methods
  //
  //---------------------------------------------------------------------------
private:

};

// end of file
// 
#endif
