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

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

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

#ifndef __ISIP_TRAIN_LINK_LIST
#include <train_link_list.h>
#endif

#ifndef __ISIP_TRAIN_LATTICE_NODE
#include <train_lattice_node.h>
#endif

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

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

  // phone-related data
  //
  int_4 phone_d;               // the monophone at this node
  int_4 phone_index_d;         // the phone index in this node
  Train_Link_list* child_d;          // link-list of children of this node

  // words / LM related data
  //
  Train_Link_list* word_list_d;   // list of lattice nodes covered at this node
  float_8* score_list_d;          // LM scores for each of these words
  int_4 num_words_d;              // number of lattice nodes covered
  
  // the most likely LM score for the words covered at this node
  //
  float_8 max_lm_score_d;        

  // reference to the parent lexical tree
  // this is a void pointer to avoid referencing problems
  //
  void_p tree_d;

  // a flag to indicate use status
  //
  logical_1 status_d;
  
  //---------------------------------------------------------------------------
  //
  // 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
  //
  ~Train_Lex_node();                                         // destructor
  Train_Lex_node();                                          // default
  Train_Lex_node(int_4 phone);                               // overloaded
  Train_Lex_node(int_4 phone, void_p tree);                  // overloaded
  Train_Lex_node(Train_Lex_node& node);                            // copy

  // set data access methods
  //
  logical_1 set_phone_cc(int_4 phone);
  logical_1 set_child_cc(Train_Link_list* child);
  logical_1 set_words_cc(Train_Link_list* word_list);
  logical_1 set_score_list_cc(int_4 num, float_8* scores);
  logical_1 set_max_score_cc(float_8 score);
  logical_1 set_tree_cc(void_p tree);
  logical_1 set_status_cc(logical_1 status);
  logical_1 set_phone_ind_cc(int_4 phone_ind);
  
  // get data access methods
  //
  int_4 get_phone_cc();
  Train_Link_list* get_child_cc();
  Train_Link_list* get_words_cc();
  logical_1 get_score_list_cc(int_4& num, float_8*& scores);
  float_8 get_max_score_cc();
  void_p get_tree_cc();
  logical_1 get_status_cc();
  int_4 get_phone_ind_cc();

  // get the child lex-node with the specified phone
  //
  Train_Lex_node* make_node_cc(int_4 phone);
  Train_Lex_node* get_node_cc(int_4 phone);

  // add the specified word to the current node
  //
  logical_1 add_word_cc(Train_Lattice_node* latnode, float_8 score);

  // add a child node to the list of child nodes
  //
  logical_1 add_child_cc(Train_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
