// file: tr_lxn_debug_0.cc
//
 
// isip include files
//
#include "train_lex_node.h"
#include "train_lex_node_constants.h"

// method: debug_cc
//
// arguments:
//  FILE* fp: (input) file pointer used for output
//  char_1* message: (input) a message concatenated to each debug message
//
// return: a logical_1 value indicating status
//
// this method displays the values of all internal data
//
logical_1 Train_Lex_node::debug_cc(FILE* fp_a, char_1* message_a) {

  // dump the phone information
  //
  fprintf(fp_a, "%s::%s: phone_d = %ld\n", TRAIN_LXN_CLASS_NAME, message_a, phone_d);

  // dump the max lm score
  //
  fprintf(fp_a, "%s::%s: max_lm_score_d = %.6f\n", TRAIN_LXN_CLASS_NAME, message_a,
	  max_lm_score_d);  

  // dump the lm scores and number of words
  //
  fprintf(fp_a, "%s::%s: num_words_d = %ld\n", TRAIN_LXN_CLASS_NAME, message_a,
	  num_words_d);
  for (int_4 i = 0; i < num_words_d; i++) {
    fprintf(fp_a, "%s::%s: score_list_d[%ld] = %.6f\n", TRAIN_LXN_CLASS_NAME,
	    message_a, i, score_list_d[i]);
  }

  // dump the status flag
  //
  fprintf(fp_a, "%s::%s: word_list_d = %c\n", TRAIN_LXN_CLASS_NAME, message_a,
	  status_d);

  // dump the link-list pointer
  //
  fprintf(fp_a, "%s::%s: word_list_d = %p\n\n", TRAIN_LXN_CLASS_NAME, message_a,
	  word_list_d);

  // dump the word list
  //
  if (word_list_d != (Train_Link_list*)NULL) {
    Train_Lattice_node* nd = (Train_Lattice_node*)NULL;
    for (Train_Link_node* node = word_list_d->get_head_cc();
	 node != (Train_Link_node*)NULL; node = node->get_next_cc()) {
      nd = (Train_Lattice_node*)(node->get_item_cc());
      fprintf(fp_a, "%s::%s: Train_Lattice node = %p\n", TRAIN_LXN_CLASS_NAME, message_a,
	      nd);
      nd->debug_cc(fp_a, message_a);
      fprintf(fp_a, "\n");
    }
  }
  
  
  // dump the link-list pointer
  //
  fprintf(fp_a, "%s::%s: child_d = %p\n\n", TRAIN_LXN_CLASS_NAME, message_a,
	  child_d);

  // dump all the child nodes
  //
  if (child_d != (Train_Link_list*)NULL) {
    Train_Lex_node* nd = (Train_Lex_node*)NULL;
    for (Train_Link_node* node = child_d->get_head_cc(); node != (Train_Link_node*)NULL;
	 node = node->get_next_cc()) {
      nd = (Train_Lex_node*)(node->get_item_cc());
      fprintf(fp_a, "%s::%s: Child node = %p\n", TRAIN_LXN_CLASS_NAME, message_a,
	      nd);
      nd->debug_cc(fp_a, message_a);
      fprintf(fp_a, "\n");
    }
  }
  
  // dump the lex tree pointer
  //
  fprintf(fp_a, "%s::%s: tree_d = %p\n\n", TRAIN_LXN_CLASS_NAME, message_a,
	  tree_d);

  // exit gracefully
  //
  return ISIP_TRUE;
}
