// file: inst_clear_0.cc
//

// isip include files
//
#include "instance.h"
#include "instance_constants.h"

// method: clear_cc
//
// arguments: none
//
// return: a logical_1 flag indicating status
//
// this method cleans the contents of the class
//
logical_1 Instance::clear_cc() {

  // remove the network information
  //
  lex_node_d = (Lex_node*)NULL;
  phone_index_d = INSTANCE_DEFAULT_INDEX;
  
  // remove the tokens
  //
  if (token_list_d != (Link_list*)NULL) {

    // loop over all active tokens --- each corresponds to an
    // active state for this phone
    //
    Token* tok = (Token*)NULL;
    for (Link_node* tok_node = token_list_d->get_head_cc();
	 tok_node != (Link_node*)NULL; tok_node = tok_node->get_next_cc()) {
      
      // get the corresponding token
      //
      tok = (Token*)(tok_node->get_item_cc());

      // free the token
      //
      delete tok;
    }
    delete token_list_d;
    token_list_d = (Link_list*)NULL;
  }
  
  // reset the parameters
  //
  max_score_d = INSTANCE_DEFAULT_SCORE;
  lm_score_d = INSTANCE_DEFAULT_SCORE;
  frame_d = INSTANCE_DEFAULT_INDEX;
  
  // exit gracefully
  //
  return ISIP_TRUE;
}
