// file: tr_lxn_size_0.cc
//

// isip include files
//
#include "train_lex_node.h"
#include "train_lex_node_constants.h"

// method: size_cc
//
// arguments: none
//
// return: an int_4 with number of bytes used by this object
//
// this method counts the size of the current object in bytes
//
int_4 Train_Lex_node::size_cc() {

  // set the size variable
  //
  int_4 size = 0;
  
  // add the size of each constituent data
  //
  size += sizeof(int_4);                    // phone_d
  size += sizeof(Train_Link_list*);               // child_d
  size += sizeof(int_4);                    // num_words_d
  size += num_words_d * sizeof(float_8);    // score_list_d
  size += sizeof(float_8);                  // max_lm_score_d
  size += sizeof(void_p);                   // tree_d
  size += sizeof(logical_1);                // status_d

  // get the size of the lattice node 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()) {
      size += node->size_cc();
      nd = (Train_Lattice_node*)(node->get_item_cc());
      size += nd->size_cc();
    }
  }

  // get the size of constituent children
  //
  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()) {
      size += node->size_cc();
      nd = (Train_Lex_node*)(node->get_item_cc());
      size += nd->size_cc();
    }
  }

  // exit gracefully
  //
  return size;
}
